@@ -6,16 +6,11 @@ import { createRouter } from './router.ts'
66import { colors , ensureDir , path , Sha1 , walk } from './std.ts'
77import { compile } from './tsc/compile.ts'
88import type { APIHandle , Config , Location , RouterURL } from './types.ts'
9- import util , { hashShort } from './util.ts'
9+ import util , { hashShort , reHashJs , reHttp , reModuleExt , reStyleModuleExt } from './util.ts'
1010import './vendor/clean-css-builds/v4.2.2.js'
1111import { Document } from './vendor/deno-dom/document.ts'
1212import less from './vendor/less/less.js'
1313
14- const reHttp = / ^ h t t p s ? : \/ \/ / i
15- const reModuleExt = / \. ( j s | j s x | m j s | t s | t s x ) $ / i
16- const reStyleModuleExt = / \. ( c s s | l e s s | s a s s | s c s s ) $ / i
17- const reHashJs = new RegExp ( `\\.[0-9a-fx]{${ hashShort } }\\.js$` , 'i' )
18-
1914const { CleanCSS } = window as any
2015const cleanCSS = new CleanCSS ( { compatibility : '*' /* Internet Explorer 10+ */ } )
2116
@@ -396,6 +391,8 @@ export default class Project {
396391 Object . assign ( globalThis , {
397392 ALEPH_ENV : {
398393 appDir : this . rootDir ,
394+ config : this . config ,
395+ mode : this . mode ,
399396 } ,
400397 document : new Document ( ) ,
401398 innerWidth : 1920 ,
@@ -913,12 +910,12 @@ export default class Project {
913910 path . dirname ( path . resolve ( '/' , url ) ) ,
914911 path . resolve ( '/' , dep . url . replace ( reModuleExt , '' ) )
915912 )
916- mod . jsContent = mod . jsContent . replace ( / ( i m p o r t | e x p o r t ) ( [ ^ ' " ] * ) ( " | ' ) ( [ ^ ' " ] + ) ( " | ' ) ( \) | ; ) ? / g, ( s , key , from , ql , importPath , qr , end ) => {
913+ mod . jsContent = mod . jsContent . replace ( / ( i | I m p o r t | e x p o r t ) ( [ ^ ' " ] * ) ( " | ' ) ( [ ^ ' " ] + ) ( " | ' ) ( \) | ; ) ? / g, ( s , key , from , ql , importPath , qr , end ) => {
917914 if (
918915 reHashJs . test ( importPath ) &&
919916 importPath . slice ( 0 , importPath . length - ( hashShort + 4 ) ) === depImportPath
920917 ) {
921- return `${ key } ${ from } ${ ql } ${ depImportPath } .${ dep . hash . slice ( 0 , hashShort ) } .js${ qr } ${ end } `
918+ return `${ key } ${ from } ${ ql } ${ depImportPath } .${ dep . hash . slice ( 0 , hashShort ) } .js${ qr } ${ end || '' } `
922919 }
923920 return s
924921 } )
@@ -965,7 +962,7 @@ export default class Project {
965962 reHashJs . test ( importPath ) &&
966963 importPath . slice ( 0 , importPath . length - ( hashShort + 4 ) ) === depImportPath
967964 ) {
968- return `${ key } ${ from } ${ ql } ${ depImportPath } .${ dep . hash . slice ( 0 , hashShort ) } .js${ qr } ${ end } `
965+ return `${ key } ${ from } ${ ql } ${ depImportPath } .${ dep . hash . slice ( 0 , hashShort ) } .js${ qr } ${ end || '' } `
969966 }
970967 return s
971968 } )
@@ -1082,7 +1079,7 @@ export default class Project {
10821079 const { default : Page } = await import ( "file://" + pageModule . jsFile )
10831080 const data = await this . getData ( )
10841081 const html = renderPage ( data , url , appModule ? App : undefined , Page )
1085- const head = renderHead ( [
1082+ const head = await renderHead ( [
10861083 this . _lookupStyles ( pageModule ) ,
10871084 appModule ? this . _lookupStyles ( appModule ) : [ ]
10881085 ] . flat ( ) )
0 commit comments