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
Rollup is embedding all dependencies in lib after upgrade to v16 #17660
Comments
This seems to be a general issue; see #10227 |
@JosefBredereck thanks for linking them up. For the most part, it was just an inconvenience thing, but I'm starting to have some real issues with this. We have a lib where we customise Axios in order to do common things like append some custom headers and add some global error handling within the interceptors, etc... With apps that are within the repo, no dramas. But we started to have some issues with apps that are not part of the repo and upon investigation, the culprit seems to be related to the fact that with rollup, it's embedding the axios in it and it seems to be conflicting with axios version from the app itself. As a test, I created the lib using vite bundler and compared the output with the rollup. If push comes to shove, I'll migrate everything to vite, but that will be quite the hassle and I'm trying to avoid doing that...
|
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
Before upgrading from v15.x to latest (16.3.2) the libs assets would not embed any dependencies into the lib itself. The result was a smaller lib package. After the migration, each lib is now embedding all its dependencies, including node_modules dependencies into the lib
index.js
When importing into apps external to the monorepo, it breaks with multiple issues. Mostly because we do have some legacy apps that are not fully upgraded to latest version of react and other dependencies. Up to this point it was all working fine.
Expected Behavior
The compilation/bundling should've remained the same.
GitHub Repo
https://github.com/minuz/rollup-issue
Steps to Reproduce
nx run-many --target=build --all
Nx Report
Failure Logs
No response
Operating System
Additional Information
Upon some digging, I managed to get the expected results by manually adding the dependent libraries into the lib
package.json
. However, this is not a sustainable solution as it requires to manually add dependencies to each library and we have plenty! More importantly, it relies on manual intervention and diligence from each developer to ensure the dependencies are correctly set onpackage.json
. We have been relying on Rollup to automatically set the dependencies and peer dependencies during compilation time.I'm hoping there's some configuration that I missed that would allow that to still happen without having to manually add dependencies into each lib.
On the repo above, I created two libs.
They are essentially the same code (and what it does is really not important). They use axios to fetch data on load.
The compiled library will have the
is-even
with axios code embedded in it and theis-odd
will only have the code from the lib itself, which is what I'd expect.The setup difference is in the
package.json
where onis-odd
I manually add axios as dependency.On nx 15, I used to be able to let rollup deal with that by itself so I wouldn't need to manually declare anything on the
package.json
Any insights are greatly appreciated.
The text was updated successfully, but these errors were encountered: