Skip to content

Default barrel exports are ignored when index is ommited #7394

Closed
@IsNull

Description

@IsNull

Bug Report

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.3.0-rc.5
node: 7.9.0
os: darwin x64
@angular/animations: 4.3.4
@angular/cdk: 2.0.0-beta.8
@angular/common: 4.3.4
@angular/compiler: 4.3.4
@angular/core: 4.3.4
@angular/flex-layout: 2.0.0-beta.8
@angular/forms: 4.3.4
@angular/http: 4.3.4
@angular/material: 2.0.0-beta.8
@angular/platform-browser: 4.3.4
@angular/platform-browser-dynamic: 4.3.4
@angular/platform-server: 4.3.4
@angular/router: 4.3.4
@angular/cli: 1.3.0-rc.5
@angular/compiler-cli: 4.3.4

Repro steps.

If you export a (barrel) from the default index.ts it is generally valid to omit the index and only reference the folder like so:
export * from 'components/feature' (does not work and fails silently)

However, ng seems to ignore the index.ts inside. As a workaround it is possible to specify the file name explicitly (as you would for any other file than index.ts):
export * from 'components/feature/index' (works)

The log given by the failure.

The failure is silent and only obvious after you check the generated metadata.json after compilation in the dist folder. It will basically just ignore all the metadata of exported classes and thus AOT compilation will break for projects consuming the library.

Desired functionality.

ng should support export * from 'components/feature' and implicitly use the index.ts inside.
If that is not desired, then at least throw an error at compile time. This wasted about a week of our time so it would be great to save others from the same fate. 🥇

Mention any other details that might be useful.

Origin: #7384

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions