mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
fix(npm): improved optional dependency support (#19135)
Note: If the package information has already been cached, then this requires running with `--reload` or for the registry information to be fetched some other way (ex. the cache busting). Closes #15544 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
ad22336245
commit
41f618a1df
25 changed files with 300 additions and 61 deletions
1
cli/tests/testdata/npm/binary_package/main.js
vendored
Normal file
1
cli/tests/testdata/npm/binary_package/main.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
import "npm:@denotest/binary-package";
|
1
cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/index.js
vendored
Normal file
1
cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
console.log("Hello from binary package on linux");
|
8
cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/package.json
vendored
Normal file
8
cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@denotest/binary-package-linux",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
}
|
1
cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/index.js
vendored
Normal file
1
cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
console.log("Hello from binary package on mac");
|
8
cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/package.json
vendored
Normal file
8
cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@denotest/binary-package-linux",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
}
|
1
cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/index.js
vendored
Normal file
1
cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
console.log("Hello from binary package on windows");
|
8
cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/package.json
vendored
Normal file
8
cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@denotest/binary-package-windows",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
}
|
13
cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/index.js
vendored
Normal file
13
cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
const packageByOs = {
|
||||
"darwin": "@denotest/binary-package-mac",
|
||||
"linux": "@denotest/binary-package-linux",
|
||||
"win32": "@denotest/binary-package-windows",
|
||||
}
|
||||
|
||||
const selectedPackage = packageByOs[process.platform];
|
||||
|
||||
if (!selectedPackage) {
|
||||
throw new Error("trying to run on unsupported platform");
|
||||
}
|
||||
|
||||
require(selectedPackage);
|
10
cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/package.json
vendored
Normal file
10
cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "@denotest/binary-package",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"optionalDependencies": {
|
||||
"@denotest/binary-package-linux": "1.0.0",
|
||||
"@denotest/binary-package-mac": "1.0.0",
|
||||
"@denotest/binary-package-windows": "1.0.0"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue