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 () => { (async () => {
const config = readConfig(); const config = readConfig();
const paths = Object.entries(config).map(([plugin]) => { const paths = Object.keys(config).map((plugin) => {
try { try {
const local = join(process.cwd(), 'src', plugin); const local = join(process.cwd(), 'src', plugin);
r.resolve(local); r.resolve(local);

View File

@ -9,14 +9,19 @@ export default class WebpackPlugin {
} }
apply(compiler) { 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 { try {
const local = join(process.cwd(), 'src', plugin);
// eslint-disable-next-line no-eval // eslint-disable-next-line no-eval
eval('require.resolve')(plugin); eval('require.resolve')(local);
return plugin; return local;
} }
catch (error) { catch (error) {
return join(process.cwd(), plugin); return plugin;
} }
}); });
const modules = paths.map((path) => `require('${path}')`).join(','); const modules = paths.map((path) => `require('${path}')`).join(',');

View File

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