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

@ngtools/webpack AOT loader failed to resolve nested exports (Barrels) #8581

Closed
Sky4CE opened this issue Nov 21, 2017 · 5 comments · Fixed by #12567
Closed

@ngtools/webpack AOT loader failed to resolve nested exports (Barrels) #8581

Sky4CE opened this issue Nov 21, 2017 · 5 comments · Fixed by #12567

Comments

@Sky4CE
Copy link

Sky4CE commented Nov 21, 2017

I'm submitting a...


[x] Bug report  
[ ] Feature request

Versions

<!--
Output from: `ng --version`.
If nothing, output from: `node --version` and `npm --version`.
  Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)
-->
@ngtools/webpack: 1.8.3
node: 6.11.1
npm: 5.5.1
os: win10 x64
angular: 5.0.2
typescript: 2.5.3

Repro steps

Use barrels system in project based on index.ts, that every feature folder consists of index.ts where you can re-export components, so instead of:
import { AuthService } from '@app/core/services/auth.service';
You can do:
import * as Core from '@app/core';
and use any entity inside Core like this:
Core.Services.AuthService

Reproduction:

Observed behavior

JIT compiles like a charm without any problems, but when I try to compile using AOT with help of @ngtools/webpack mentioned behavior not work. AOT plugin cannot see any further than second property, for example when I inject service into constructor like this:
constructor(private router: Router, private authService: Core.Services.AuthService)
I get next error:
ERROR in Error: Can't resolve all parameters for AppLaunchComponent in /Client/app/app.launch.ts: ([object Object], ?).
so second parameter does not recognized, but when I import CoreServices directly and use like this:
constructor(private router: Router, private authService: CoreServices.AuthService)
it could recognize all parameters.
But I really like to import one-line just Core and nothing more, because we have 1000+ components in our app, so import each separately is absolutely not an option.

Desired behavior

Do not drop(tree-shake) nested exports while parsing import sequence!

Is it possible to see this bug fixed ?

@filipesilva
Copy link
Contributor

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

@filipesilva filipesilva self-assigned this Nov 23, 2017
@filipesilva filipesilva added the needs: repro steps We cannot reproduce the issue with the information given label Nov 23, 2017
@Sky4CE
Copy link
Author

Sky4CE commented Nov 29, 2017

@filipesilva , I've prepared reproduction repo for you. It can be build with jit or aot. Jit build works, but aot throws an error at compile stage, you can play with it, I've left commented lines which will work with aot, but with 1 level deep nesting:
image
image
image
to run with aot: npm run aot
to run with jit: npm run jit
access site at localhost:3000

@Sky4CE
Copy link
Author

Sky4CE commented Dec 1, 2017

@filipesilva , I've created another repo which is based on pure angular-cli (ng new) plus applied barrels. In this case not working neither JIT nor AOT. So I assume this is angular cli bug.

@Sky4CE
Copy link
Author

Sky4CE commented Dec 6, 2017

@filipesilva any progress on this ?

@filipesilva filipesilva added command: build P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix and removed needs: repro steps We cannot reproduce the issue with the information given labels Dec 7, 2017
@filipesilva filipesilva added freq2: medium severity2: inconvenient and removed P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful labels Feb 1, 2018
@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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants