Angular-cli: Angular 6 lazyloaded modules - chunks not generated when build in symlinked path

Created on 25 Jul 2018  路  19Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

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

Command (mark with an x)

- [ ] new
- [x ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

$ npm -v
6.2.0

$ ng -v

Angular CLI: 6.0.8
Node: 10.4.1
OS: win32 x64
Angular: 6.0.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.6.8
@angular-devkit/build-angular 0.6.8
@angular-devkit/build-optimizer 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@angular/cdk 6.3.1
@angular/cli 6.0.8
@angular/material 6.3.1
@ngtools/webpack 6.0.8
@schematics/angular 0.6.8
@schematics/update 0.6.8
rxjs 6.2.1
typescript 2.7.2
webpack 4.8.3

Repro steps

Have an angular 6 app with lazy loaded modules. It build fine in both dev and prod configuration at its normal path. When we build it with a symlinked path pointing to the app directory it fails with this error, and the module chunks are missing (i.e 0.js, ..., x.js):

Date: 2018-07-25T13:19:28.110Z
Hash: 30a42f47a6b01e52d17b
Time: 24573ms
chunk {0} runtime.js (runtime) 1.07 kB [entry] [rendered]
chunk {1} vendor.js (vendor) 404 kB [initial] [rendered]
chunk {2} styles.css (styles) 106 kB [initial] [rendered]
chunk {3} polyfills.js (polyfills) 147 kB [initial] [rendered]
chunk {4} main.js (main) 9.83 kB [initial] [rendered]

WARNING in ../node_modules/@angular/core/fesm5/core.js
4863:15-36 Critical dependency: the request of a dependency is an expression

WARNING in ../node_modules/@angular/core/fesm5/core.js
4875:15-102 Critical dependency: the request of a dependency is an expression

It makes no difference if we use the --preserve-symlinks commandline option (which worked in V5) nor "preserveSymlinks": true in architect.build.options

The log given by the failure

Date: 2018-07-25T13:19:28.110Z
Hash: 30a42f47a6b01e52d17b
Time: 24573ms
chunk {0} runtime.js (runtime) 1.07 kB [entry] [rendered]
chunk {1} vendor.js (vendor) 404 kB [initial] [rendered]
chunk {2} styles.css (styles) 106 kB [initial] [rendered]
chunk {3} polyfills.js (polyfills) 147 kB [initial] [rendered]
chunk {4} main.js (main) 9.83 kB [initial] [rendered]

WARNING in ../node_modules/@angular/core/fesm5/core.js
4863:15-36 Critical dependency: the request of a dependency is an expression

WARNING in ../node_modules/@angular/core/fesm5/core.js
4875:15-102 Critical dependency: the request of a dependency is an expression

Desired functionality

Make build work under symlinks in Angular V6.

Mention any other details that might be useful

devkibuild-angular low broken bufix

Most helpful comment

I'm experiencing this issue in v7 as well.

Pushed a simple demo code repo here with all the latest and greatest Angular, as well as steps to reproduce the issue, in case it's of use to anyone.

I made some changes (based on provided demo) and it works for me at this repo, can you check this out?

All 19 comments

Any ideas for a temporary workaround would be great. We can't change our build server setup easily. And downgrading to v5 is also a greater undertaking.

We think it might be the webpack configuration that is wrong. But since the eject feature is disabled we can't test that theory.

Ok. So we ended up with a downgrade 馃槱

Same issue here, node_modules symlinked and same error occurs.

I did a workaround for my case with symlinked node_modules from my cache. Instead of symlink i move node_modules from cache to project and back, it is not nice overall but it is working. I decided to go this way because I do not want to be locked to specific versions of my dependencies.

Also don't you think this is more like severity5: regression ?

Is this fixed in v7?

I'm experiencing this issue in v7 as well.

Pushed a simple demo code repo here with all the latest and greatest Angular, as well as steps to reproduce the issue, in case it's of use to anyone.

I'm experiencing this issue in v7 as well.

Pushed a simple demo code repo here with all the latest and greatest Angular, as well as steps to reproduce the issue, in case it's of use to anyone.

That makes me a saaad panda. No upgrade path for us then. Stuck at v5!

Any status on this? Its a serious problem for us that we are getting left behind on v5, when this isn't fixed.

@filipesilva, @clydin, @alan-agius4 do you have any idea what might have caused the regression?

Hello, yesterday i tried preserveSymlinks option as stated there https://www.typescriptlang.org/docs/handbook/compiler-options.html
and for my case it works. My case was with symlinked node_modules. Anyway i also did upgrade my project to ng7, devkit to 0.11.x, typescript to 3.1.6 and so im not sure if some of that played a role.

@nnit-TroelsJensen are you using latest versions as well?

I'm experiencing this issue in v7 as well.

Pushed a simple demo code repo here with all the latest and greatest Angular, as well as steps to reproduce the issue, in case it's of use to anyone.

I made some changes (based on provided demo) and it works for me at this repo, can you check this out?

@mgechev No sadly not. We were stuck at v5 because of this issue, but if it works in v7 then we have an upgrade path. Just a bit more involved upgrade, as we are bumping two major versions.
We wil have to try it :smile:

Based on the comment from @daimoonis, this seems fixed in the latest major. Closing this as fixed. If you still experience this issue please file a separate issue so we can track it (you can point to this one).

Not sure why my use case is different, but when I have symlinked directories in my src folder and my node_modules folder is also symlinked, I am still having this issue on the latest 7x build of Angular CLI (@angular/[email protected]). When the node_modules directory is a local folder, it will correctly pick up the lazy modules, but it will ignore any lazy modules when node_modules is a symlink to another directory. My work-around at the moment will have to be to use hard-links for the node_modules directory instead of symlinks

Well its the same for us i think. We are symlinking at the root level so both src and node_modules are symlinked and that fails it for us too. Based on @daimoonis answer we went ahead and upgraded, but i failed again as it had from v5 -> v6. So still an issue here too.

@nnit-TroelsJensen We were facing exactly the issue you are describing and as a workaround, you can temporarily change the working directory of a build script to a symlink target, run npm and then change the directory back.

Depending on your build environment, there are various ways to get symlink target - since we have a powershell pipeline, we ended up using this: https://social.technet.microsoft.com/Forums/en-US/851584ae-35ce-47d5-926b-e4da9f98e112/get-symlink-folder-details?forum=winserverpowershell

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

Was this page helpful?
0 / 5 - 0 ratings