-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Description
Which @angular/* package(s) are the source of the bug?
common
Is this a regression?
Yes
Description
Goal: Update to angular 13, still create dynamic modules/components and have all imports work.
Outcome: After upgrading to Angular 13 I am still able to create dynamic modules and components but when I try to apply the common module as an import it has empty exports which leads to issues like.
core.mjs:10144 NG0303: Can't bind to 'ngIf' since it isn't a known property of 'div'.
I've debugged the issue and saw in ɵɵdefineNgModule all the module info(imports, declarations, exports) are all undefined and end up defaulted to empty arrays. I don't know enough about the inner workings to say if this is normal but when I was debugging the dynamic module I did notice that emod.exports was an empty array.
However, you will notice if I reexport things from the common module they start working.
Please provide a link to a minimal reproduction of the bug
https://github.com/bstaley/ng13-dynamic-common-import-fail
Please provide the exception or error you saw
core.mjs:10144 NG0303: Can't bind to '<Any Pipe Or Directive From Common Module>' since it isn't a known property of 'div'.
### Please provide the environment you discovered this bug in (run `ng version`)
```true
Angular CLI: 13.2.6
Node: 14.15.1
Package Manager: npm 6.14.8
OS: win32 x64
Angular: 13.2.7
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1302.6
@angular-devkit/build-angular 13.2.6
@angular-devkit/core 13.2.6
@angular-devkit/schematics 13.2.6
@angular/cli 13.2.6
@schematics/angular 13.2.6
ng-packagr 13.2.1
rxjs 7.5.5
typescript 4.5.5
Anything else?
- You will notice the example uses both a lib and an app. Normally the lib would be published as a separate package but I am able to reproduce the error the same with them together.
- In the example repo you will also notice that the lib has a component which is added to the dynamic template(other-lib). I add the module to the imports input. It is understood by the component and renders.
- It doesn't seem to matter if I try to import CommonModule into app.module or any other module for that matter.