mirror of
https://github.com/denoland/deno.git
synced 2024-12-26 09:10:40 -05:00
feat: support subpaths in npm package references (#15578)
This commit is contained in:
parent
a4cc09447e
commit
684aabbc25
14 changed files with 26 additions and 1 deletions
|
@ -204,7 +204,11 @@ pub fn node_resolve_npm_reference(
|
|||
.resolve_package_from_deno_module(&reference.req)?
|
||||
.folder_path;
|
||||
let maybe_url = package_config_resolve(
|
||||
reference.sub_path.as_deref().unwrap_or("."),
|
||||
&reference
|
||||
.sub_path
|
||||
.as_ref()
|
||||
.map(|s| format!("./{}", s))
|
||||
.unwrap_or_else(|| ".".to_string()),
|
||||
&package_folder,
|
||||
npm_resolver,
|
||||
)
|
||||
|
|
|
@ -68,6 +68,13 @@ itest!(import_map {
|
|||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(sub_paths {
|
||||
args: "run --unstable -A --quiet npm/sub_paths/main.jsx",
|
||||
output: "npm/sub_paths/main.out",
|
||||
envs: env_vars(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
#[test]
|
||||
fn parallel_downloading() {
|
||||
let (out, _err) = util::run_and_collect_output_with_args(
|
||||
|
|
BIN
cli/tests/testdata/npm/registry/js-tokens/js-tokens-4.0.0.tgz
vendored
Normal file
BIN
cli/tests/testdata/npm/registry/js-tokens/js-tokens-4.0.0.tgz
vendored
Normal file
Binary file not shown.
1
cli/tests/testdata/npm/registry/js-tokens/registry.json
vendored
Normal file
1
cli/tests/testdata/npm/registry/js-tokens/registry.json
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
cli/tests/testdata/npm/registry/loose-envify/loose-envify-1.4.0.tgz
vendored
Normal file
BIN
cli/tests/testdata/npm/registry/loose-envify/loose-envify-1.4.0.tgz
vendored
Normal file
Binary file not shown.
1
cli/tests/testdata/npm/registry/loose-envify/registry.json
vendored
Normal file
1
cli/tests/testdata/npm/registry/loose-envify/registry.json
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
cli/tests/testdata/npm/registry/react-dom/react-dom-18.2.0.tgz
vendored
Normal file
BIN
cli/tests/testdata/npm/registry/react-dom/react-dom-18.2.0.tgz
vendored
Normal file
Binary file not shown.
1
cli/tests/testdata/npm/registry/react-dom/registry.json
vendored
Normal file
1
cli/tests/testdata/npm/registry/react-dom/registry.json
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
cli/tests/testdata/npm/registry/react/react-18.2.0.tgz
vendored
Normal file
BIN
cli/tests/testdata/npm/registry/react/react-18.2.0.tgz
vendored
Normal file
Binary file not shown.
1
cli/tests/testdata/npm/registry/react/registry.json
vendored
Normal file
1
cli/tests/testdata/npm/registry/react/registry.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
cli/tests/testdata/npm/registry/scheduler/registry.json
vendored
Normal file
1
cli/tests/testdata/npm/registry/scheduler/registry.json
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
cli/tests/testdata/npm/registry/scheduler/scheduler-0.23.0.tgz
vendored
Normal file
BIN
cli/tests/testdata/npm/registry/scheduler/scheduler-0.23.0.tgz
vendored
Normal file
Binary file not shown.
8
cli/tests/testdata/npm/sub_paths/main.jsx
vendored
Normal file
8
cli/tests/testdata/npm/sub_paths/main.jsx
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
import React from "npm:react@18.2.0";
|
||||
import { renderToString } from "npm:react-dom@18.2.0/server";
|
||||
|
||||
function App({ name }) {
|
||||
return <div>Hello {name}!</div>;
|
||||
}
|
||||
|
||||
console.log(renderToString(<App name="World" />));
|
1
cli/tests/testdata/npm/sub_paths/main.out
vendored
Normal file
1
cli/tests/testdata/npm/sub_paths/main.out
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<div>Hello <!-- -->World<!-- -->!</div>
|
Loading…
Reference in a new issue