@@ -536,17 +536,17 @@ export class Project {
536
536
Object . assign ( this , { buildID : this . mode + '.' + this . config . buildTarget } )
537
537
// update routing
538
538
this . #routing = new Routing ( [ ] , this . config . baseUrl , this . config . defaultLocale , this . config . locales )
539
- // import postcss plugins
540
- await Promise . all ( this . config . postcss . plugins . map ( async p => {
541
- let name : string
542
- if ( typeof p === 'string' ) {
543
- name = p
544
- } else {
545
- name = p . name
539
+ // inject ALEPH global variable
540
+ Object . assign ( globalThis , {
541
+ ALEPH : {
542
+ ENV : {
543
+ ...this . config . env ,
544
+ __version : version ,
545
+ __buildMode : this . mode ,
546
+ __buildTarget : this . config . buildTarget ,
547
+ } as AlephEnv
546
548
}
547
- const { default :
Plugin } = await import ( `https://esm.sh/${ name } [email protected] &no-check` )
548
- this . #postcssPlugins[ name ] = Plugin
549
- } ) )
549
+ } )
550
550
}
551
551
552
552
private async _init ( reload : boolean ) {
@@ -565,24 +565,21 @@ export class Project {
565
565
await ensureDir ( this . buildDir )
566
566
}
567
567
568
- Object . assign ( globalThis , {
569
- ALEPH : {
570
- ENV : {
571
- ...this . config . env ,
572
- __version : version ,
573
- __buildMode : this . mode ,
574
- __buildTarget : this . config . buildTarget ,
575
- } as AlephEnv
576
- } ,
577
- document : new Document ( ) ,
578
- innerWidth : 1920 ,
579
- innerHeight : 1080 ,
580
- devicePixelRatio : 1 ,
581
- $RefreshReg$ : ( ) => { } ,
582
- $RefreshSig$ : ( ) => ( type : any ) => type ,
583
- } )
568
+ // change current work dir to appDoot
584
569
Deno . chdir ( this . appRoot )
585
570
571
+ // import postcss plugins
572
+ await Promise . all ( this . config . postcss . plugins . map ( async p => {
573
+ let name : string
574
+ if ( typeof p === 'string' ) {
575
+ name = p
576
+ } else {
577
+ name = p . name
578
+ }
579
+ const { default :
Plugin } = await import ( `https://esm.sh/${ name } [email protected] &no-check` )
580
+ this . #postcssPlugins[ name ] = Plugin
581
+ } ) )
582
+
586
583
for await ( const { path : p , } of walk ( this . srcDir , { ...walkOptions , maxDepth : 1 , exts : [ ...walkOptions . exts , '.jsx' , '.tsx' ] } ) ) {
587
584
const name = path . basename ( p )
588
585
switch ( name . replace ( reModuleExt , '' ) ) {
@@ -627,7 +624,7 @@ export class Project {
627
624
log . info ( colors . bold ( `Aleph.js v${ version } ` ) )
628
625
if ( this . config . __file ) {
629
626
log . info ( colors . bold ( '- Config' ) )
630
- log . info ( ' ⚙️ ' , this . config . __file )
627
+ log . info ( ' ▲ ' , this . config . __file )
631
628
}
632
629
log . info ( colors . bold ( '- Global' ) )
633
630
if ( this . #modules. has ( '/app.js' ) ) {
@@ -970,7 +967,7 @@ export class Project {
970
967
let sourceCode = ( new TextDecoder ) . decode ( sourceContent )
971
968
for ( const plugin of this . config . plugins ) {
972
969
if ( plugin . test . test ( url ) && plugin . transform ) {
973
- const { code, loader = 'js' } = await plugin . transform ( sourceContent )
970
+ const { code, loader = 'js' } = await plugin . transform ( sourceContent , url )
974
971
sourceCode = code
975
972
mod . loader = loader
976
973
break
@@ -1418,6 +1415,16 @@ export class Project {
1418
1415
}
1419
1416
}
1420
1417
1418
+ // add virtual browser global objects
1419
+ Object . assign ( globalThis , {
1420
+ document : new Document ( ) ,
1421
+ innerWidth : 1920 ,
1422
+ innerHeight : 1080 ,
1423
+ devicePixelRatio : 1 ,
1424
+ $RefreshReg$ : ( ) => { } ,
1425
+ $RefreshSig$ : ( ) => ( type : any ) => type ,
1426
+ } )
1427
+
1421
1428
/** inject HMR and React Fast Referesh helper code */
1422
1429
export function injectHmr ( { id, sourceFilePath, jsContent } : Module ) : string {
1423
1430
let hmrImportPath = path . relative (
0 commit comments