mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 19:08:15 +00:00
fix(npm): support non-all lowercase package names (#16669)
Supports package names that aren't all lowercase. This stores the package with a leading underscore (since that's not allowed in npm's registry and no package exists with a leading underscore) then base32 encoded (A-Z0-9) so it can be lowercased and avoid collisions. Global cache dir: ``` $DENO_DIR/npm/registry.npmjs.org/_{base32_encode(package_name).to_lowercase()}/{version} ``` node_modules dir `.deno` folder: ``` node_modules/.deno/_{base32_encode(package_name).to_lowercase()}@{version}/node_modules/<package-name> ``` Within node_modules folder: ``` node_modules/<package-name> ``` So, direct childs of the node_modules folder can have collisions between packages like `JSON` vs `json`, but this is already something npm itself doesn't handle well. Plus, Deno doesn't actually ever resolve to the `node_modules/<package-name>` folder, but just has that for compatibility. Additionally, packages in the `.deno` dir could have collissions if they have multiple dependencies that only differ in casing or a dependency that has different casing, but if someone is doing that then they're already going to have trouble with npm and they are asking for trouble in general.
This commit is contained in:
parent
1d85c25205
commit
40a72f3555
13 changed files with 153 additions and 20 deletions
1
cli/tests/testdata/npm/registry/@denotest/CAPITALS/1.0.0/index.js
vendored
Normal file
1
cli/tests/testdata/npm/registry/@denotest/CAPITALS/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = 5;
|
4
cli/tests/testdata/npm/registry/@denotest/CAPITALS/1.0.0/package.json
vendored
Normal file
4
cli/tests/testdata/npm/registry/@denotest/CAPITALS/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "@denotest/CAPITALS",
|
||||
"version": "1.0.0"
|
||||
}
|
2
cli/tests/testdata/npm/registry/@denotest/MixedCase/1.0.0/index.js
vendored
Normal file
2
cli/tests/testdata/npm/registry/@denotest/MixedCase/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
const value = require("@denotest/CAPITALS");
|
||||
module.exports = value;
|
7
cli/tests/testdata/npm/registry/@denotest/MixedCase/1.0.0/package.json
vendored
Normal file
7
cli/tests/testdata/npm/registry/@denotest/MixedCase/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "@denotest/MixedCase",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@denotest/CAPITALS": "^1"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue