@@ -255,13 +255,22 @@ function refreshRuntimeOptions() {
255255 refreshOptions ( ) ;
256256}
257257
258- function defineEntrypoint ( entrypoint ) {
258+ function defineEntrypoint ( computeEntrypoint ) {
259+ let entrypoint ;
260+ let computed = false ;
261+
259262 ObjectDefineProperty ( process , 'entrypoint' , {
260263 __proto__ : null ,
261- writable : false ,
262264 enumerable : true ,
263265 configurable : true ,
264- value : entrypoint ,
266+ get ( ) {
267+ if ( ! computed ) {
268+ entrypoint = computeEntrypoint ( ) ;
269+ computed = true ;
270+ }
271+ return entrypoint ;
272+ } ,
273+ set : undefined ,
265274 } ) ;
266275}
267276
@@ -305,15 +314,18 @@ function patchProcessObject(expandArgv1) {
305314 }
306315 }
307316
308- let entrypoint ;
309- if ( mainEntry !== undefined ) {
310- const { pathToFileURL } = require ( 'internal/url' ) ;
311- entrypoint = pathToFileURL ( mainEntry ) ;
312- } else if ( getOptionValue ( '--entry-url' ) && process . argv [ 1 ] ) {
313- const { URL } = require ( 'internal/url' ) ;
314- entrypoint = new URL ( process . argv [ 1 ] , getCWDURL ( ) ) ;
315- }
316- defineEntrypoint ( entrypoint ) ;
317+ const entryArg = process . argv [ 1 ] ;
318+ defineEntrypoint ( ( ) => {
319+ if ( mainEntry !== undefined ) {
320+ const { pathToFileURL } = require ( 'internal/url' ) ;
321+ return pathToFileURL ( mainEntry ) . href ;
322+ }
323+ if ( entryArg && getOptionValue ( '--entry-url' ) ) {
324+ const { URL } = require ( 'internal/url' ) ;
325+ return new URL ( entryArg , getCWDURL ( ) ) . href ;
326+ }
327+ return undefined ;
328+ } ) ;
317329
318330 // We need to initialize the global console here again with process.stdout
319331 // and friends for snapshot deserialization.
0 commit comments