module: simplify ts under node_modules check · nodejs/node@0794861
@@ -125,10 +125,10 @@ const { pathToFileURL, fileURLToPath, isURL } = require('internal/url');
125125const {
126126 pendingDeprecate,
127127 emitExperimentalWarning,
128- isUnderNodeModules,
129128 kEmptyObject,
130129 setOwnProperty,
131130 getLazy,
131+ isUnderNodeModules,
132132 isWindows,
133133} = require('internal/util');
134134const {
@@ -170,7 +170,6 @@ const {
170170ERR_REQUIRE_CYCLE_MODULE,
171171ERR_REQUIRE_ESM,
172172ERR_UNKNOWN_BUILTIN_MODULE,
173-ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING,
174173},
175174 setArrowMessage,
176175} = require('internal/errors');
@@ -1348,9 +1347,6 @@ let emittedRequireModuleWarning = false;
13481347function loadESMFromCJS(mod, filename) {
13491348let source = getMaybeCachedSource(mod, filename);
13501349if (getOptionValue('--experimental-strip-types') && path.extname(filename) === '.mts') {
1351-if (isUnderNodeModules(filename)) {
1352-throw new ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING(filename);
1353-}
13541350source = stripTypeScriptTypes(source, filename);
13551351}
13561352const cascadedLoader = require('internal/modules/esm/loader').getOrInitializeCascadedLoader();
@@ -1587,9 +1583,6 @@ function getMaybeCachedSource(mod, filename) {
15871583}
1588158415891585function loadCTS(module, filename) {
1590-if (isUnderNodeModules(filename)) {
1591-throw new ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING(filename);
1592-}
15931586const source = getMaybeCachedSource(module, filename);
15941587const code = stripTypeScriptTypes(source, filename);
15951588module._compile(code, filename, 'commonjs');
@@ -1601,9 +1594,6 @@ function loadCTS(module, filename) {
16011594 * @param {string} filename The file path of the module
16021595 */
16031596function loadTS(module, filename) {
1604-if (isUnderNodeModules(filename)) {
1605-throw new ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING(filename);
1606-}
16071597// If already analyzed the source, then it will be cached.
16081598const source = getMaybeCachedSource(module, filename);
16091599const content = stripTypeScriptTypes(source, filename);