-
Notifications
You must be signed in to change notification settings - Fork 392
Add script to check whether npm i
needs to be run
#3154
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a script to automatically check if npm install
needs to be run before building the project. The change aims to ensure dependencies are up-to-date by detecting when node_modules
is missing or when package-lock.json
is newer than the installed dependencies.
- Adds a bash script that checks if npm install is needed and runs it automatically
- Integrates the check into the build command to ensure dependencies are current before building
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
scripts/check-node-modules.sh | New script that checks if node_modules exists and if package-lock.json is newer than installed dependencies |
package.json | Updates the build command to run the dependency check script before transpiling |
and add it to the `build` command
7b64b31
to
455038c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprisingly simple optimization. But it is a semantically large one.
- Why
npm install
instead ofnpm ci
? (my biggest issue here) - Is it expected by the users that
build
now installs dependencies? It probably is, there's certainly precedence for doing it, but the change itself is semantically huge. Given the number of active contributors, we are good though I think.
I think we need to print something in the shell script. Otherwise, a stale node_module is going to cause some npm run build
mystery for a developer some day.
check-node-modules.sh: node_modules appears to be up to date
check-node-modules.sh: node_modules appears to be outdated, doing
npm install
This primarily addresses an issue with local development, where one of us forgets to run In CI, we already run
CI will always fail on a PR if you bundled the JS files with outdated dependencies. So practically speaking, you never want to not run In other words: if you run
Perhaps -- I had considered it and there's certainly no harm in adding extra messages, but the output from |
Thanks for elaborating. I'm still a bit iffy on the fact that a forgotten
Its the other way around I worry about. The timestamp check is just one (very good) indicator for outdated dependencies, combined with the silence when that indicator falsely holds, we can end up in a mystery situation. Consider this scenario:
I think the |
I am not convinced that this is really a problem, because actually building the bundle would then fail because of the missing dependency. For example, running
I would assume that this would prompt any of us to run The thinking behind the addition in this PR is not to simplify the development workflow, but to protect us from forgetting to run Nonetheless, I have opened #3155 which adds log messages + skips the script when it detects that it is running in an Actions workflow. |
And add it to the
build
commandRisk assessment
For internal use only. Please select the risk level of this change:
Merge / deployment checklist