Angular webpack 为 style.js 生成不带 type=module 的标签。我开始使用 webpack-module federation,现在收到错误: styles.js:3277 Uncaught SyntaxError: Cannot use 'import.meta' Outside a module。在一个 scss 样式表中,我使用 @import。de angular.json 中有没有办法让 Angular webpack 注入带有模块类型的 style.js ?我可以删除 library: { type: 'module' } 并在 webpack.config 中设置 scriptType: 'text/javascript' 并重置回 Angular 12 版本,但这不是我想要的。
我正在尝试使用 angular 8 和 Karma 测试日期字符串转换的实际输出。
在我的 app.module 我使用语法:
registerLocaleData(localeNl, 'nl');
在我的模板中,我使用
{{date | date: 'MMMM yyyy'}}
当我使用以下单元测试管道转换时:
element = fixture.nativeElement;
content = element.querySelector('.content');
expect(content.innerText).toContain('mei 2020')
Run Code Online (Sandbox Code Playgroud)
我收到 Karma 错误,即innerText 是“May 2020”而不是“mei 2020”,但在实际的角度应用程序中,它正确呈现文本“mei 2020”。那么如何让 Karma 环境使用与应用程序相同的语言环境呢?