Skip to content

Conversation

@Aditi-1400
Copy link
Contributor

@Aditi-1400Aditi-1400 commented Jun 23, 2025

Adds an option (NODE_COMPILE_CACHE_RELATIVE_PATH) for the built-in compile cache to encode the hashes with relative file paths. On enabling the option,
the source directory along with cache directory can be bundled and moved, and the cache continues to work.

When enabled, paths encoded in hash are relative to compile cache directory.

Fixes: #58755
Refs: #52696

Thanks @joyeecheung for all the help :)

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jun 23, 2025
@codecov
Copy link

codecovbot commented Jun 23, 2025

Codecov Report

❌ Patch coverage is 86.07595% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.89%. Comparing base (9bcc5a8) to head (b879f6b).
⚠️ Report is 319 commits behind head on main.

Files with missing linesPatch %Lines
src/compile_cache.cc81.48%1 Missing and 4 partials ⚠️
src/path.cc73.68%2 Missing and 3 partials ⚠️
src/env.cc87.50%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #58797 +/- ## ========================================== + Coverage 89.37% 89.89% +0.52%  ========================================== Files 654 667 +13 Lines 192554 196670 +4116 Branches 37434 38617 +1183 ========================================== + Hits 172086 176794 +4708 + Misses 12995 12331 -664 - Partials 7473 7545 +72 
Files with missing linesCoverage Δ
lib/internal/modules/helpers.js98.29% <100.00%> (+0.92%)⬆️
src/compile_cache.h100.00% <ø> (ø)
src/env.h98.14% <ø> (ø)
src/node_modules.cc77.06% <100.00%> (-0.25%)⬇️
src/env.cc80.83% <87.50%> (-0.05%)⬇️
src/compile_cache.cc80.78% <81.48%> (-0.01%)⬇️
src/path.cc72.81% <73.68%> (+3.76%)⬆️

... and 195 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@joyeecheungjoyeecheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some integration to module.enableCompileCache() as well? I think having it in options bag when the first argument is an object might work well enough. The path can be options.path in that case.

@joyeecheungjoyeecheung mentioned this pull request Jul 3, 2025
13 tasks
@mcollinamcollina added the semver-minor PRs that contain new features and should be released in the next minor version. label Jul 4, 2025
@Aditi-1400Aditi-1400force-pushed the compile-cache branch 2 times, most recently from 5abcfc9 to de78d1aCompareAugust 1, 2025 13:15
Copy link
Member

@jasnelljasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file:// URL handling in this is incorrect. Either support for file:// URLs here at all should be dropped or they should be correctly handled.

jasnell

This comment was marked as duplicate.

@Aditi-1400Aditi-1400force-pushed the compile-cache branch 4 times, most recently from ddd3bcd to d03bf27CompareAugust 11, 2025 16:30
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@joyeecheungjoyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 11, 2025
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 11, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@Aditi-1400Aditi-1400 added the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 12, 2025
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 12, 2025
@nodejs-github-botnodejs-github-bot merged commit 94422e8 into nodejs:mainSep 12, 2025
73 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 94422e8

targos pushed a commit that referenced this pull request Sep 12, 2025
Adds an option (NODE_COMPILE_CACHE_PORTABLE) for the built-in compile cache to encode the hashes with relative file paths. On enabling the option, the source directory along with cache directory can be bundled and moved, and the cache continues to work. When enabled, paths encoded in hash are relative to compile cache directory. PR-URL: #58797Fixes: #58755 Refs: #52696 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
@joyeecheungjoyeecheung added dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v25.x PRs that should not land on the v25.x-staging branch and should not be released in v25.x. labels Sep 18, 2025
* - `portable`: If `portable` is true, the cache directory will be considered relative. Defaults to false.
* If cache path is undefined, it defaults to the NODE_MODULE_CACHE environment variable.
* If `NODE_MODULE_CACHE` isn't set, it defaults to `path.join(os.tmpdir(), 'node-compile-cache')`.
* @param{string |{path?: string, portable?: boolean } | undefined} options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed an issue with the new options - it should be directory instead of path to align with the return value. Marking the PR with dont-land labels to fix it before it gets released.

nodejs-github-bot added a commit that referenced this pull request Sep 24, 2025
Notable changes: http: * (SEMVER-MINOR) add shouldUpgradeCallback to let servers control HTTP upgrades (Tim Perry) #59824 sqlite: * (SEMVER-MINOR) cleanup ERM support and export Session class (James M Snell) #58378 * (SEMVER-MINOR) add tagged template (0hm☘️) #58748 src: * (SEMVER-MINOR) add an option to make compile cache portable (Aditi) #58797 worker: * (SEMVER-MINOR) add heap profile API (theanarkh) #59846 PR-URL: #59997
@targostargos mentioned this pull request Sep 24, 2025
9 tasks
@targostargos removed dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v25.x PRs that should not land on the v25.x-staging branch and should not be released in v25.x. labels Oct 10, 2025
@targos
Copy link
Member

