File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,6 +107,14 @@ impl SpecifierMapper for EsmShMapper {
107107 return None ;
108108 }
109109
110+ // Ignore esm.sh imports of jsr packages. These are only published to
111+ // npm under the `@jsr` scope on the jsr registry, which would require
112+ // the output package to be configured with a custom registry, so just
113+ // vendor the remote module instead.
114+ if specifier. path ( ) . starts_with ( "/jsr/" ) {
115+ return None ;
116+ }
117+
110118 let captures = ESMSH_MAPPING_RE . captures ( specifier. as_str ( ) ) ?;
111119
112120 let sub_path = captures. get ( 4 ) . map ( |m| m. as_str ( ) . to_owned ( ) ) ;
@@ -243,5 +251,20 @@ mod test {
243251 . map( & ModuleSpecifier :: parse( "https://esm.sh/gh/owner/repo" ) . unwrap( ) ) ,
244252 None ,
245253 ) ;
254+ assert_eq ! (
255+ mapper. map(
256+ & ModuleSpecifier :: parse( "https://esm.sh/jsr/@cross/fs@0.1.11" ) . unwrap( )
257+ ) ,
258+ None ,
259+ ) ;
260+ assert_eq ! (
261+ mapper. map(
262+ & ModuleSpecifier :: parse(
263+ "https://esm.sh/jsr/@std/path@1.0.8/resolve.ts"
264+ )
265+ . unwrap( )
266+ ) ,
267+ None ,
268+ ) ;
246269 }
247270}
You can’t perform that action at this time.
0 commit comments