11// CLI utility to build/list/extract/run ESZIPs
22
33import { build , Parser } from "./mod.ts" ;
4- import { dirname , extname , join } from "https://deno.land/[email protected] /path/mod.ts" ; 5-
6- const extensions = new Set ( [
7- ".ts" ,
8- ".tsx" ,
9- ".js" ,
10- ".jsx" ,
11- ".mjs" ,
12- ".mts" ,
13- ".json" ,
14- ".wasm"
15- ] ) ;
4+ import { dirname , join } from "https://deno.land/[email protected] /path/mod.ts" ; 165
176function hasV2Header ( bytes : Uint8Array ) {
187 const magicV2 = new TextDecoder ( ) . decode ( bytes . slice ( 0 , 8 ) ) ;
@@ -92,6 +81,7 @@ class V2 {
9281 const imports : Record < string , string > = { } ;
9382
9483 for ( const specifier of this . specifiers ) {
84+ if ( new URL ( specifier ) . protocol !== "file:" ) continue
9585 const module = await this . parser . getModuleSource ( specifier ) ;
9686 await write ( join ( dest , "source" , url2path ( specifier ) ) , module ) ;
9787 // Track import
@@ -118,15 +108,8 @@ export async function loadESZIP(filename: string): Promise<ESZIP> {
118108 return await V1 . load ( bytes ) ;
119109}
120110
121- function url2path ( urlString : string ) {
122- const url = new URL ( urlString ) ;
123- let path = join ( url . hostname , ...url . pathname . split ( "/" ) . filter ( Boolean ) ) ;
124-
125- if ( ! extensions . has ( extname ( path ) ) ) {
126- path = join ( path , ".index.ts" ) ;
127- }
128-
129- return path ;
111+ function url2path ( url : string ) {
112+ return join ( ...( new URL ( url ) . pathname . split ( "/" ) . filter ( Boolean ) ) ) ;
130113}
131114
132115async function write ( path : string , content : string ) {
0 commit comments