fix: require paths

This commit is contained in:
cha0s 2020-12-07 08:06:56 -06:00
parent 3252f681a3
commit 43c0ac4609
3 changed files with 11 additions and 6 deletions

View File

@ -10,7 +10,7 @@ const r = eval('require');
(async () => {
const config = readConfig();
const paths = Object.entries(config).map(([plugin]) => {
const paths = Object.keys(config).map((plugin) => {
try {
const local = join(process.cwd(), 'src', plugin);
r.resolve(local);

View File

@ -9,14 +9,19 @@ export default class WebpackPlugin {
}
apply(compiler) {
const paths = Object.entries(this.config).map(([plugin]) => {
// eslint-disable-next-line no-eval
eval('require')('@babel/register')({
presets: ['@babel/preset-react'],
});
const paths = Object.keys(this.config).map((plugin) => {
try {
const local = join(process.cwd(), 'src', plugin);
// eslint-disable-next-line no-eval
eval('require.resolve')(plugin);
return plugin;
eval('require.resolve')(local);
return local;
}
catch (error) {
return join(process.cwd(), plugin);
return plugin;
}
});
const modules = paths.map((path) => `require('${path}')`).join(',');

View File

@ -42,7 +42,7 @@ const middleware = (neutrino) => {
export default {
hooks: {
'@latus/core/config': () => ({
entry: './src/react',
entry: './react',
}),
'@latus/http/build': () => middleware,
'@latus/http/plugins': (req, {config: {'@latus/react': {entry}}}) => ({