fix(cli): remove modules from webpack config
This commit is contained in:
@@ -34,10 +34,9 @@ export async function serveBackend(options: ServeOptions) {
|
||||
poll: true,
|
||||
},
|
||||
(err: Error) => {
|
||||
console.log('Build succeeded');
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
} else console.log('Build succeeded');
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ export async function buildBundle(options: BuildOptions) {
|
||||
...options,
|
||||
checksEnabled: false,
|
||||
isDev: false,
|
||||
isBackend: false,
|
||||
});
|
||||
const compiler = webpack(config);
|
||||
|
||||
|
||||
@@ -79,39 +79,40 @@ export function createConfig(
|
||||
}),
|
||||
);
|
||||
|
||||
const backendRelatedConfig = {
|
||||
watch: true,
|
||||
watchOptions: {
|
||||
ignored: [/node_modules\/(?!\@backstage)/],
|
||||
},
|
||||
externals: [
|
||||
nodeExternals({
|
||||
modulesDir: paths.rootNodeModules,
|
||||
whitelist: [
|
||||
'webpack/hot/poll?100',
|
||||
/\@backstage\/.*\/(?!node_modules)/,
|
||||
],
|
||||
}),
|
||||
nodeExternals({
|
||||
modulesDir: paths.targetNodeModules,
|
||||
whitelist: [
|
||||
'webpack/hot/poll?100',
|
||||
/\@backstage\/.*\/(?!node_modules)/,
|
||||
],
|
||||
}),
|
||||
],
|
||||
target: 'node' as const,
|
||||
node: {
|
||||
__dirname: true,
|
||||
__filename: true,
|
||||
global: true,
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
mode: isDev ? 'development' : 'production',
|
||||
profile: false,
|
||||
...(isBackend
|
||||
? {
|
||||
watch: true,
|
||||
watchOptions: {
|
||||
ignored: [/node_modules\/(?!\@backstage)/],
|
||||
// poll: 1000
|
||||
},
|
||||
externals: [
|
||||
nodeExternals({
|
||||
modulesDir: paths.rootNodeModules,
|
||||
whitelist: [
|
||||
'webpack/hot/poll?100',
|
||||
/\@backstage\/.*\/(?!node_modules)/,
|
||||
],
|
||||
}),
|
||||
nodeExternals({
|
||||
modulesDir: paths.targetNodeModules,
|
||||
whitelist: [
|
||||
'webpack/hot/poll?100',
|
||||
/\@backstage\/.*\/(?!node_modules)/,
|
||||
],
|
||||
}),
|
||||
],
|
||||
target: 'node',
|
||||
node: {
|
||||
__dirname: true,
|
||||
__filename: true,
|
||||
global: true,
|
||||
},
|
||||
}
|
||||
? backendRelatedConfig
|
||||
: {
|
||||
node: {
|
||||
module: 'empty',
|
||||
@@ -140,7 +141,6 @@ export function createConfig(
|
||||
resolve: {
|
||||
extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'],
|
||||
mainFields: ['main:src', 'browser', 'module', 'main'],
|
||||
modules: [paths.targetNodeModules, paths.rootNodeModules],
|
||||
plugins: [
|
||||
new ModuleScopePlugin(
|
||||
[paths.targetSrc, paths.targetDev],
|
||||
|
||||
@@ -38,7 +38,11 @@ export async function serveBundle(options: ServeOptions) {
|
||||
const paths = resolveBundlingPaths(options);
|
||||
const pkgPath = paths.targetPackageJson;
|
||||
const pkg = await fs.readJson(pkgPath);
|
||||
const config = createConfig(paths, { ...options, isDev: true });
|
||||
const config = createConfig(paths, {
|
||||
...options,
|
||||
isDev: true,
|
||||
isBackend: false,
|
||||
});
|
||||
const compiler = webpack(config);
|
||||
|
||||
const server = new WebpackDevServer(compiler, {
|
||||
|
||||
@@ -22,7 +22,7 @@ export type BundlingOptions = {
|
||||
isDev: boolean;
|
||||
config: Config;
|
||||
appConfigs: AppConfig[];
|
||||
isBackend?: boolean;
|
||||
isBackend: boolean;
|
||||
};
|
||||
|
||||
export type ServeOptions = BundlingPathsOptions & {
|
||||
|
||||
Reference in New Issue
Block a user