1
0
Fork 0
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:
David Sherret 2022-08-24 11:25:32 -04:00 committed by GitHub
parent a4cc09447e
commit 684aabbc25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 26 additions and 1 deletions

View file

@ -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,
)

View file

@ -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(

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

View 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" />));

View file

@ -0,0 +1 @@
<div>Hello <!-- -->World<!-- -->!</div>