0

I have an workspace with a library and a showcase project: mylib and myshow. I've been using the following scripts without any problem with Angular 13, 14 and 15:

"scripts": {
    "lib:watch": "ng build mylib --configuration development --watch",
    "showcase:watch": "ng build myshow --watch --configuration development --deploy-url /myshow/ --base-href /myshow/",
}

When I made a change in the lib, everything was built-up smoothly.

Then I upgraded to Angular 16. Now a change like adding a function in a component from mylib results in this error (when building the myshow project):

Error: projects/myshow/src/app/app.module.ts:25:12 - error NG6002: 'Module1Module' does not appear to be an NgModule class.
This likely means that the dependency (mylib) which declares Module1Module is not compatible with Angular Ivy.

I tried to set (temporarily) "enableIvy" to false in "angularCompilerOptions" in tsconfig.ts, but I get the same error.

I compared the dist folders, before and after the change that produces the error and one file diff is striking. mylib\module1\module1.module.d.ts looks like this before the change:

import { ModuleWithProviders } from '@angular/core';
import { IModule1Config } from './configuration/configuration';
import * as i0 from "@angular/core";
import * as i1 from "./main.component";
import * as i2 from "./components/component1/component1.component";
import * as i3 from "./components/component2/component2.component";
import * as i9 from "@angular/common";
import * as i11 from "../lib/mylib.module";
import * as i12 from "@angular/forms";
export declare class Module1Module {
    static forRoot(initialConfig: IModule1Config): ModuleWithProviders<Module1Module>;
    static ɵfac: i0.ɵɵFactoryDeclaration<Module1Module, never>;
    static ɵmod: i0.ɵɵNgModuleDeclaration<Module1Module, [typeof i1.MainComponent, typeof i2.Component1Component, typeof i3.Component2Component, [typeof i9.CommonModule, typeof i11.MyLibModule, typeof i12.FormsModule], [typeof i1.MainComponent, typeof i2.Component1Component, typeof i3.Component2Component]>;
    static ɵinj: i0.ɵɵInjectorDeclaration<Module1Module>;
}
export * from './components';
//# sourceMappingURL=module1.module.d.ts.map

and like this after the change that produces the error:

import { ModuleWithProviders } from '@angular/core';
import { IModule1Config } from './configuration/configuration';
export declare class Module1Module {
    static forRoot(initialConfig: IModule1Config): ModuleWithProviders<Module1Module>;
}
export * from './components';
//# sourceMappingURL=module1.module.d.ts.map

Note: I also used an improved version of the scripts, but the problem persists:

"scripts": {
    "start": "npm-run-all clean --parallel lib:watch showcase:start-waiton",
    "lib:watch": "ng build mylib --watch --configuration development",
    "showcase:start-waiton": "wait-on dist/mylib/package.json && npm run showcase:watch",
    "showcase:watch": "ng build myshow --watch --configuration development --deploy-url /myshow/ --base-href /myshow/",
    "clean": "rimraf dist"
}

Any thoughts on how I can can fix this?

Paul
  • 1,224
  • 2
  • 14
  • 31

0 Answers0