@@ -44,6 +44,8 @@ const { emitExperimentalWarning } = require('internal/util');
44
44
// communication with JS.
45
45
const { shouldAbortOnUncaughtToggle } = internalBinding ( 'util' ) ;
46
46
47
+ const kEvalTag = '[eval]' ;
48
+
47
49
function tryGetCwd ( ) {
48
50
try {
49
51
return process . cwd ( ) ;
@@ -259,7 +261,7 @@ function evalTypeScript(name, source, breakFirstLine, print, shouldLoadESM = fal
259
261
compiledScript = compileScript ( name , source , baseUrl ) ;
260
262
} catch ( originalError ) {
261
263
try {
262
- sourceToRun = stripTypeScriptModuleTypes ( source , name , false ) ;
264
+ sourceToRun = stripTypeScriptModuleTypes ( source , kEvalTag , false ) ;
263
265
// Retry the CJS/ESM syntax detection after stripping the types.
264
266
if ( shouldUseModuleEntryPoint ( name , sourceToRun ) ) {
265
267
return evalTypeScriptModuleEntryPoint ( source , print ) ;
@@ -322,7 +324,7 @@ function evalTypeScriptModuleEntryPoint(source, print) {
322
324
moduleWrap = loader . createModuleWrap ( source , url ) ;
323
325
} catch ( originalError ) {
324
326
try {
325
- const strippedSource = stripTypeScriptModuleTypes ( source , url , false ) ;
327
+ const strippedSource = stripTypeScriptModuleTypes ( source , kEvalTag , false ) ;
326
328
// If the moduleWrap was successfully created, execute the module job.
327
329
// outside the try-catch block to avoid catching runtime errors.
328
330
moduleWrap = loader . createModuleWrap ( strippedSource , url ) ;
@@ -355,7 +357,7 @@ function evalTypeScriptModuleEntryPoint(source, print) {
355
357
*/
356
358
function parseAndEvalModuleTypeScript ( source , print ) {
357
359
// 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 ) ;
359
361
evalModuleEntryPoint ( strippedSource , print ) ;
360
362
}
361
363
@@ -370,7 +372,7 @@ function parseAndEvalModuleTypeScript(source, print) {
370
372
*/
371
373
function parseAndEvalCommonjsTypeScript ( name , source , breakFirstLine , print , shouldLoadESM = false ) {
372
374
// 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 ) ;
374
376
evalScript ( name , strippedSource , breakFirstLine , print , shouldLoadESM ) ;
375
377
}
376
378
0 commit comments