1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -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)? .resolve_package_from_deno_module(&reference.req)?
.folder_path; .folder_path;
let maybe_url = package_config_resolve( 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, &package_folder,
npm_resolver, npm_resolver,
) )

View file

@ -68,6 +68,13 @@ itest!(import_map {
http_server: true, 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] #[test]
fn parallel_downloading() { fn parallel_downloading() {
let (out, _err) = util::run_and_collect_output_with_args( 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>