У меня есть фрагмент:
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$
Что за ошибка: ОШИБКА в test/angular-webpack/angular/bundle.aot.ts(7,31): ошибка TS2307: не удается найти модуль './module.ngfactory'.
Я пытаюсь включить ivy, добавив раздел angularCompilerOptions, чтобы enableIvy был истинным, и именно тогда я получаю эту ошибку.
У Angular Ivy больше нет ngfactories.
вместо того, чтобы хранить метаданные о компонентах в отдельном файле, информация теперь хранится в виде статических полей в самом компоненте.
Поэтому вы должны реорганизовать свой код, чтобы не использовать вещи, зависящие от ngfactory, такие как импорт ./module.ngfactory
нужно добавить allowEmptyCodegenFiles : true
в angularCompilerOptions в tsconfig.app.json