Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions packages/angular_devkit/build_angular/src/server/base_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,31 @@ describe('Server Builder', () => {

await run.stop();
});

it('should not try to resolve web-worker', async () => {
host.writeMultipleFiles({
'src/app/app.worker.ts': `
/// <reference lib="webworker" />

const foo: string = 'hello world';
addEventListener('message', ({ data }) => {
postMessage(foo);
});
`,
'src/main.server.ts': `
if (typeof Worker !== 'undefined') {
const worker = new Worker(new URL('./app/app.worker', import.meta.url), { type: 'module' });
worker.onmessage = ({ data }) => {
console.log('page got message:', data);
};
worker.postMessage('hello');
}
`,
});

const run = await architect.scheduleTarget(target);
const output = (await run.result) as ServerBuilderOutput;
expect(output.success).toBe(true);
await run.stop();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ export function getServerConfig(wco: WebpackConfigOptions): Configuration {
output: {
libraryTarget: 'commonjs',
},
module: {
parser: {
javascript: {
worker: false,
url: false,
},
},
},
plugins: [
// Fixes Critical dependency: the request of a dependency is an expression
new ContextReplacementPlugin(/@?hapi(\\|\/)/),
Expand Down