@@ -11,6 +11,9 @@ const { getOptionValue } = require('internal/options');
1111
1212const {
1313 evalModuleEntryPoint,
14+ evalTypeScript,
15+ parseAndEvalCommonjsTypeScript,
16+ parseAndEvalModuleTypeScript,
1417 evalScript,
1518 readStdin,
1619} = require ( 'internal/process/execution' ) ;
@@ -25,13 +28,30 @@ readStdin((code) => {
2528
2629 const print = getOptionValue ( '--print' ) ;
2730 const shouldLoadESM = getOptionValue ( '--import' ) . length > 0 ;
28- if ( getOptionValue ( '--input-type' ) === 'module' ) {
31+ const inputType = getOptionValue ( '--input-type' ) ;
32+ const tsEnabled = getOptionValue ( '--experimental-strip-types' ) ;
33+ if ( inputType === 'module' ) {
2934 evalModuleEntryPoint ( code , print ) ;
35+ } else if ( inputType === 'module-typescript' && tsEnabled ) {
36+ parseAndEvalModuleTypeScript ( code , print ) ;
3037 } else {
31- evalScript ( '[stdin]' ,
32- code ,
33- getOptionValue ( '--inspect-brk' ) ,
34- print ,
35- shouldLoadESM ) ;
38+
39+ let evalFunction ;
40+ if ( inputType === 'commonjs' ) {
41+ evalFunction = evalScript ;
42+ } else if ( inputType === 'commonjs-typescript' && tsEnabled ) {
43+ evalFunction = parseAndEvalCommonjsTypeScript ;
44+ } else if ( tsEnabled ) {
45+ evalFunction = evalTypeScript ;
46+ } else {
47+ // Default to commonjs.
48+ evalFunction = evalScript ;
49+ }
50+
51+ evalFunction ( '[stdin]' ,
52+ code ,
53+ getOptionValue ( '--inspect-brk' ) ,
54+ print ,
55+ shouldLoadESM ) ;
3656 }
3757} ) ;
0 commit comments