node
node copied to clipboard
module,win: make module cache case-insensitive
This PR makes the module cache object case-insensitive by utilizing Proxy in JS.
Fixes: https://github.com/nodejs/node/issues/54132
Review requested:
- [ ] @nodejs/loaders
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 88.06%. Comparing base (
2c14615) to head (f038f19). Report is 614 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #54478 +/- ##
==========================================
+ Coverage 87.08% 88.06% +0.98%
==========================================
Files 648 652 +4
Lines 182341 183578 +1237
Branches 34982 35866 +884
==========================================
+ Hits 158783 161671 +2888
+ Misses 16831 15155 -1676
- Partials 6727 6752 +25
| Files with missing lines | Coverage Δ | |
|---|---|---|
| lib/internal/modules/cjs/loader.js | 96.14% <100.00%> (+3.21%) |
:arrow_up: |
Is there anything else I can do to help this PR move forward?
CI: https://ci.nodejs.org/job/node-test-pull-request/61842/
CI: https://ci.nodejs.org/job/node-test-pull-request/63064/
I've added the blocked label, so this is not merged accidentally if the CI passes while it is still being discussed.
Adding it to the @nodejs/tsc agenda for visibility
Discussed in todays TSC meeting, consensus on those present (it was a smaller number 7) was that it does need more work to make the treatment of case more consistent across the different aspects as mentioned by @joyeecheung (ESM, invoking resultion functions, or looking at result of filename) and how windows treats case insensitivity before it should land.
I’m a bit confused - there exist non-lowercase npm package names, for example https://www.npmjs.com/package/jsonstream and https://www.npmjs.com/package/JSONStream. Both of these need to be independently requireable and importable. Does this PR only apply to relative paths?
I’m a bit confused - there exist non-lowercase npm package names, for example https://www.npmjs.com/package/jsonstream and https://www.npmjs.com/package/JSONStream. Both of these need to be independently requireable and importable. Does this PR only apply to relative paths?
When you install a module in a project, a folder with the same name as the module is created in node_modules. I guess it should not be possible to install these two modules at the same time in a project.
Windows after 2018 does support case sensitive directories so this needs to state and see what context it is in and not use pure case-insensitivity even if that is the default per things like https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity using those flags having 2 case sensitive npm modules is allowed under windows.
On Thu, Mar 6, 2025 at 1:44 AM navegador5 @.***> wrote:
@.**** commented on this pull request.
In lib/internal/modules/cjs/loader.js https://github.com/nodejs/node/pull/54478#discussion_r1982844820:
@@ -321,35 +324,24 @@ let patched = false; /* Make Module._cache case-insensitive on Windows / if (isWindows) { / Create a proxy handler to intercept some operations */
- const toLowerCaseIfString = (prop) => (typeof prop === 'string' ? StringPrototypeToLowerCase(prop) : prop);
i think (maybe) just add some code to check the file-system-type AND fsutil file setCaseSensitiveInfo enable/disable is ok.
— Reply to this email directly, view it on GitHub https://github.com/nodejs/node/pull/54478#discussion_r1982844820, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABZJI5MYR4TH63QN5HHJCL2S74FRAVCNFSM6AAAAABM3ZS2F6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMNRTGU4TCNBVG4 . You are receiving this because you are on a team that was mentioned.Message ID: @.***>