我有一个片段:
import { platformBrowser } from '@angular/platform-browser';
import { enableProdMode } from '@angular/core';
enableProdMode();
import '../../../src/bundle';
import {ModuleNgFactory} from './module.ngfactory';
platformBrowser().bootstrapModuleFactory(ModuleNgFactory);一旦我启用了ivy,我就会遇到这样的错误:
Running "cory-build-aot" task
Compiling @angular/core : module as esm5
Compiling @angular/common : module as esm5
Compiling @angular/platform-browser : module as esm5
Compiling @angular/common/http : module as esm5
Compiling @angular/router : module as esm5
Compiling @angular/forms : module as esm5
Hash: d7163c5eb0d56ede4ba6
Version: webpack 4.32.2
Time: 24870ms
Built at: 05/29/2019 2:43:19 PM
4 assets
Entrypoint polyfills = polyfills.d7163c5eb0d56ede4ba6.js sourcemaps/polyfills.d7163c5eb0d56ede4ba6.js.map
Entrypoint bundle = bundle.d7163c5eb0d56ede4ba6.js sourcemaps/bundle.d7163c5eb0d56ede4ba6.js.map
[0] ./test/angular-webpack/angular/polyfills.ts 0 bytes {1} [built]
[1] ./test/angular-webpack/angular/bundle.aot.ts 0 bytes {0} [built]
ERROR in test/angular-webpack/angular/bundle.aot.ts(7,31): error TS2307: Cannot find module './module.ngfactory'.
Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html
[0] ./node_modules/html-webpack-plugin/lib/loader.js!./test/angular-webpack/index.html 261 bytes {0} [built]
Warning: Command failed: ./node_modules/.bin/webpack-cli --color --cache --production --config /home/patrikx3/Projects/patrikx3/corifeus/corifeus-web/node_modules/corifeus-builder-angular/src/webpack.test.config.js
Compiling @angular/core : module as esm5
Compiling @angular/common : module as esm5
Compiling @angular/platform-browser : module as esm5
Compiling @angular/common/http : module as esm5
Compiling @angular/router : module as esm5
Compiling @angular/forms : module as esm5
Use --force to continue.
Aborted due to warnings.
Execution Time (2019-05-29 14:42:53 UTC+2)
cory-build-aot 25.8s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100%
Total 25.9s
patrikx3@workstation:~/Projects/patrikx3/corifeus/corifeus-web$ 错误是: error in test/angular-webpack/angular/bundle.aot.ts(7,31):ERROR TS2307:找不到模块'./module.ngfactory‘。
我尝试通过将angularCompilerOptions部分添加到enableIvy来启用ivy,这就是我收到这个错误的时候。
发布于 2019-05-29 20:55:49
角常春藤不再有任何no工厂。
现在,信息作为静态字段存储在组件本身上,而不是将有关组件的元数据存储在单独的文件中。
因此,您应该重构您的代码,以不使用与ngfactory相关的东西,如导入./module.ngfactory
发布于 2019-05-29 20:57:51
需要在tsconfig.app.json的angularCompilerOptions中添加allowEmptyCodegenFiles : true
https://stackoverflow.com/questions/56361024
复制相似问题