我试图使用worker-plugin和Comlink在Angular 7中延迟加载包含WebWorkers的模块。基本上,我已经按照here的教程进行编译并且工作正常。
当运行ng serve
时,它会在第一次使用TypeError: Cannot read property 'kind' of undefined
重新加载时崩溃。
代码在GitHub上。 https://github.com/jetkiwi/angular-comlink-lazyload-example
PS C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example> ng serve
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
29% building 163/164 modules 1 active ...example\src\app\lazy\worker\markdown.tsWarning (worker-plugin): output.globalObject is set to "window". It must be set to "self" to support HMR in Workers.
Date: 2019-03-18T10:51:05.270Z
Hash: faa40366aaa3831a6ec7
Time: 10417ms
chunk {es2015-polyfills} es2015-polyfills.js, es2015-polyfills.js.map (es2015-polyfills) 284 kB [initial] [rendered]
chunk {lazy-lazy-module} lazy-lazy-module.js, lazy-lazy-module.js.map (lazy-lazy-module) 21.5 kB [rendered]
chunk {main} main.js, main.js.map (main) 11 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 236 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 8.77 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.3 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.76 MB [initial] [rendered]
i 「wdm」: Compiled successfully.
i 「wdm」: Compiling...
Date: 2019-03-18T10:51:11.248Z - Hash: f7b1396d7e355dec9ed5 - Time: 2026ms
6 unchanged chunks
chunk {lazy-lazy-module} lazy-lazy-module.js, lazy-lazy-module.js.map (lazy-lazy-module) 21.5 kB [rendered]
ERROR in : TypeError: Cannot read property 'kind' of undefined
at getAssignmentTargetKind (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:10228:28)
at Object.isAssignmentTarget (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:10271:16)
at checkObjectLiteral (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:47313:45)
at checkExpressionWorker (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:51812:28)
at checkExpression (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:51757:42)
at checkExpressionWithContextualType (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:51587:26)
at checkApplicableSignature (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:48906:35)
at chooseOverload (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:49225:26)
at resolveCall (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:49177:26)
at resolveCallExpression (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:49484:20)
at resolveSignature (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:49772:28)
at getResolvedSignature (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:49804:26)
at checkCallExpression (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:49896:29)
at checkExpressionWorker (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:51823:28)
at checkExpression (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:51757:42)
at resolveDecorator (C:\Users\jetkiwi\Documents\Development\angular-comlink-lazyload-example\node_modules\typescript\lib\typescript.js:49691:28)
i 「wdm」: Failed to compile.
更新我的同事发现使用--aot
选项运行可以防止它崩溃。
将@ angular-devkit / build-angular更新为0.13.8解决了这个问题。
我假设它与@ ngtools / webpack有关。 https://github.com/angular/angular-cli/releases/tag/v7.3.8