@@ -26,23 +26,16 @@ export async function serveBackend(options: BackendServeOptions) {
|
||||
isDev: true,
|
||||
});
|
||||
|
||||
const compiler = webpack(config);
|
||||
|
||||
const watcher = compiler.watch(
|
||||
{
|
||||
poll: true,
|
||||
},
|
||||
(err: Error | undefined) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
} else console.log('Build succeeded');
|
||||
},
|
||||
);
|
||||
const compiler = webpack(config, (err: Error | undefined) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
} else console.log('Build succeeded');
|
||||
});
|
||||
|
||||
const waitForExit = async () => {
|
||||
for (const signal of ['SIGINT', 'SIGTERM'] as const) {
|
||||
process.on(signal, () => {
|
||||
watcher.close(() => console.log('Stopped watcher'));
|
||||
compiler.close(() => console.log('Stopped watcher'));
|
||||
// exit instead of resolve. The process is shutting down and resolving a promise here logs an error
|
||||
process.exit();
|
||||
});
|
||||
|
||||
@@ -258,7 +258,7 @@ export async function createBackendConfig(
|
||||
modulesDir: paths.rootNodeModules,
|
||||
additionalModuleDirs: moduleDirs,
|
||||
allowlist: ['webpack/hot/poll?100', ...localPackageNames],
|
||||
}) as any,
|
||||
}),
|
||||
],
|
||||
target: 'node' as const,
|
||||
node: {
|
||||
@@ -358,8 +358,11 @@ function nodeExternalsWithResolve(
|
||||
},
|
||||
});
|
||||
|
||||
return (context: string, request: string, callback: any) => {
|
||||
currentContext = context;
|
||||
return (
|
||||
{ context, request }: { context?: string; request?: string },
|
||||
callback: any,
|
||||
) => {
|
||||
currentContext = context!;
|
||||
return externals(context, request, callback);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user