Since upgrading to angular 13, I've encountered an issue while attempting to create a worker in the following manner:
new Worker(new URL('../path/to/worker', import.meta.url), {type: 'module'})
This code works as expected with "ng serve" or "ng build", but fails when using "ng build --configuration production". Disabling buildOptimizer and aot resolves the issue, but this is not ideal.
The problem seems to be related to the import.meta.url. It's puzzling since this should be a standard feature.
When running "ng build --configuration production", the error thrown is:
Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js):
SyntaxError: Support for the experimental syntax 'importMeta' isn't currently enabled (18:102):
Add @babel/plugin-syntax-import-meta () to the 'plugins' section of your Babel config to enable parsing.
This situation is strange since I'm not directly using babel. It's possible that Angular's buildOptimizer incorporates babel, but if so, configuration changes are not possible.
Is there a solution or workaround for this issue?