Saturday, 6 May 2017

Make external module eliglible for Angular AOT compiler

I am trying to develop angular application which would be combined from multiple repositories. My catalog structure is:

git_repo_1-bootstrap-module
|                        |
|                        src
|
git_repo_2-lazy-loaded-module
|        |
|        src
|
git_repo_3-lazy-loaded-module
        |
        src

package.json in the bootstrap module have dependencies to child modules:

 "dependencies": {
    "module-1": "git+ssh://git@gitlab.com/my-project/module-1.git",
    "module-2": "git+ssh://git@gitlab.com/my-project/module-2.git",
    //another dependencies
  },

Now, I am lazy-loading child modules as follows:

const routes: Routes = [
    {path: 'home', loadChildren: '../../node_modules/my-project-module1/src/app/home.module#HomeModule' },
    {path: 'account-settings', loadChildren: '../../node_modules/my-project-module2/src/app/account-settings.module#AccountSettingsModule' }
];

Everything works with Just In Time (JIT) compilation. The problem starts with the Ahead of Time (AOT):

ERROR in ./compiled/src/app/app.module.ngfactory.ts
Module build failed: Error: Cannot find module '/path-to-my-project/compiled/node_modules/krolewicz-ol-admin-home/src/app/home.module.ngsummary.json'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Loader.trackSymbolRootDecl (/path-to-my-project/node_modules/src/Loader.ts:157:23)
    at Loader.trackSymbolRootDecl (/path-to-my-project/node_modules/src/Loader.ts:168:19)
    at /path-to-my-project/node_modules/src/Loader.ts:120:29
 @ ./src/main.browser.aot.ts 10:0-78

I have no idea how for what are used .ngsummary.json files, and how to make my external modules eliglible for AOT compilator?

I am using https://github.com/AngularClass/angular-starter as a boiler plate. So every configuration file is as in this repo.



via Maciej Sobala

No comments:

Post a Comment