@@ -79,7 +79,6 @@ export class Application implements ServerApplication {
79
79
readonly importMap : ImportMap
80
80
readonly ready : Promise < void >
81
81
82
- #dirs: Map < string , string > = new Map ( )
83
82
#modules: Map < string , Module > = new Map ( )
84
83
#pageRouting: Routing = new Routing ( { } )
85
84
#apiRouting: Routing = new Routing ( { } )
@@ -122,7 +121,8 @@ export class Application implements ServerApplication {
122
121
123
122
// inject env variables
124
123
Deno . env . set ( 'ALEPH_VERSION' , VERSION )
125
- Deno . env . set ( 'BUILD_MODE' , this . mode )
124
+ Deno . env . set ( 'ALEPH_BUILD_MODE' , this . mode )
125
+ Deno . env . set ( 'ALEPH_FRAMEWORK' , this . framework )
126
126
127
127
// inject browser navigator polyfill
128
128
Object . assign ( ( globalThis as any ) . navigator , {
@@ -195,12 +195,12 @@ export class Application implements ServerApplication {
195
195
}
196
196
197
197
// init framework
198
- const { init } = await import ( `../framework/${ this . config . framework } /init.ts` )
198
+ const { init } = await import ( `../framework/${ this . framework } /init.ts` )
199
199
await init ( this )
200
200
201
201
// import framework renderer
202
202
if ( this . config . ssr ) {
203
- const { jsFile } = await this . compile ( `${ alephPkgUri } /framework/${ this . config . framework } /renderer.ts` )
203
+ const { jsFile } = await this . compile ( `${ alephPkgUri } /framework/${ this . framework } /renderer.ts` )
204
204
const { render } = await import ( `file://${ jsFile } ` )
205
205
if ( util . isFunction ( render ) ) {
206
206
this . #renderer. setFrameworkRenderer ( { render } )
@@ -210,7 +210,7 @@ export class Application implements ServerApplication {
210
210
log . info ( 'Compiling...' )
211
211
212
212
// pre-compile framework modules
213
- await this . compile ( `${ alephPkgUri } /framework/${ this . config . framework } /bootstrap.ts` )
213
+ await this . compile ( `${ alephPkgUri } /framework/${ this . framework } /bootstrap.ts` )
214
214
if ( this . isDev ) {
215
215
await this . compile ( `${ alephPkgUri } /framework/core/hmr.ts` )
216
216
await this . compile ( `${ alephPkgUri } /framework/core/nomodule.ts` )
@@ -405,16 +405,20 @@ export class Application implements ServerApplication {
405
405
return this . mode === 'development'
406
406
}
407
407
408
+ get framework ( ) {
409
+ return this . config . framework
410
+ }
411
+
408
412
get srcDir ( ) {
409
- return this . getDir ( 'src' , ( ) => join ( this . workingDir , this . config . srcDir ) )
413
+ return join ( this . workingDir , this . config . srcDir )
410
414
}
411
415
412
416
get outputDir ( ) {
413
- return this . getDir ( 'output' , ( ) => join ( this . workingDir , this . config . outputDir ) )
417
+ return join ( this . workingDir , this . config . outputDir )
414
418
}
415
419
416
420
get buildDir ( ) {
417
- return this . getDir ( 'build' , ( ) => join ( this . workingDir , '.aleph' , this . mode ) )
421
+ return join ( this . workingDir , '.aleph' , this . mode )
418
422
}
419
423
420
424
get loaders ( ) {
@@ -757,16 +761,6 @@ export class Application implements ServerApplication {
757
761
log . info ( `Done in ${ Math . round ( performance . now ( ) - start ) } ms` )
758
762
}
759
763
760
- private getDir ( name : string , init : ( ) => string ) {
761
- if ( this . #dirs. has ( name ) ) {
762
- return this . #dirs. get ( name ) !
763
- }
764
-
765
- const dir = init ( )
766
- this . #dirs. set ( name , dir )
767
- return dir
768
- }
769
-
770
764
private createRouteUpdate ( url : string ) : [ string , string , { isIndex ?: boolean , useDeno ?: boolean } ] {
771
765
const isBuiltinModule = moduleExts . some ( ext => url . endsWith ( '.' + ext ) )
772
766
let pagePath = isBuiltinModule ? toPagePath ( url ) : util . trimSuffix ( url , '/pages' )
@@ -1231,7 +1225,7 @@ export class Application implements ServerApplication {
1231
1225
1232
1226
// add framwork bootstrap module as shared entry
1233
1227
entryMods . set (
1234
- [ `${ getAlephPkgUri ( ) } /framework/${ this . config . framework } /bootstrap.ts` ] ,
1228
+ [ `${ getAlephPkgUri ( ) } /framework/${ this . framework } /bootstrap.ts` ] ,
1235
1229
true
1236
1230
)
1237
1231
0 commit comments