简体   繁体   English

Angular 13 - 当前未启用对实验语法“importMeta”的支持

[英]Angular 13 - Support for the experimental syntax 'importMeta' isn't currently enabled

After upgrading to angular 13 I'm having this issue.升级到 angular 13 后,我遇到了这个问题。 I am trying to create a worker like this:我正在尝试创建一个这样的工人:

new Worker(new URL('../path/to/worker', import.meta.url), {type: 'module'})

This works fine when I do " ng serve " or " ng build ".当我执行“ ng serve ”或“ ng build ”时,这很好用。 However, it does not work when I run " ng build --configuration production ".但是,当我运行“ ng build --configuration production ”时它不起作用。 If I turn buildOptimizer and aot to false it does work but that's something I'm trying to avoid.如果我将buildOptimizeraot 设置为 false,它确实有效,但这是我试图避免的。

It looks like this has everything to to with the import.meta.url .看起来这一切都与import.meta.url有关。 It doesn't make much sense since this is an established standard.这没有多大意义,因为这是一个既定标准。

So, when I run "ng build --configuration production" It throws the error:所以,当我运行“ng build --configuration production”时,它会抛出错误:

Error: Module build failed (from./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js):错误:模块构建失败(来自./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js):

SyntaxError: Support for the experimental syntax 'importMeta' isn't currently enabled (18:102): SyntaxError:当前未启用对实验性语法“importMeta”的支持 (18:102):

Add @babel/plugin-syntax-import-meta ( https://git.io/vbKK6 ) to the 'plugins' section of your Babel config to enable parsing.将 @babel/plugin-syntax-import-meta ( https://git.io/vbKK6 ) 添加到 Babel 配置的“插件”部分以启用解析。

This is weird since I'm not using babel, at least directly.这很奇怪,因为我没有直接使用 babel。 Maybe it's Angular's buildOptimizer that uses babel, but if it is, I cannot change it's configs.也许是使用 babel 的 Angular 的 buildOptimizer,但如果是,我无法更改它的配置。

Is there any fix or workaround to this issue?这个问题有什么修复或解决方法吗?

I had the same issue after upgrading to Angular 12 from 9. I managed to fix the issue by removing the node_modules folder and the package-lock.json file and running npm install.从 9 升级到 Angular 12 后,我遇到了同样的问题。我设法通过删除 node_modules 文件夹和 package-lock.json 文件并运行 ZBB30E85411B56DF41296726AB445DC8F 来解决这个问题。

There must have been some conflicting packages or something but doing the above fixed it.一定有一些冲突的包或其他东西,但执行上述修复它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当前未启用对实验性语法“jsx”的支持 - Support for the experimental syntax 'jsx' isn't currently enabled Expo 目前未启用对实验语法“jsx”的支持 - Expo Support for the experimental syntax 'jsx' isn't currently enabled Rails 上的 Ruby “当前未启用对实验语法 'jsx' 的支持” - Ruby on Rails "support for the experimental syntax 'jsx' isn't currently enabled" 如何解决当前未启用对实验语法“jsx”的支持 - How to solve Support for the experimental syntax 'jsx' isn't currently enabled Laravel:当前未启用对实验语法“classProperties”的支持 - Laravel: Support for the experimental syntax 'classProperties' isn't currently enabled 错误:当前未启用对实验性语法“可选链”的支持,但已启用 - Error: Support for the experimental syntax 'optionalChaining' isn't currently enabled, but it is 语法错误 - 当前未启用对实验性语法“decorators-legacy”的支持 - Syntax error - Support for the experimental syntax 'decorators-legacy' isn't currently enabled 如何解决问题当前未启用对实验性语法“classProperties”的支持 - How to solve the problem Support for the experimental syntax 'classProperties' isn't currently enabled “松散”:true 未修复当前未启用对实验性语法“classProperties”的支持 - "loose": true is not fixing Support for the experimental syntax 'classProperties' isn't currently enabled React.js 当前未启用对实验性语法“classProperties”的支持错误 - Support for the experimental syntax 'classProperties' isn't currently enabled error on a React.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM