fix: require paths
This commit is contained in:
parent
3252f681a3
commit
43c0ac4609
|
@ -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);
|
||||||
|
|
|
@ -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(',');
|
||||||
|
|
|
@ -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}}}) => ({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user