@@ -34,7 +34,7 @@ export async function build(serverEntry?: string) {
34
34
const moduleLoaders = await initModuleLoaders ( importMap ) ;
35
35
const config : AlephConfig | undefined = Reflect . get ( globalThis , "__ALEPH_CONFIG" ) ;
36
36
const platform = config ?. build ?. platform ?? "deno" ;
37
- const target = config ?. build ?. target ?? "es2015 " ;
37
+ const target = config ?. build ?. target ?? "es2020 " ;
38
38
const outputDir = join ( workingDir , config ?. build ?. outputDir ?? "dist" ) ;
39
39
40
40
if ( platform === "cloudflare" || platform === "vercel" ) {
@@ -252,15 +252,15 @@ export async function build(serverEntry?: string) {
252
252
const html = await Deno . readFile ( join ( workingDir , "index.html" ) ) ;
253
253
const links = await parseHtmlLinks ( html ) ;
254
254
for ( const src of links ) {
255
- if ( ! util . isLikelyHttpURL ( src ) ) {
256
- const ext = extname ( util . splitBy ( src , "?" ) [ 0 ] ) . slice ( 1 ) ;
257
- if ( ext === "css" || builtinModuleExts . includes ( ext ) ) {
258
- const specifier = "." + util . cleanPath ( src ) ;
259
- tasks . push ( specifier ) ;
260
- }
255
+ const url = new URL ( src , "http://localhost/" ) ;
256
+ const ext = extname ( url . pathname ) . slice ( 1 ) ;
257
+ if ( ext === "css" || builtinModuleExts . includes ( ext ) ) {
258
+ const specifier = util . isLikelyHttpURL ( src ) ? src : "." + util . cleanPath ( src ) ;
259
+ tasks . push ( specifier ) ;
261
260
}
262
261
}
263
262
}
263
+ tasks . push ( `${ alephPkgUri } /framework/core/nomodule.ts` ) ;
264
264
265
265
const entryModules = new Set ( tasks ) ;
266
266
const allModules = new Set < string > ( ) ;
@@ -275,7 +275,7 @@ export async function build(serverEntry?: string) {
275
275
const isCSS = url . pathname . endsWith ( ".css" ) ;
276
276
const req = new Request ( url . toString ( ) ) ;
277
277
let savePath = join ( outputDir , url . pathname ) ;
278
- if ( specifier . startsWith ( "https://esm.sh/" ) ) {
278
+ if ( specifier . startsWith ( "https://esm.sh/" ) && ! specifier . endsWith ( ".js" ) && ! specifier . endsWith ( ".css" ) ) {
279
279
savePath += ".js" ;
280
280
} else if ( isCSS && url . searchParams . has ( "module" ) ) {
281
281
savePath += ".js" ;
@@ -377,7 +377,7 @@ export async function build(serverEntry?: string) {
377
377
if ( counter . size > 1 ) {
378
378
clientModules . add ( specifier ) ;
379
379
}
380
- console . log ( `${ specifier } is referenced by \n - ${ Array . from ( counter ) . join ( "\n - " ) } ` ) ;
380
+ // console.log(`[ ${specifier}] \n - ${Array.from(counter).join("\n - ")}`);
381
381
} ) ;
382
382
383
383
// bundle client modules
@@ -394,7 +394,7 @@ export async function build(serverEntry?: string) {
394
394
Array . from ( bundling ) . map ( async ( entryPoint ) => {
395
395
const url = new URL ( util . isLikelyHttpURL ( entryPoint ) ? toLocalPath ( entryPoint ) : entryPoint , "http://localhost" ) ;
396
396
let jsFile = join ( outputDir , url . pathname ) ;
397
- if ( entryPoint . startsWith ( "https://esm.sh/" ) ) {
397
+ if ( entryPoint . startsWith ( "https://esm.sh/" ) && ! entryPoint . endsWith ( ".js" ) && ! entryPoint . endsWith ( ".css" ) ) {
398
398
jsFile += ".js" ;
399
399
}
400
400
await esbuild ( {
@@ -408,11 +408,19 @@ export async function build(serverEntry?: string) {
408
408
minify : true ,
409
409
treeShaking : true ,
410
410
sourcemap : false ,
411
+ loader : {
412
+ ".vue" : "js" ,
413
+ } ,
411
414
plugins : [ {
412
415
name : "aleph-esbuild-plugin" ,
413
416
setup ( build ) {
414
417
build . onResolve ( { filter : / .* / } , ( args ) => {
415
- const path = util . trimPrefix ( args . path , outputDir ) ;
418
+ let argsPath = args . path ;
419
+ if ( argsPath . startsWith ( "./" ) || argsPath . startsWith ( "../" ) ) {
420
+ argsPath = join ( args . resolveDir , argsPath ) ;
421
+ }
422
+ const [ fp , q ] = util . splitBy ( argsPath , "?" ) ;
423
+ const path = util . trimPrefix ( fp , outputDir ) ;
416
424
let specifier = "." + path ;
417
425
if ( args . path . startsWith ( "/-/" ) ) {
418
426
specifier = restoreUrl ( path ) ;
@@ -421,8 +429,14 @@ export async function build(serverEntry?: string) {
421
429
return { path : args . path , external : true } ;
422
430
}
423
431
let jsFile = join ( outputDir , path ) ;
424
- if ( specifier . startsWith ( "https://esm.sh/" ) ) {
432
+ if (
433
+ specifier . startsWith ( "https://esm.sh/" ) && ! specifier . endsWith ( ".js" ) && ! specifier . endsWith ( ".css" )
434
+ ) {
425
435
jsFile += ".js" ;
436
+ } else {
437
+ if ( specifier . endsWith ( ".css" ) && new URLSearchParams ( q ) . has ( "module" ) ) {
438
+ jsFile += ".js" ;
439
+ }
426
440
}
427
441
return { path : jsFile } ;
428
442
} ) ;
0 commit comments