-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix(misc): don't clear node_modules require cache #22907
fix(misc): don't clear node_modules require cache #22907
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit fb78c78. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 6 targets
Sent with 💌 from NxCloud. |
|
||
export function clearRequireCache() { | ||
for (const k of Object.keys(require.cache)) { | ||
if (!packageInstallationDirectories.some((dir) => k.includes(dir))) { |
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.
Please use the relative
+ startsWith
check rather than includes
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.
relative
+ startsWith
wouldn't handle npm workspaces right? e.g. apps/my-app/node_modules/jest
if the app has a different version of jest installed
da543bc
to
68520b2
Compare
68520b2
to
fb78c78
Compare
(cherry picked from commit 80b5514)
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
When loading a config file within a
createNodes
plugin, we bust the require cache to ensure we get fresh contents. This is required otherwise project configuration isn't updated as we update the tools configuration.However, removing node_modules from cache can cause some weird edge cases when any of those modules contained a Symbol, as once reloaded it will be considered a different symbol.
Expected Behavior
We don't clear node modules from require cache, to avoid causing funky behavior around Symbols.
Related Issue(s)
Fixes #