🐞 Bug report
Command (mark with an x)
- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
no
Description
Angular 8 support build web worker command, but when the app deploys to CDN with --deploy-url, the web worker ts will also loaded from the CDN URL.
This will cause cross domain error
ERROR Error: Uncaught (in promise): SecurityError: Failed to construct 'Worker':
It makes that impossible to use web worker with @angular/cli in the production environment
Angular CLI should support cross-domain web worker loader with options or by default
async () => {
const codeString = await fetch(originWorkerUrl).then(res => res.text());
const localWorkerUrl = window.URL.createObjectURL(new Blob([codeString], {
type: 'application/javascript'
}));
}
🔬 Minimal Reproduction
https://angular.io/guide/web-worker
with ng build --prod --deploy-url to any CDN url can easily reproduce this error
🔥 Exception or Error
ERROR Error: Uncaught (in promise): SecurityError: Failed to construct 'Worker': Script at 'http://assets.daily.xxx.net/xxx.worker.js' cannot be accessed from origin 'http://daily.abc.xxx.net'.
Error: Failed to construct 'Worker': Script at 'http://assets.daily.xxx.net/xxx.worker.js' cannot be accessed from origin 'http://daily.abc.xxx.net'.
🌍 Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 8.0.4
Node: 12.4.0
OS: darwin x64
Angular: 8.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.800.4
@angular-devkit/build-angular 0.800.4
@angular-devkit/build-optimizer 0.800.4
@angular-devkit/build-webpack 0.800.4
@angular-devkit/core 8.0.4
@angular-devkit/schematics 8.0.4
@angular/cli 8.0.4
@ngtools/webpack 8.0.4
@schematics/angular 8.0.4
@schematics/update 0.800.4
rxjs 6.4.0
typescript 3.4.5
webpack 4.30.0
🐞 Bug report
Command (mark with an
x)Is this a regression?
no
Description
Angular 8 support build web worker command, but when the app deploys to CDN with
--deploy-url, the web worker ts will also loaded from the CDN URL.This will cause cross domain error
It makes that impossible to use web worker with
@angular/cliin the production environmentAngular CLI should support cross-domain web worker loader with options or by default
worker-pluginlike the code below https://github.com/GoogleChromeLabs/worker-plugin#pluginsor replace
worker-pluginwithworker-loaderwhich support cross-origin-policyhttps://github.com/webpack-contrib/worker-loader#cross-origin-policy
angular-cli/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/worker.ts
Line 13 in 277d4ab
or should give an option to deploy the web worker build out to the assets folder
🔬 Minimal Reproduction
https://angular.io/guide/web-worker
with
ng build --prod --deploy-urlto any CDN url can easily reproduce this error🔥 Exception or Error
🌍 Your Environment