AOT: Unexpected value 'undefined' exported by the module when using barrel index.ts
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
I’m trying to migrate an existing library to the new Angular-cli library support
This library has a lot of barrels index.ts
files
I’m experiencing error on build with AOT enabled
How To Reproduce
https://github.com/kepennar/ng-cli-lib-issue-repro
Given a library managed by the new angular-cli v6 library management system.
Given a component Comp1Component
of this lib imported from a barrel index.ts
in a module LibModule
projects/lib1/src/lib/components/index.ts
export * from './comp1.component';
projects/lib1/src/lib/lib.module.ts
import { Comp1Component } from './components';
// ...
@NgModule({
declarations: [Comp1Component],
exports: [Comp1Component]
})
export class LibModule {}
When an application using this lib is launched in prod
mode
Then build crash with the error
ERROR in : Unexpected value 'undefined' exported by the module 'Lib1Module ...
If the component is directly imported from it’s own file. It’s work
projects/lib1/src/lib/lib.module.ts
import { Comp1Component } from './components/comp1.component';
@NgModule({
declarations: [Comp1Component],
exports: [Comp1Component]
})
export class LibModule {}
Reproduction steps
From the repo https://github.com/kepennar/ng-cli-lib-issue-repro
npm run build:lib
npm run start:prod
Expected Behaviour
I would like ng-packagr to support correctly barrels files
Version Information
Output from: ng --version
.
Angular CLI: 6.0.7
Node: 10.3.0
OS: linux x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.6.7
@angular-devkit/build-angular 0.6.7
@angular-devkit/build-ng-packagr 0.6.7
@angular-devkit/build-optimizer 0.6.7
@angular-devkit/core 0.6.7
@angular-devkit/schematics 0.6.7
@angular/cli 6.0.7
@ngtools/json-schema 1.1.0
@ngtools/webpack 6.0.7
@schematics/angular 0.6.7
@schematics/update 0.6.7
ng-packagr 3.0.0
rxjs 6.2.0
typescript 2.7.2
webpack 4.8.3
Issue Analytics
- State:
- Created 5 years ago
- Reactions:34
- Comments:31 (7 by maintainers)
Top GitHub Comments
When I change import to
I have this error during lib build:
@blemaire @deepthan Yes, we know. It literally says that direct imports work in the original ticket description:
The bug is that barrel imports (index.ts) don’t work, but they should.