@@ -1362,8 +1362,9 @@ function loadESMFromCJS(mod, filename) {
13621362 if ( isUnderNodeModules ( filename ) ) {
13631363 throw new ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING ( filename ) ;
13641364 }
1365- const { tsParse } = require ( 'internal/modules/helpers' ) ;
1366- source = tsParse ( source ) ;
1365+ const { stripTypes } = require ( 'internal/modules/helpers' ) ;
1366+ const { code } = stripTypes ( source , filename ) ;
1367+ source = code ;
13671368 }
13681369 const cascadedLoader = require ( 'internal/modules/esm/loader' ) . getOrInitializeCascadedLoader ( ) ;
13691370 const isMain = mod [ kIsMainSymbol ] ;
@@ -1576,9 +1577,9 @@ function loadCTS(module, filename) {
15761577 throw new ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING ( filename ) ;
15771578 }
15781579 const source = getMaybeCachedSource ( module , filename ) ;
1579- const { tsParse } = require ( 'internal/modules/helpers' ) ;
1580- const content = tsParse ( source ) ;
1581- module . _compile ( content , filename , 'commonjs' ) ;
1580+ const { stripTypes } = require ( 'internal/modules/helpers' ) ;
1581+ const { code } = stripTypes ( source , filename ) ;
1582+ module . _compile ( code , filename , 'commonjs' ) ;
15821583}
15831584
15841585/**
@@ -1592,8 +1593,8 @@ function loadTS(module, filename) {
15921593 }
15931594 // If already analyzed the source, then it will be cached.
15941595 const source = getMaybeCachedSource ( module , filename ) ;
1595- const { tsParse } = require ( 'internal/modules/helpers' ) ;
1596- const content = tsParse ( source ) ;
1596+ const { stripTypes } = require ( 'internal/modules/helpers' ) ;
1597+ const { code : content } = stripTypes ( source , filename ) ;
15971598 let format ;
15981599 const pkg = packageJsonReader . getNearestParentPackageJSON ( filename ) ;
15991600 // Function require shouldn't be used in ES modules.
@@ -1613,7 +1614,8 @@ function loadTS(module, filename) {
16131614 if ( Module . _cache [ parentPath ] ) {
16141615 let parentSource ;
16151616 try {
1616- parentSource = tsParse ( fs . readFileSync ( parentPath , 'utf8' ) ) ;
1617+ const { code } = stripTypes ( fs . readFileSync ( parentPath , 'utf8' ) , parentPath ) ;
1618+ parentSource = code ;
16171619 } catch {
16181620 // Continue regardless of error.
16191621 }
0 commit comments