0
votes

I have a snippet:

import { platformBrowser }    from '@angular/platform-browser';
import { enableProdMode } from '@angular/core';
enableProdMode();

import '../../../src/bundle';

import {ModuleNgFactory} from './module.ngfactory';

platformBrowser().bootstrapModuleFactory(ModuleNgFactory);

As soon, I enable ivy, i face this error:

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$ 

What the error is: ERROR in test/angular-webpack/angular/bundle.aot.ts(7,31): error TS2307: Cannot find module './module.ngfactory'.

I try to enable ivy, by adding angularCompilerOptions section to enableIvy to be true, and that is when I get this error.

2

2 Answers

2
votes

Angular ivy no longer has any ngfactories.

instead of having to store metadata about the components in a separate file, the info is now stored as static fields on the component itself.

You should therefor refactor your code to not use ngfactory dependant thing such as importing ./module.ngfactory

0
votes

need to add allowEmptyCodegenFiles : true in angularCompilerOptions in tsconfig.app.json