@@ -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() {
4850 try {
4951 return process.cwd();
@@ -259,7 +261,7 @@ function evalTypeScript(name, source, breakFirstLine, print, shouldLoadESM = fal
259261 compiledScript = compileScript(name, source, baseUrl);
260262 } catch (originalError) {
261263 try {
262- sourceToRun = stripTypeScriptModuleTypes(source, name , false);
264+ sourceToRun = stripTypeScriptModuleTypes(source, kEvalTag , false);
263265 // Retry the CJS/ESM syntax detection after stripping the types.
264266 if (shouldUseModuleEntryPoint(name, sourceToRun)) {
265267 return evalTypeScriptModuleEntryPoint(source, print);
@@ -322,7 +324,7 @@ function evalTypeScriptModuleEntryPoint(source, print) {
322324 moduleWrap = loader.createModuleWrap(source, url);
323325 } catch (originalError) {
324326 try {
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.
328330 moduleWrap = 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 );
359361 evalModuleEntryPoint(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 );
374376 evalScript(name, strippedSource, breakFirstLine, print, shouldLoadESM);
375377}
376378
0 commit comments