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
Webpacker: Use local NPM installer instead of duplicating the packages folder #8159
Conversation
Remove the duplicate packages folder from the design app and use the local installer instead.
@ahukkanen Thanks for your amazing work! 🤩 |
@leio10 Yes, I answered to your concern at #8136 (comment). This approach means no changes to the deployment scripts as far as I know, if you are already running When you run |
Hi @ahukkanen! I'm trying to deploy this to Heroku and I'm getting an error message. The staging app is working with the If I try to execute the task locally, what I get is:
If I remove the reference to the package located in UPDATE: it didn't work, it can't find the webpacker command. |
@leio10 Ah yeah, this is tricky. I think the NPM local cache has played tricks on me because it's fetching the packages from there if they don't exist at When I remove the I'll think about this if I can come up with a solution... |
@leio10 I think I have a solution for the problem above. It requires a small change in the deployment script, though, but does not require changing the So given this PR: First, revert commit Then, change the deployment script to run this command before $ npm exec -y --package github:decidim/decidim-npm-local -- decidimpack . After that, install the dependencies as normal: $ npm i |
@leio10 And at Heroku, I think you can achieve the above if you add this to the staging app's package.json: "scripts": {
"heroku-prebuild": "npm exec -y --package github:decidim/decidim-npm-local -- decidimpack ."
} See: https://devcenter.heroku.com/articles/nodejs-support#heroku-specific-build-steps |
@ahukkanen I tried your suggestion and it's almost working... but it seems that the contents of the .tgz files are not exactly the same, so I'm getting an error while checking the integrity of the file:
Would it be possible to remove the integrity check for this package somehow? |
@leio10 Do you mean you get that error at Heroku or locally? I tried running the following locally in the staging app's PR branch: $ npm run heroku-prebuild
$ npm ci It worked fine. If this happens at Heroku, I'm wondering what happens when I'm also wondering which happens first at Heroku, does it install the NPM dependencies before running |
Yes, definitely that's the problem. And it's worst, as it won't work if you install ruby before node :( |
Yes, I was about to say that as I noticed it... 😄 Well, back to the drawing table. |
@leio10 I think I have a solution which requires this change in the local installer NPM package: What that does is that if This should make the SHA hashes match to avoid integrity violations. |
I'm reviewing old PRs and found this one. @ahukkanen does it make sense to retake this issue? Personally, it'd be difficult to test this, as I don't have access to the Codegram's configured staging app, so I'd need to configure that and arrive to the same state that @leio10 got. Also, I'm afraid of touching How do you see it? |
@andreslucena Thanks for reminding. I think the current approach is fine. I don't like is that we have to copy the packages to development apps / the design app, but I guess that's just something we have to live with. The approach taken in this PR is not perfect either, we were just trying to explore different ways to bypass the issue we had. I feel that we should rely as long as possible with the defaults that NPM provides and avoid creating our own abstraction on top of it (that needs to be maintained). Let's just live with the limitations of NPM for now. Closing this. |
🎩 What? Why?
As discussed with @leio10 at #8136 (comment), we should migrate to using a local NPM package installer instead of duplicating the packages folder in every app.
This is a workaround for installing the linked package dependencies due to a bug in NPM v7 (npm/cli#2339). Until the issue is fixed at NPM, we need this workaround.
The local package installer is a separate NPM package implemented at:
https://github.com/decidim/decidim-npm-local
This tool does not have to follow the Decidim version numbering, it is designed to work on its own. It could be released already to NPM even before there is an actual Decidim release available.
The workaround works as follows:
decidim
gem installation path usingbundle show decidim
packages
folder to the application'stmp
folder which doesn't go to gitdegit
Benefits compared to the current solution:
packages
folder does not need to be duplicated to the application itself for local and git installationspackages
folder does not need to be duplicated to the design appIf the related NPM bug is fixed at some point, we can consider removing this workaround and installing the Decidim NPM dependencies directly using file paths pointing to the
decidim
gem's installation folder (when available, note that there are also installations that do not install thedecidim
main gem but only e.g.decidim-core
,decidim-admin
, etc.).📌 Related Issues
Testing
tmp/npmbuild
foldernode_modules
foldernpm i
inside the development app./bin/webpack-dev-server
npm i
causing no changes to e.g. deployment scripts📋 Checklist
docs/
.