#59896 (comment)

Should land with #59931

aduh95 pushed a commit that referenced this pull request Oct 31, 2025
Adds an option (NODE_COMPILE_CACHE_PORTABLE) for the built-in compile cache to encode the hashes with relative file paths. On enabling the option, the source directory along with cache directory can be bundled and moved, and the cache continues to work. When enabled, paths encoded in hash are relative to compile cache directory. PR-URL: #58797Fixes: #58755 Refs: #52696 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
nodejs-github-bot added a commit that referenced this pull request Nov 7, 2025
Notable changes: http: * (SEMVER-MINOR) add optimizeEmptyRequests server option (Rafael Gonzaga) #59778 src: * (SEMVER-MINOR) add watch config namespace (Marco Ippolito) #60178 * (SEMVER-MINOR) add an option to make compile cache portable (Aditi) #58797 v8: * (SEMVER-MINOR) add cpu profile (theanarkh) #59807 PR-URL: #60615
targos pushed a commit that referenced this pull request Nov 18, 2025
Adds an option (NODE_COMPILE_CACHE_PORTABLE) for the built-in compile cache to encode the hashes with relative file paths. On enabling the option, the source directory along with cache directory can be bundled and moved, and the cache continues to work. When enabled, paths encoded in hash are relative to compile cache directory. PR-URL: #58797Fixes: #58755 Refs: #52696 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
nodejs-github-bot added a commit that referenced this pull request Dec 9, 2025
Notable changes: http: * (SEMVER-MINOR) add optimizeEmptyRequests server option (Rafael Gonzaga) #59778 lib: * (SEMVER-MINOR) add options to util.deprecate (Rafael Gonzaga) #59982 module: * (SEMVER-MINOR) mark type stripping as stable (Marco Ippolito) #60600 node-api: * (SEMVER-MINOR) add napi_create_object_with_properties (Miguel Marcondes Filho) #59953 sqlite: * (SEMVER-MINOR) allow setting defensive flag (Bart Louwers) #60217 src: * (SEMVER-MINOR) add watch config namespace (Marco Ippolito) #60178 * (SEMVER-MINOR) add an option to make compile cache portable (Aditi) #58797 src,permission: * (SEMVER-MINOR) add --allow-inspector ability (Rafael Gonzaga) #59711 v8: * (SEMVER-MINOR) add cpu profile (theanarkh) #59807 PR-URL: #61001
targos pushed a commit that referenced this pull request Dec 9, 2025
Notable changes: http: * (SEMVER-MINOR) add optimizeEmptyRequests server option (Rafael Gonzaga) #59778 lib: * (SEMVER-MINOR) add options to util.deprecate (Rafael Gonzaga) #59982 module: * (SEMVER-MINOR) mark type stripping as stable (Marco Ippolito) #60600 node-api: * (SEMVER-MINOR) add napi_create_object_with_properties (Miguel Marcondes Filho) #59953 sqlite: * (SEMVER-MINOR) allow setting defensive flag (Bart Louwers) #60217 src: * (SEMVER-MINOR) add watch config namespace (Marco Ippolito) #60178 * (SEMVER-MINOR) add an option to make compile cache portable (Aditi) #58797 src,permission: * (SEMVER-MINOR) add --allow-inspector ability (Rafael Gonzaga) #59711 v8: * (SEMVER-MINOR) add cpu profile (theanarkh) #59807 PR-URL: #61001
targos pushed a commit that referenced this pull request Dec 10, 2025
Notable changes: http: * (SEMVER-MINOR) add optimizeEmptyRequests server option (Rafael Gonzaga) #59778 lib: * (SEMVER-MINOR) add options to util.deprecate (Rafael Gonzaga) #59982 module: * (SEMVER-MINOR) mark type stripping as stable (Marco Ippolito) #60600 node-api: * (SEMVER-MINOR) add napi_create_object_with_properties (Miguel Marcondes Filho) #59953 sqlite: * (SEMVER-MINOR) allow setting defensive flag (Bart Louwers) #60217 src: * (SEMVER-MINOR) add watch config namespace (Marco Ippolito) #60178 * (SEMVER-MINOR) add an option to make compile cache portable (Aditi) #58797 src,permission: * (SEMVER-MINOR) add --allow-inspector ability (Rafael Gonzaga) #59711 v8: * (SEMVER-MINOR) add cpu profile (theanarkh) #59807 PR-URL: #61001
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.lib / srcIssues and PRs related to general changes in the lib or src directory.needs-ciPRs that need a full CI run.semver-minorPRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support relative compile cache

6 participants

@Aditi-1400@nodejs-github-bot@jasnell@joyeecheung@targos@mcollina