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

ng build should not require @angular/* modules that are not used #5967

Closed
jrood opened this issue Apr 14, 2017 · 6 comments · Fixed by #6980
Closed

ng build should not require @angular/* modules that are not used #5967

jrood opened this issue Apr 14, 2017 · 6 comments · Fixed by #6980
Assignees
Labels
effort2: medium (days) freq1: low Only reported by a handful of users who observe it rarely P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity2: inconvenient

Comments

@jrood
Copy link

jrood commented Apr 14, 2017

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.0.0
node: 6.9.5
os: darwin x64
@angular/common: 4.0.2
@angular/compiler: 4.0.2
@angular/core: 4.0.2
@angular/forms: 4.0.2
@angular/http: 4.0.2
@angular/platform-browser: 4.0.2
@angular/platform-browser-dynamic: 4.0.2
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.2

Repro steps.

ng new test-app
cd test-app
npm r --save @angular/router
ng build
It should return ERROR in Could not resolve module @angular/router
It should not be trying to resolve @angular/router if it is not being used.

Desired functionality.

When an application is not using the @angular/router, the ng cli should not attempt to resolve it.
Angular already aspires to be granular. It seems the purpose of splitting things up into /core /forms /http /router and so on is to let developers only include the parts they need. If the ng cli requires all these packages, even when they are not used, it seems that this purpose is thwarted.

@michaellev
Copy link

I reproduced this behaviour with same versions, and got same error message.
This is a real issue.
#goodnessSquad

@yuriykuzin
Copy link

👍

@filipesilva
Copy link
Contributor

I tested myself and can verify it as well.

kamik@T460p MINGW64 /d/sandbox/master-project (master)
$ rm -rf ./node_modules/\@angular/router

kamik@T460p MINGW64 /d/sandbox/master-project (master)
$ ng build
Hash: 5f9283f0affda25610c6
Time: 9102ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 166 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 52.8 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 65.2 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.09 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in Could not resolve module @angular/router

I think this is related to how lazy route detection tries to find router tokens but there is no direct dependency on it.

Perhaps @ngtools/webpack should have a peer dependency on the router.

/cc @hansl

@filipesilva filipesilva added effort2: medium (days) freq1: low Only reported by a handful of users who observe it rarely P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity2: inconvenient labels May 5, 2017
@HollyPony
Copy link

I can reproduce in 4.2.4 with 1.1.3 cli.

Dependency seems to come from [angular-cli, blueprints, compiler-cli]

hansl added a commit to hansl/angular-cli that referenced this issue Jul 14, 2017
Fixes angular#5967

If the router isnt in node_modules then there's no reason to fail, just pretend there are no lazy routes.
@hansl
Copy link
Contributor

hansl commented Jul 14, 2017

The webpack plugin uses @angular/compiler-cli to get the list of lazy routes, which are used as code splitting points in the build. The Compiler CLI uses @angular/router to get the symbol that it looks for. This new PR will say there's no lazy routes if that error shows up.

hansl added a commit that referenced this issue Jul 14, 2017
Fixes #5967

If the router isnt in node_modules then there's no reason to fail, just pretend there are no lazy routes.
Brocco pushed a commit to Brocco/angular-cli that referenced this issue Jul 20, 2017
Fixes angular#5967

If the router isnt in node_modules then there's no reason to fail, just pretend there are no lazy routes.
dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
Fixes angular#5967

If the router isnt in node_modules then there's no reason to fail, just pretend there are no lazy routes.
@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
effort2: medium (days) freq1: low Only reported by a handful of users who observe it rarely P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity2: inconvenient
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants