mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 07:44:48 -05:00
fix(byonm): correct resolution for scoped packages (#21083)
This commit is contained in:
parent
56a4c981f5
commit
7eb34c7a36
11 changed files with 83 additions and 28 deletions
|
@ -2227,17 +2227,9 @@ pub fn byonm_cjs_esm_packages() {
|
|||
.use_temp_cwd()
|
||||
.build();
|
||||
let dir = test_context.temp_dir();
|
||||
let run_npm = |args: &str| {
|
||||
test_context
|
||||
.new_command()
|
||||
.name("npm")
|
||||
.args(args)
|
||||
.run()
|
||||
.skip_output_check();
|
||||
};
|
||||
|
||||
run_npm("init -y");
|
||||
run_npm("install @denotest/esm-basic @denotest/cjs-default-export @denotest/dual-cjs-esm chalk@4 chai@4.3");
|
||||
test_context.run_npm("init -y");
|
||||
test_context.run_npm("install @denotest/esm-basic @denotest/cjs-default-export @denotest/dual-cjs-esm chalk@4 chai@4.3");
|
||||
|
||||
dir.write(
|
||||
"main.ts",
|
||||
|
@ -2346,12 +2338,7 @@ pub fn byonm_package_specifier_not_installed_and_invalid_subpath() {
|
|||
"import '@denotest/conditional-exports-strict/test';",
|
||||
);
|
||||
|
||||
test_context
|
||||
.new_command()
|
||||
.name("npm")
|
||||
.args("install")
|
||||
.run()
|
||||
.skip_output_check();
|
||||
test_context.run_npm("install");
|
||||
|
||||
let output = test_context.new_command().args("run main.ts").run();
|
||||
output.assert_matches_text(
|
||||
|
@ -2395,12 +2382,7 @@ pub fn byonm_package_npm_specifier_not_installed_and_invalid_subpath() {
|
|||
"import 'npm:@denotest/conditional-exports-strict/test';",
|
||||
);
|
||||
|
||||
test_context
|
||||
.new_command()
|
||||
.name("npm")
|
||||
.args("install")
|
||||
.run()
|
||||
.skip_output_check();
|
||||
test_context.run_npm("install");
|
||||
|
||||
let output = test_context.new_command().args("run main.ts").run();
|
||||
output.assert_matches_text(
|
||||
|
@ -2487,12 +2469,7 @@ console.log(add(1, 2));
|
|||
"#,
|
||||
);
|
||||
|
||||
test_context
|
||||
.new_command()
|
||||
.name("npm")
|
||||
.args("install")
|
||||
.run()
|
||||
.skip_output_check();
|
||||
test_context.run_npm("install");
|
||||
|
||||
let output = test_context
|
||||
.new_command()
|
||||
|
@ -2530,3 +2507,37 @@ itest!(imports_package_json_sub_path_import_not_defined {
|
|||
exit_code: 1,
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(different_nested_dep_node_modules_dir_false {
|
||||
args: "run --quiet --node-modules-dir=false npm/different_nested_dep/main.js",
|
||||
output: "npm/different_nested_dep/main.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
exit_code: 0,
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(different_nested_dep_node_modules_dir_true {
|
||||
args: "run --quiet --node-modules-dir=true main.js",
|
||||
output: "npm/different_nested_dep/main.out",
|
||||
copy_temp_dir: Some("npm/different_nested_dep/"),
|
||||
cwd: Some("npm/different_nested_dep/"),
|
||||
envs: env_vars_for_npm_tests(),
|
||||
exit_code: 0,
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
#[test]
|
||||
pub fn different_nested_dep_byonm() {
|
||||
let test_context = TestContextBuilder::for_npm()
|
||||
.use_copy_temp_dir("npm/different_nested_dep")
|
||||
.cwd("npm/different_nested_dep/")
|
||||
.build();
|
||||
|
||||
test_context.run_npm("install");
|
||||
|
||||
let output = test_context
|
||||
.new_command()
|
||||
.args("run --unstable-byonm main.js")
|
||||
.run();
|
||||
output.assert_matches_file("npm/different_nested_dep/main.out");
|
||||
}
|
||||
|
|
5
cli/tests/testdata/npm/different_nested_dep/main.js
vendored
Normal file
5
cli/tests/testdata/npm/different_nested_dep/main.js
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import dep from "@denotest/different-nested-dep";
|
||||
import childDep from "@denotest/different-nested-dep-child";
|
||||
|
||||
console.log(dep);
|
||||
console.log(childDep);
|
2
cli/tests/testdata/npm/different_nested_dep/main.out
vendored
Normal file
2
cli/tests/testdata/npm/different_nested_dep/main.out
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
1
|
||||
2
|
6
cli/tests/testdata/npm/different_nested_dep/package.json
vendored
Normal file
6
cli/tests/testdata/npm/different_nested_dep/package.json
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@denotest/different-nested-dep": "1.0.0",
|
||||
"@denotest/different-nested-dep-child": "2.0.0"
|
||||
}
|
||||
}
|
1
cli/tests/testdata/npm/registry/@denotest/different-nested-dep-child/1.0.0/index.js
vendored
Normal file
1
cli/tests/testdata/npm/registry/@denotest/different-nested-dep-child/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export default 1;
|
5
cli/tests/testdata/npm/registry/@denotest/different-nested-dep-child/1.0.0/package.json
vendored
Normal file
5
cli/tests/testdata/npm/registry/@denotest/different-nested-dep-child/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "@denotest/different-nested-dep-child",
|
||||
"type": "module",
|
||||
"version": "1.0.0"
|
||||
}
|
1
cli/tests/testdata/npm/registry/@denotest/different-nested-dep-child/2.0.0/index.js
vendored
Normal file
1
cli/tests/testdata/npm/registry/@denotest/different-nested-dep-child/2.0.0/index.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export default 2;
|
5
cli/tests/testdata/npm/registry/@denotest/different-nested-dep-child/2.0.0/package.json
vendored
Normal file
5
cli/tests/testdata/npm/registry/@denotest/different-nested-dep-child/2.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "@denotest/different-nested-dep-child",
|
||||
"type": "module",
|
||||
"version": "2.0.0"
|
||||
}
|
2
cli/tests/testdata/npm/registry/@denotest/different-nested-dep/1.0.0/index.js
vendored
Normal file
2
cli/tests/testdata/npm/registry/@denotest/different-nested-dep/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
import version from "@denotest/different-nested-dep-child";
|
||||
export default version;
|
8
cli/tests/testdata/npm/registry/@denotest/different-nested-dep/1.0.0/package.json
vendored
Normal file
8
cli/tests/testdata/npm/registry/@denotest/different-nested-dep/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@denotest/different-nested-dep",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@denotest/different-nested-dep-child": "1.0.0"
|
||||
}
|
||||
}
|
|
@ -212,6 +212,15 @@ impl TestContext {
|
|||
builder.deno_exe(&self.deno_exe).set_test_context(self);
|
||||
builder
|
||||
}
|
||||
|
||||
pub fn run_npm(&self, args: impl AsRef<str>) {
|
||||
self
|
||||
.new_command()
|
||||
.name("npm")
|
||||
.args(args)
|
||||
.run()
|
||||
.skip_output_check();
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TestCommandBuilder {
|
||||
|
|
Loading…
Reference in a new issue