@oclif/core 3.0.0-beta.12 → 3.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config/ts-node.js +10 -21
- package/package.json +1 -1
package/lib/config/ts-node.js
CHANGED
|
@@ -6,7 +6,6 @@ const path = require("path");
|
|
|
6
6
|
const settings_1 = require("../settings");
|
|
7
7
|
const util_1 = require("../util");
|
|
8
8
|
const util_2 = require("./util");
|
|
9
|
-
const config_1 = require("./config");
|
|
10
9
|
const errors_1 = require("../errors");
|
|
11
10
|
// eslint-disable-next-line new-cap
|
|
12
11
|
const debug = (0, util_2.Debug)('ts-node');
|
|
@@ -92,7 +91,6 @@ function registerTSNode(root) {
|
|
|
92
91
|
REGISTERED.add(root);
|
|
93
92
|
return tsconfig;
|
|
94
93
|
}
|
|
95
|
-
// eslint-disable-next-line complexity
|
|
96
94
|
function tsPath(root, orig, plugin) {
|
|
97
95
|
if (!orig)
|
|
98
96
|
return orig;
|
|
@@ -102,28 +100,19 @@ function tsPath(root, orig, plugin) {
|
|
|
102
100
|
debug(`Skipping ts-node registration for ${root} because tsNodeEnabled is explicitly set to false`);
|
|
103
101
|
return orig;
|
|
104
102
|
}
|
|
105
|
-
// Skip ts-node registration
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
// Skip ts-node registration for ESM plugins.
|
|
104
|
+
// The node ecosystem is not mature enough to support auto-transpiling ESM modules at this time.
|
|
105
|
+
// See the following:
|
|
106
|
+
// - https://github.com/TypeStrong/ts-node/issues/1791#issuecomment-1149754228
|
|
107
|
+
// - https://github.com/nodejs/node/issues/49432
|
|
108
|
+
// - https://github.com/nodejs/node/pull/49407
|
|
109
|
+
// - https://github.com/nodejs/node/issues/34049
|
|
110
|
+
if (plugin?.moduleType === 'module') {
|
|
111
|
+
debug(`Skipping ts-node registration for ${root} because it's an ESM module`);
|
|
108
112
|
if (plugin.type === 'link')
|
|
109
|
-
(0, errors_1.memoizedWarn)(`${plugin.name} is a linked ESM module and cannot be auto-
|
|
113
|
+
(0, errors_1.memoizedWarn)(`${plugin.name} is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.`);
|
|
110
114
|
return orig;
|
|
111
115
|
}
|
|
112
|
-
// If plugin is an ESM plugin being executed from an ESM root plugin, check to see if ts-node/esm loader has been set
|
|
113
|
-
// either in the NODE_OPTIONS env var or from the exec args. If the ts-node/esm loader has NOT been loaded then we want
|
|
114
|
-
// to skip ts-node registration so that it falls back on the compiled source.
|
|
115
|
-
if (plugin?.moduleType === 'module') {
|
|
116
|
-
const tsNodeEsmLoaderInExecArgv = process.execArgv.includes('--loader') && process.execArgv.includes('ts-node/esm');
|
|
117
|
-
const tsNodeEsmLoaderInNodeOptions = process.env.NODE_OPTIONS?.includes('--loader=ts-node/esm') ?? false;
|
|
118
|
-
if (!tsNodeEsmLoaderInExecArgv && !tsNodeEsmLoaderInNodeOptions) {
|
|
119
|
-
debug(`Skipping ts-node registration for ${root} because it's an ESM module but the ts-node/esm loader hasn't been run`);
|
|
120
|
-
debug('try setting NODE_OPTIONS="--loader ts-node/esm" in your environment.');
|
|
121
|
-
if (plugin.type === 'link') {
|
|
122
|
-
(0, errors_1.memoizedWarn)(`${plugin.name} is a linked ESM module and cannot be auto-compiled without setting NODE_OPTIONS="--loader=ts-node/esm" in the environment. Existing compiled source will be used instead.`);
|
|
123
|
-
}
|
|
124
|
-
return orig;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
116
|
if (settings_1.settings.tsnodeEnabled === undefined && (0, util_1.isProd)() && plugin?.type !== 'link') {
|
|
128
117
|
debug(`Skipping ts-node registration for ${root} because NODE_ENV is NOT "test" or "development"`);
|
|
129
118
|
return orig;
|