@@ -71,7 +71,6 @@ export class Application implements ServerApplication {
71
71
private async init ( reload : boolean ) {
72
72
const t = performance . now ( )
73
73
const alephPkgUri = getAlephPkgUri ( )
74
- const { env, framework, plugins, ssr } = this . config
75
74
const walkOptions = { includeDirs : false , skip : [ / ( ^ | \/ | \\ ) \. / , / \. d \. t s $ / i, / ( \. | _ ) ( t e s t | s p e c | e 2 e ) \. ( t s x ? | j s x ? | m j s ) ? $ / i] }
76
75
const apiDir = path . join ( this . srcDir , 'api' )
77
76
const pagesDir = path . join ( this . srcDir , 'pages' )
@@ -109,14 +108,13 @@ export class Application implements ServerApplication {
109
108
await ensureDir ( this . buildDir )
110
109
}
111
110
112
- // change current working directory to appDoot
113
- Deno . chdir ( this . workingDir )
114
-
115
111
// inject env variables
116
- Object . entries ( env ) . forEach ( ( [ key , value ] ) => Deno . env . set ( key , value ) )
117
112
Deno . env . set ( 'ALEPH_VERSION' , VERSION )
118
113
Deno . env . set ( 'BUILD_MODE' , this . mode )
119
114
115
+ // change current working directory to appDoot
116
+ Deno . chdir ( this . workingDir )
117
+
120
118
const [ config , importMap , denoDir ] = await Promise . all ( [
121
119
loadConfig ( this . workingDir ) ,
122
120
loadImportMap ( this . workingDir ) ,
@@ -127,29 +125,29 @@ export class Application implements ServerApplication {
127
125
this . #dirs. set ( 'denoDir' , denoDir )
128
126
129
127
// apply server plugins
130
- for ( const plugin of plugins ) {
128
+ for ( const plugin of this . config . plugins ) {
131
129
if ( plugin . type === 'server' ) {
132
130
await plugin . onInit ( this )
133
131
}
134
132
}
135
133
136
134
// init framework
137
- const { init } = await import ( `../framework/${ framework } /init.ts` )
135
+ const { init } = await import ( `../framework/${ this . config . framework } /init.ts` )
138
136
await init ( this )
139
137
140
138
log . info ( 'Compiling...' )
141
139
142
140
// pre-compile framework modules
143
- await this . compile ( `${ alephPkgUri } /framework/${ framework } /bootstrap.ts` )
141
+ await this . compile ( `${ alephPkgUri } /framework/${ this . config . framework } /bootstrap.ts` )
144
142
if ( this . isDev ) {
145
143
await Promise . all ( [ 'hmr.ts' , 'nomodule.ts' ] . map ( name => {
146
144
this . compile ( `${ alephPkgUri } /framework/core/${ name } ` )
147
145
} ) )
148
146
}
149
147
150
148
// compile and import framework renderer when ssr is enable
151
- if ( ssr ) {
152
- const rendererModuleUrl = `${ alephPkgUri } /framework/${ framework } /renderer.ts`
149
+ if ( this . config . ssr ) {
150
+ const rendererModuleUrl = `${ alephPkgUri } /framework/${ this . config . framework } /renderer.ts`
153
151
const { jsFile } = await this . compile ( rendererModuleUrl , { once : true } )
154
152
this . #renderer = await import ( 'file://' + jsFile )
155
153
}
0 commit comments