node icon indicating copy to clipboard operation
node copied to clipboard

module,win: make module cache case-insensitive

Open huseyinacacak-janea opened this issue 1 year ago • 7 comments

This PR makes the module cache object case-insensitive by utilizing Proxy in JS.

Fixes: https://github.com/nodejs/node/issues/54132

huseyinacacak-janea avatar Aug 21 '24 11:08 huseyinacacak-janea

Review requested:

  • [ ] @nodejs/loaders

nodejs-github-bot avatar Aug 21 '24 11:08 nodejs-github-bot

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:

... and 213 files with indirect coverage changes

codecov[bot] avatar Aug 21 '24 12:08 codecov[bot]

Is there anything else I can do to help this PR move forward?

huseyinacacak-janea avatar Sep 03 '24 06:09 huseyinacacak-janea

CI: https://ci.nodejs.org/job/node-test-pull-request/61842/

nodejs-github-bot avatar Sep 03 '24 07:09 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/63064/

nodejs-github-bot avatar Oct 12 '24 09:10 nodejs-github-bot

I've added the blocked label, so this is not merged accidentally if the CI passes while it is still being discussed.

StefanStojanovic avatar Oct 14 '24 11:10 StefanStojanovic

Adding it to the @nodejs/tsc agenda for visibility

mcollina avatar Oct 15 '24 20:10 mcollina

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.

mhdawson avatar Oct 23 '24 14:10 mhdawson

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?

ljharb avatar Oct 23 '24 15:10 ljharb

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.

huseyinacacak-janea avatar Nov 06 '24 13:11 huseyinacacak-janea

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: @.***>

bmeck avatar Mar 06 '25 13:03 bmeck