@@ -44,6 +44,8 @@ const { emitExperimentalWarning } = require('internal/util');
4444// communication with JS.
4545const { shouldAbortOnUncaughtToggle } = internalBinding ( 'util' ) ;
4646
47+ const kEvalTag = '[eval]' ;
48+
4749function tryGetCwd ( ) {
4850try {
4951return process . cwd ( ) ;
@@ -259,7 +261,7 @@ function evalTypeScript(name, source, breakFirstLine, print, shouldLoadESM = fal
259261compiledScript = compileScript ( name , source , baseUrl ) ;
260262} catch ( originalError ) {
261263try {
262- sourceToRun = stripTypeScriptModuleTypes ( source , name , false ) ;
264+ sourceToRun = stripTypeScriptModuleTypes ( source , kEvalTag , false ) ;
263265// Retry the CJS/ESM syntax detection after stripping the types.
264266if ( shouldUseModuleEntryPoint ( name , sourceToRun ) ) {
265267return evalTypeScriptModuleEntryPoint ( source , print ) ;
@@ -322,7 +324,7 @@ function evalTypeScriptModuleEntryPoint(source, print) {
322324moduleWrap = loader . createModuleWrap ( source , url ) ;
323325} catch ( originalError ) {
324326try {
325- const strippedSource = stripTypeScriptModuleTypes ( source , url , false ) ;
327+ const strippedSource = stripTypeScriptModuleTypes ( source , kEvalTag , false ) ;
326328// If the moduleWrap was successfully created, execute the module job.
327329// outside the try-catch block to avoid catching runtime errors.
328330moduleWrap = loader . createModuleWrap ( strippedSource , url ) ;
@@ -355,7 +357,7 @@ function evalTypeScriptModuleEntryPoint(source, print) {
355357 */
356358function parseAndEvalModuleTypeScript ( source , print ) {
357359// We know its a TypeScript module, we can safely emit the experimental warning.
358- const strippedSource = stripTypeScriptModuleTypes ( source , getEvalModuleUrl ( ) ) ;
360+ const strippedSource = stripTypeScriptModuleTypes ( source , kEvalTag ) ;
359361evalModuleEntryPoint ( strippedSource , print ) ;
360362}
361363
@@ -370,7 +372,7 @@ function parseAndEvalModuleTypeScript(source, print) {
370372 */
371373function parseAndEvalCommonjsTypeScript ( name , source , breakFirstLine , print , shouldLoadESM = false ) {
372374// We know its a TypeScript module, we can safely emit the experimental warning.
373- const strippedSource = stripTypeScriptModuleTypes ( source , getEvalModuleUrl ( ) ) ;
375+ const strippedSource = stripTypeScriptModuleTypes ( source , kEvalTag ) ;
374376evalScript ( name , strippedSource , breakFirstLine , print , shouldLoadESM ) ;
375377}
376378
0 commit comments