AOT build of application fails when uses re-export in entryComponents
See original GitHub issueType of Issue
[x ] Bug Report
[ ] Feature Request
Description
When uses re-export to define entryComponents for NgModule AOT build of end application fails. It seems that ng-packagr
does not write type infomation to *metadata.json
files.
How To Reproduce
/components/my-component.ts
@Component(..) export class MyComponent { }
/components/index.ts:
export {MyComponent} from "./my-component";
/module.ts:
import {MyComponent} from "./components";
@NgModule({
...
entryComponents: [
// entry here
MyComponent
]
})
export class MyModule {}
Angular compilier fail to build application that uses library. If I use direct import in the module, like import {MyComponent} from "./components/my-component"
, error is gone.
Angular compilier error:
ERROR in TypeError: Cannot read property 'members' of undefined
at AotSummaryResolver.resolveSummary (C:\Git\stream-webapp\node_modules\@angular\compiler\bundles\compiler.umd.js:32817:56)
at CompileMetadataResolver._loadSummary (C:\Git\stream-webapp\node_modules\@angular\compiler\bundles\compiler.umd.js:14837:66)
at CompileMetadataResolver._getEntryComponentMetadata (C:\Git\stream-webapp\node_modules\@angular\compiler\bundles\compiler.umd.js:15895:66)
at C:\Git\stream-webapp\node_modules\@angular\compiler\bundles\compiler.umd.js:15361:55
at Array.map (<anonymous>)
at CompileMetadataResolver.getNgModuleMetadata (C:\Git\stream-webapp\node_modules\@angular\compiler\bundles\compiler.umd.js:15361:18)
at C:\Git\stream-webapp\node_modules\@angular\compiler\bundles\compiler.umd.js:31325:70
at Array.forEach (<anonymous>)
at analyzeFile (C:\Git\stream-webapp\node_modules\@angular\compiler\bundles\compiler.umd.js:31308:53)
at AotCompiler._analyzeFile (C:\Git\stream-webapp\node_modules\@angular\compiler\bundles\compiler.umd.js:30510:17)
at AotCompiler.findGeneratedFileNames (C:\Git\stream-webapp\node_modules\@angular\compiler\bundles\compiler.umd.js:30526:42)
at Object.findGeneratedFileNames (C:\Git\stream-webapp\packages\compiler-cli\src\transformers\program.ts:434:60)
at TsCompilerAotCompilerTypeCheckHostAdapter.getSourceFile (C:\Git\stream-webapp\packages\compiler-cli\src\transformers\compiler_host.ts:384:45)
at findSourceFile (C:\Git\stream-webapp\node_modules\typescript\lib\typescript.js:73056:29)
at processImportedModules (C:\Git\stream-webapp\node_modules\typescript\lib\typescript.js:73228:25)
at findSourceFile (C:\Git\stream-webapp\node_modules\typescript\lib\typescript.js:73104:17)
at args (C:\Git\stream-webapp\node_modules\typescript\lib\typescript.js:72993:85)
at getSourceFileFromReferenceWorker (C:\Git\stream-webapp\node_modules\typescript\lib\typescript.js:72966:34)
at processSourceFile (C:\Git\stream-webapp\node_modules\typescript\lib\typescript.js:72993:13)
at processRootFile (C:\Git\stream-webapp\node_modules\typescript\lib\typescript.js:72848:13)
at C:\Git\stream-webapp\node_modules\typescript\lib\typescript.js:72006:60
at Object.forEach (C:\Git\stream-webapp\node_modules\typescript\lib\typescript.js:1526:30)
at Object.createProgram (C:\Git\stream-webapp\node_modules\typescript\lib\typescript.js:72006:16)
at AngularCompilerProgram._createProgramWithBasicStubs (C:\Git\stream-webapp\packages\compiler-cli\src\transformers\program.ts:482:27)
at C:\Git\stream-webapp\packages\compiler-cli\src\transformers\program.ts:182:17
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
at Function.Module.runMain (module.js:692:11)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:666:3
Version Information
$ node_modules/.bin/ng-packagr --version
ng-packagr: 2.4.1
@angular/*: 5.2.3
typescript: 2.6.2
rxjs: 5.5.6
node: 9.8.0
npm/yarn: 5.7.1
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:12 (2 by maintainers)
Top Results From Across the Web
FeatureModule fails during an AOT build when static forRoot ...
I am encountering an AOT build issue using Angular@5.1.0. The error is: ERROR in Error during template compile of 'AppModule' Function calls ...
Read more >NgModule FAQ - Angular
NgModules help organize an application into cohesive blocks of functionality. This page answers the questions many developers ask about NgModule design and ...
Read more >Building an AOT Friendly Dynamic Content Outlet in Angular
We're going to build a special module with a dynamic component outlet that can be included and used anywhere in your application.
Read more >Frequently used Modules - Angular - w3resource
Re -exported by BrowserModule, which is included automatically in the root AppModule when you create a new app with the CLI new command....
Read more >Angular 9: What's New? - Auth0
Because prior to Angular 9, the AOT compilation step only ran when we executed using the production flag ng build --prod . It...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Barrel files are the problem in my case…
index.ts = 👎
@alan-agius4 sure.
I found this promblem not only for entryComponents, but for all imports from re-export modules (like index.ts).
When I use direct import like
import {MyComponent} from "./components/my-component/my-component.ts"
- metadata.json file contains metadata required for angular compilier-cli.I try to describe the difference of created metadata.json files:
my-module.metadata.json
:But when I has import like
import {MyComponent} from "./components"
metadata.json file looks like:During AOT compilier does not receive any information of used type and throw exception above