Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default barrel exports are ignored when index is ommited #7394

Closed
IsNull opened this issue Aug 15, 2017 · 4 comments
Closed

Default barrel exports are ignored when index is ommited #7394

IsNull opened this issue Aug 15, 2017 · 4 comments
Assignees
Labels
needs: more info Reporter must clarify the issue

Comments

@IsNull
Copy link

IsNull commented Aug 15, 2017

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

@filipesilva
Copy link
Contributor

What you're describing does sound like a bug, but I don't quite get the failure you describe.

We neither support creating libraries in Angular CLI nor do we output metadata.json to dist/. Are you sure you're using Angular CLI?

@filipesilva filipesilva added the needs: more info Reporter must clarify the issue label Aug 24, 2017
@filipesilva filipesilva self-assigned this Aug 24, 2017
@IsNull
Copy link
Author

IsNull commented Aug 25, 2017

@filipesilva You are right, Angular CLI does not support libraries out of the box, nevertheless it is used in the process. https://github.com/jvandemo/generator-angular2-library

The interesting involved build steps are

  • inline-resources
  • ngc
  • rollup:fesm
  • rollup:umd

I was under the impression that ngc is responsible for creating the metadata.json as it is an Angular specific thing. And since rollup comes into play later down the road, I was assuming ngc is the issue.

@filipesilva
Copy link
Contributor

Angular CLI and ngc are not the same thing though, they are quite different. The package for ngc is @angular/compiler-cli, and the repository where you can submit issues for that package is https://github.com/angular/angular.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests

2 participants