Skip to content

Commit

Permalink
fix(core): register transpiler should setup loading for node code (#1…
Browse files Browse the repository at this point in the history
…9454)

Co-authored-by: Colum Ferry <[email protected]>
  • Loading branch information
AgentEnder and Coly010 authored Oct 5, 2023
1 parent 9474841 commit 7214791
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 10 additions & 0 deletions packages/nx/src/plugins/js/utils/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ export function getTsNodeTranspiler(
export function getTranspiler(compilerOptions: CompilerOptions) {
const preferTsNode = process.env.NX_PREFER_TS_NODE === 'true';

if (!ts) {
ts = require('typescript');
}

compilerOptions.lib = ['es2021'];
compilerOptions.module = ts.ModuleKind.CommonJS;
compilerOptions.target = ts.ScriptTarget.ES2021;
compilerOptions.inlineSourceMap = true;
compilerOptions.skipLibCheck = true;

if (swcNodeInstalled && !preferTsNode) {
return () => getSwcTranspiler(compilerOptions);
}
Expand Down
5 changes: 0 additions & 5 deletions packages/nx/src/utils/nx-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,6 @@ export function registerPluginTSTranspiler() {
experimentalDecorators: true,
emitDecoratorMetadata: true,
...tsConfig.options,
lib: ['es2021'],
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES2021,
inlineSourceMap: true,
skipLibCheck: true,
});
tsNodeAndPathsUnregisterCallback = () => {
unregisterTsConfigPaths();
Expand Down

0 comments on commit 7214791

Please sign in to comment.