Skip to content

Bundle does not include 3rd party lib after ng-build --prod #11409

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

Closed
lehno opened this issue Jun 29, 2018 · 9 comments
Closed

Bundle does not include 3rd party lib after ng-build --prod #11409

lehno opened this issue Jun 29, 2018 · 9 comments
Labels
area: @angular-devkit/build-angular needs: repro steps We cannot reproduce the issue with the information given
Milestone

Comments

@lehno
Copy link

lehno commented Jun 29, 2018

Bug Report or Feature Request (mark with an x)

- [X] bug report
- [ ] feature request

Versions

Angular CLI: 6.0.8
@angular/compiler-cli: 6.0.7
@types/jasmine: 2.8.8
@types/jasminewd2: 2.0.3
@types/node: 10.5.1

Angular: 6.0.7
Node: 8.10.0
OS: Windows 10

Package                           Version
-----------------------------------------------------------
@angular-devkit/build-angular     0.6.7
@angular/cli                      6.0.7
rxjs                              6.2.1
typescript                        2.7.2
webpack                           4.8.3

Repro steps

1 - Created I lib in a different workspace from the main project.
2- Published to a private npm.
3 - Installed the lib in the same workspace with a test project, npm install @org/my-lib, ng serve works and ng-build works, (it has the lib code in the bundle file)
4 - Installed the lib in my main project (that will consume the lib), its in another workspace.
5- ng serve works, ng build --prod does not include the lib code into the bundle.

Mention any other details that might be useful

The main project was upgraded from angular 5 to 6 one month ago using angular cli.
If I install the lib using the tgz file directly "my-lib": "file:../../my-project/dist/my-lib", ng-build --prod works and the code in included in the bundle.
If I install the lib using the tgz file from cloud "my-lib": "https://myserver/my-lib.0.0.1.tgz", it does not include the lib code into the bundle file
If I install the lib using "@org/my-lib":"0.0.1" , ng build --prod does'n include the lib code into the bundle

@clydin
Copy link
Member

clydin commented Jun 29, 2018

This appears to be a bug but we will need to look at a reproduction to find and fix the problem. Can you setup a minimal reproduction please?

You can read here why this is needed. A good way to make a minimal reproduction 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.

@lehno
Copy link
Author

lehno commented Jul 2, 2018

It is something with cache, I created one repro app and a repro-lib, did a few tests and it works, it updates the code normally. Is there any cache with angular-cli or webpack? I saw in some issues here about angular-cli relying on a symlink on dist folder. I have different folder names on my main project. Im not using src and dist folders. Do you think its related?

@lehno
Copy link
Author

lehno commented Jul 2, 2018

When I delete my node_modules folder and all dist folder, npm instal and ng build --prod again, it brings the last lib code to the vendor file

@lehno
Copy link
Author

lehno commented Jul 5, 2018

The only way I found to make my build to include updates on my lib is to
delete node_modules folder
npm cache clean --force
npm install
Then, if I build, it includes the last code

@lehno
Copy link
Author

lehno commented Jul 10, 2018

I posted this issue on webpack repo. No solution until now...

@alexmj212
Copy link

I'm also having the same issue and running a npm cache clean --force worked for me as well.

I had also tried making changes to my tsconfig.json by adding the 3rd party path directly to the config, this did not work. Errors showed that it was looking directly at the installed module in node_modules but that it still couldn't find it. #11835 also did not include the fix for this.

Just to clarify, I have 3 sub-packages that are getting built locally and I was using an npm link to point to them from the main project. Each sub-package had several 3rd party dependencies (angular, rxjs, etc).

After linking the other local sub-packages, I run ng test in the main package. This resulted in Module not Found errors for almost all the 3rd party dependencies because it could not resolve the sub-package 3rd party dependencies.

@ngbot ngbot bot added this to the needsTriage milestone Jan 24, 2019
@filipesilva
Copy link
Contributor

There was a point at which we had some cache for prod builds (specifically for Build Optimizer) that had some edge cases where it didn't work. We've since removed it. I think that might have been the cause of the problem on our side.

Not sure what the problem might be with the npm cache proper, if at all. But this repo wouldn't be the right place to address it.

In regards to npm link please bear in mind that there are a lot of cases where it doesn't work properly. Especially with peer dependencies, which are common in Angular projects. I don't recommend using it.

@lehno
Copy link
Author

lehno commented Feb 21, 2019

Using the latest version of everything mentioned above and it does not happen anymore.

@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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular-devkit/build-angular needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

4 participants