@@ -77,9 +77,12 @@ function normalizedExecuted(commonOption: CommonOptions, options: ResolvedCommon
77
77
78
78
const execute = options . execute ;
79
79
80
- if ( execute . type === ExecuteMode . Node && commonOption . experienceEsm ) {
80
+ if ( execute . type === ExecuteMode . Node && commonOption . experienceScript ) {
81
81
if ( options . format === 'esm' && ! execute . args . includes ( '--import' ) ) {
82
82
execute . args . push ( '--import' , path . join ( import . meta. dirname , './import_register.js' ) ) ;
83
+ } else if ( options . format === 'cjs' && ! execute . args . includes ( '--experimental-vm-modules' ) ) {
84
+ // support dynamic import in vm
85
+ execute . args . push ( '--experimental-vm-modules' ) ;
83
86
}
84
87
}
85
88
}
@@ -125,7 +128,6 @@ export function normalizedTargetEnv(
125
128
options : ResolvedCommonOptions ,
126
129
logger : Logger ,
127
130
) {
128
- config . compilation ?. output ?. targetEnv ;
129
131
if ( commonOptions . target ) {
130
132
if ( ! invalidTargetEnv . includes ( commonOptions . target ) ) {
131
133
logger . error ( `target ${ commonOptions . target } is invalid` ) ;
@@ -176,7 +178,6 @@ async function normalizedSimpleConfig(
176
178
logger : Logger ,
177
179
) {
178
180
const inputs = await tryFindEntryFromUserConfig ( logger , config , commonOptions ) ;
179
-
180
181
options . entry = inputs ;
181
182
182
183
config . compilation ??= { } ;
@@ -207,7 +208,7 @@ async function normalizedSimpleConfig(
207
208
208
209
normalizedExecuted ( commonOptions , options ) ;
209
210
210
- pinOutputEntryFilename ( options ) ;
211
+ pinOutputEntryFilename ( options , config ) ;
211
212
}
212
213
213
214
function withServerOrWatch ( userConfig : UserConfig , resolvedOption : ResolvedCommonOptions ) : UserConfig {
@@ -266,6 +267,9 @@ export class NormalizeOption {
266
267
...( this . options . outputEntry ? { entryFilename : this . options . outputEntry . name } : { } ) ,
267
268
path : this . options . outputDir ,
268
269
} ,
270
+ // TODO: fix in script mode, resources are now only synchronized once at startup
271
+ // and lazyCompilation cannot obtain the latest resources in a timely manner.
272
+ ...( this . options . execute . type === ExecuteMode . Node ? { lazyCompilation : true } : { } ) ,
269
273
...pick ( this . options , 'minify' , 'sourcemap' , 'external' ) ,
270
274
} ,
271
275
} ,
0 commit comments