Skip to content

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

Closed

Description

@Sky4CE

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 ?

Activity

  1. filipesilva commented on Nov 23, 2017

    @filipesilva
    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.

  2. self-assigned this
    on Nov 23, 2017
  3. Sky4CE commented on Nov 29, 2017

    @Sky4CE
    Author

    @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

  4. Sky4CE commented on Dec 1, 2017

    @Sky4CE
    Author

    @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.

  5. Sky4CE commented on Dec 6, 2017

    @Sky4CE
    Author

    @filipesilva any progress on this ?

  6. added
    P1Impacts a large percentage of users; if a workaround exists it is partial or overly painful
    and removed
    needs: repro stepsWe cannot reproduce the issue with the information given
    on Dec 7, 2017
  7. added and removed
    P1Impacts a large percentage of users; if a workaround exists it is partial or overly painful
    on Feb 1, 2018
  8. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  9. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions