nx 19.4.0 → 19.5.0-beta.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +30 -26
- package/src/command-line/graph/graph.js +7 -2
- package/src/command-line/reset/reset.js +1 -1
- package/src/command-line/watch/watch.js +6 -0
- package/src/commands-runner/create-command-graph.js +32 -10
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/daemon/client/client.d.ts +1 -0
- package/src/daemon/client/client.js +14 -2
- package/src/devkit-exports.d.ts +1 -0
- package/src/devkit-exports.js +3 -1
- package/src/native/browser.js +1 -0
- package/src/native/index.d.ts +178 -138
- package/src/native/index.js +16 -0
- package/src/native/native-bindings.js +352 -238
- package/src/native/nx.wasi-browser.js +108 -0
- package/src/native/nx.wasi.cjs +139 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/native/wasi-worker-browser.mjs +32 -0
- package/src/native/wasi-worker.mjs +63 -0
- package/src/plugins/js/utils/register.js +29 -13
- package/src/project-graph/plugins/internal-api.js +0 -1
- package/src/project-graph/plugins/isolation/plugin-pool.js +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +8 -6
- package/src/project-graph/utils/project-configuration-utils.js +109 -44
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
- package/src/tasks-runner/pseudo-terminal.js +3 -0
- package/src/tasks-runner/task-graph-utils.d.ts +1 -1
- package/src/tasks-runner/task-graph-utils.js +4 -4
- package/src/tasks-runner/utils.js +1 -1
- package/src/utils/nx-plugin.deprecated.js +0 -2
- package/src/plugins/target-defaults/symbols.d.ts +0 -17
- package/src/plugins/target-defaults/symbols.js +0 -20
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +0 -121
- package/src/plugins/target-defaults/target-defaults-plugin.js +0 -176
@@ -0,0 +1,108 @@
|
|
1
|
+
import {
|
2
|
+
instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync,
|
3
|
+
getDefaultContext as __emnapiGetDefaultContext,
|
4
|
+
WASI as __WASI,
|
5
|
+
createOnMessage as __wasmCreateOnMessageForFsProxy,
|
6
|
+
} from '@napi-rs/wasm-runtime'
|
7
|
+
|
8
|
+
import __wasmUrl from './nx.wasm32-wasi.wasm?url'
|
9
|
+
|
10
|
+
const __wasi = new __WASI({
|
11
|
+
version: 'preview1',
|
12
|
+
})
|
13
|
+
|
14
|
+
const __emnapiContext = __emnapiGetDefaultContext()
|
15
|
+
|
16
|
+
const __sharedMemory = new WebAssembly.Memory({
|
17
|
+
initial: 16384,
|
18
|
+
maximum: 32768,
|
19
|
+
shared: true,
|
20
|
+
})
|
21
|
+
|
22
|
+
const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
|
23
|
+
|
24
|
+
const {
|
25
|
+
instance: __napiInstance,
|
26
|
+
module: __wasiModule,
|
27
|
+
napiModule: __napiModule,
|
28
|
+
} = __emnapiInstantiateNapiModuleSync(__wasmFile, {
|
29
|
+
context: __emnapiContext,
|
30
|
+
asyncWorkPoolSize: 4,
|
31
|
+
wasi: __wasi,
|
32
|
+
onCreateWorker() {
|
33
|
+
const worker = new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), {
|
34
|
+
type: 'module',
|
35
|
+
})
|
36
|
+
|
37
|
+
return worker
|
38
|
+
},
|
39
|
+
overwriteImports(importObject) {
|
40
|
+
importObject.env = {
|
41
|
+
...importObject.env,
|
42
|
+
...importObject.napi,
|
43
|
+
...importObject.emnapi,
|
44
|
+
memory: __sharedMemory,
|
45
|
+
}
|
46
|
+
return importObject
|
47
|
+
},
|
48
|
+
beforeInit({ instance }) {
|
49
|
+
__napi_rs_initialize_modules(instance)
|
50
|
+
},
|
51
|
+
})
|
52
|
+
|
53
|
+
function __napi_rs_initialize_modules(__napiInstance) {
|
54
|
+
__napiInstance.exports['__napi_register__expand_outputs_0']?.()
|
55
|
+
__napiInstance.exports['__napi_register__get_files_for_outputs_1']?.()
|
56
|
+
__napiInstance.exports['__napi_register__remove_2']?.()
|
57
|
+
__napiInstance.exports['__napi_register__copy_3']?.()
|
58
|
+
__napiInstance.exports['__napi_register__hash_array_4']?.()
|
59
|
+
__napiInstance.exports['__napi_register__hash_file_5']?.()
|
60
|
+
__napiInstance.exports['__napi_register__ImportResult_struct_6']?.()
|
61
|
+
__napiInstance.exports['__napi_register__find_imports_7']?.()
|
62
|
+
__napiInstance.exports['__napi_register__transfer_project_graph_8']?.()
|
63
|
+
__napiInstance.exports['__napi_register__ExternalNode_struct_9']?.()
|
64
|
+
__napiInstance.exports['__napi_register__Target_struct_10']?.()
|
65
|
+
__napiInstance.exports['__napi_register__Project_struct_11']?.()
|
66
|
+
__napiInstance.exports['__napi_register__ProjectGraph_struct_12']?.()
|
67
|
+
__napiInstance.exports['__napi_register__HashPlanner_struct_13']?.()
|
68
|
+
__napiInstance.exports['__napi_register__HashPlanner_impl_17']?.()
|
69
|
+
__napiInstance.exports['__napi_register__HashDetails_struct_18']?.()
|
70
|
+
__napiInstance.exports['__napi_register__HasherOptions_struct_19']?.()
|
71
|
+
__napiInstance.exports['__napi_register__TaskHasher_struct_20']?.()
|
72
|
+
__napiInstance.exports['__napi_register__TaskHasher_impl_23']?.()
|
73
|
+
__napiInstance.exports['__napi_register__Task_struct_24']?.()
|
74
|
+
__napiInstance.exports['__napi_register__TaskTarget_struct_25']?.()
|
75
|
+
__napiInstance.exports['__napi_register__TaskGraph_struct_26']?.()
|
76
|
+
__napiInstance.exports['__napi_register__FileData_struct_27']?.()
|
77
|
+
__napiInstance.exports['__napi_register__InputsInput_struct_28']?.()
|
78
|
+
__napiInstance.exports['__napi_register__FileSetInput_struct_29']?.()
|
79
|
+
__napiInstance.exports['__napi_register__RuntimeInput_struct_30']?.()
|
80
|
+
__napiInstance.exports['__napi_register__EnvironmentInput_struct_31']?.()
|
81
|
+
__napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_32']?.()
|
82
|
+
__napiInstance.exports['__napi_register__DepsOutputsInput_struct_33']?.()
|
83
|
+
__napiInstance.exports['__napi_register__NxJson_struct_34']?.()
|
84
|
+
__napiInstance.exports['__napi_register__WorkspaceContext_struct_35']?.()
|
85
|
+
__napiInstance.exports['__napi_register__WorkspaceContext_impl_44']?.()
|
86
|
+
__napiInstance.exports['__napi_register__WorkspaceErrors_45']?.()
|
87
|
+
__napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_46']?.()
|
88
|
+
__napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_47']?.()
|
89
|
+
__napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_48']?.()
|
90
|
+
__napiInstance.exports['__napi_register__FileMap_struct_49']?.()
|
91
|
+
__napiInstance.exports['__napi_register____test_only_transfer_file_map_50']?.()
|
92
|
+
__napiInstance.exports['__napi_register__IS_WASM_51']?.()
|
93
|
+
}
|
94
|
+
export const HashPlanner = __napiModule.exports.HashPlanner
|
95
|
+
export const ImportResult = __napiModule.exports.ImportResult
|
96
|
+
export const TaskHasher = __napiModule.exports.TaskHasher
|
97
|
+
export const WorkspaceContext = __napiModule.exports.WorkspaceContext
|
98
|
+
export const copy = __napiModule.exports.copy
|
99
|
+
export const expandOutputs = __napiModule.exports.expandOutputs
|
100
|
+
export const findImports = __napiModule.exports.findImports
|
101
|
+
export const getFilesForOutputs = __napiModule.exports.getFilesForOutputs
|
102
|
+
export const hashArray = __napiModule.exports.hashArray
|
103
|
+
export const hashFile = __napiModule.exports.hashFile
|
104
|
+
export const IS_WASM = __napiModule.exports.IS_WASM
|
105
|
+
export const remove = __napiModule.exports.remove
|
106
|
+
export const testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
|
107
|
+
export const transferProjectGraph = __napiModule.exports.transferProjectGraph
|
108
|
+
export const WorkspaceErrors = __napiModule.exports.WorkspaceErrors
|
@@ -0,0 +1,139 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
/* prettier-ignore */
|
3
|
+
|
4
|
+
/* auto-generated by NAPI-RS */
|
5
|
+
|
6
|
+
const __nodeFs = require('node:fs')
|
7
|
+
const __nodePath = require('node:path')
|
8
|
+
const { WASI: __nodeWASI } = require('node:wasi')
|
9
|
+
const { Worker } = require('node:worker_threads')
|
10
|
+
|
11
|
+
const {
|
12
|
+
instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync,
|
13
|
+
getDefaultContext: __emnapiGetDefaultContext,
|
14
|
+
createOnMessage: __wasmCreateOnMessageForFsProxy,
|
15
|
+
} = require('@napi-rs/wasm-runtime')
|
16
|
+
|
17
|
+
const __rootDir = __nodePath.parse(process.cwd()).root
|
18
|
+
|
19
|
+
const __wasi = new __nodeWASI({
|
20
|
+
version: 'preview1',
|
21
|
+
env: process.env,
|
22
|
+
preopens: {
|
23
|
+
[__rootDir]: __rootDir,
|
24
|
+
}
|
25
|
+
})
|
26
|
+
|
27
|
+
const __emnapiContext = __emnapiGetDefaultContext()
|
28
|
+
|
29
|
+
const __sharedMemory = new WebAssembly.Memory({
|
30
|
+
initial: 16384,
|
31
|
+
maximum: 32768,
|
32
|
+
shared: true,
|
33
|
+
})
|
34
|
+
|
35
|
+
let __wasmFilePath = __nodePath.join(__dirname, 'nx.wasm32-wasi.wasm')
|
36
|
+
const __wasmDebugFilePath = __nodePath.join(__dirname, 'nx.wasm32-wasi.debug.wasm')
|
37
|
+
|
38
|
+
if (__nodeFs.existsSync(__wasmDebugFilePath)) {
|
39
|
+
__wasmFilePath = __wasmDebugFilePath
|
40
|
+
} else if (!__nodeFs.existsSync(__wasmFilePath)) {
|
41
|
+
try {
|
42
|
+
__wasmFilePath = __nodePath.resolve('@nx/nx-wasm32-wasi')
|
43
|
+
} catch {
|
44
|
+
throw new Error('Cannot find nx.wasm32-wasi.wasm file, and @nx/nx-wasm32-wasi package is not installed.')
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), {
|
49
|
+
context: __emnapiContext,
|
50
|
+
asyncWorkPoolSize: (function() {
|
51
|
+
const threadsSizeFromEnv = Number(process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ?? process.env.UV_THREADPOOL_SIZE)
|
52
|
+
// NaN > 0 is false
|
53
|
+
if (threadsSizeFromEnv > 0) {
|
54
|
+
return threadsSizeFromEnv
|
55
|
+
} else {
|
56
|
+
return 4
|
57
|
+
}
|
58
|
+
})(),
|
59
|
+
wasi: __wasi,
|
60
|
+
onCreateWorker() {
|
61
|
+
const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), {
|
62
|
+
env: process.env,
|
63
|
+
execArgv: ['--experimental-wasi-unstable-preview1'],
|
64
|
+
})
|
65
|
+
worker.onmessage = ({ data }) => {
|
66
|
+
__wasmCreateOnMessageForFsProxy(__nodeFs)(data)
|
67
|
+
}
|
68
|
+
return worker
|
69
|
+
},
|
70
|
+
overwriteImports(importObject) {
|
71
|
+
importObject.env = {
|
72
|
+
...importObject.env,
|
73
|
+
...importObject.napi,
|
74
|
+
...importObject.emnapi,
|
75
|
+
memory: __sharedMemory,
|
76
|
+
}
|
77
|
+
return importObject
|
78
|
+
},
|
79
|
+
beforeInit({ instance }) {
|
80
|
+
__napi_rs_initialize_modules(instance)
|
81
|
+
}
|
82
|
+
})
|
83
|
+
|
84
|
+
function __napi_rs_initialize_modules(__napiInstance) {
|
85
|
+
__napiInstance.exports['__napi_register__expand_outputs_0']?.()
|
86
|
+
__napiInstance.exports['__napi_register__get_files_for_outputs_1']?.()
|
87
|
+
__napiInstance.exports['__napi_register__remove_2']?.()
|
88
|
+
__napiInstance.exports['__napi_register__copy_3']?.()
|
89
|
+
__napiInstance.exports['__napi_register__hash_array_4']?.()
|
90
|
+
__napiInstance.exports['__napi_register__hash_file_5']?.()
|
91
|
+
__napiInstance.exports['__napi_register__ImportResult_struct_6']?.()
|
92
|
+
__napiInstance.exports['__napi_register__find_imports_7']?.()
|
93
|
+
__napiInstance.exports['__napi_register__transfer_project_graph_8']?.()
|
94
|
+
__napiInstance.exports['__napi_register__ExternalNode_struct_9']?.()
|
95
|
+
__napiInstance.exports['__napi_register__Target_struct_10']?.()
|
96
|
+
__napiInstance.exports['__napi_register__Project_struct_11']?.()
|
97
|
+
__napiInstance.exports['__napi_register__ProjectGraph_struct_12']?.()
|
98
|
+
__napiInstance.exports['__napi_register__HashPlanner_struct_13']?.()
|
99
|
+
__napiInstance.exports['__napi_register__HashPlanner_impl_17']?.()
|
100
|
+
__napiInstance.exports['__napi_register__HashDetails_struct_18']?.()
|
101
|
+
__napiInstance.exports['__napi_register__HasherOptions_struct_19']?.()
|
102
|
+
__napiInstance.exports['__napi_register__TaskHasher_struct_20']?.()
|
103
|
+
__napiInstance.exports['__napi_register__TaskHasher_impl_23']?.()
|
104
|
+
__napiInstance.exports['__napi_register__Task_struct_24']?.()
|
105
|
+
__napiInstance.exports['__napi_register__TaskTarget_struct_25']?.()
|
106
|
+
__napiInstance.exports['__napi_register__TaskGraph_struct_26']?.()
|
107
|
+
__napiInstance.exports['__napi_register__FileData_struct_27']?.()
|
108
|
+
__napiInstance.exports['__napi_register__InputsInput_struct_28']?.()
|
109
|
+
__napiInstance.exports['__napi_register__FileSetInput_struct_29']?.()
|
110
|
+
__napiInstance.exports['__napi_register__RuntimeInput_struct_30']?.()
|
111
|
+
__napiInstance.exports['__napi_register__EnvironmentInput_struct_31']?.()
|
112
|
+
__napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_32']?.()
|
113
|
+
__napiInstance.exports['__napi_register__DepsOutputsInput_struct_33']?.()
|
114
|
+
__napiInstance.exports['__napi_register__NxJson_struct_34']?.()
|
115
|
+
__napiInstance.exports['__napi_register__WorkspaceContext_struct_35']?.()
|
116
|
+
__napiInstance.exports['__napi_register__WorkspaceContext_impl_44']?.()
|
117
|
+
__napiInstance.exports['__napi_register__WorkspaceErrors_45']?.()
|
118
|
+
__napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_46']?.()
|
119
|
+
__napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_47']?.()
|
120
|
+
__napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_48']?.()
|
121
|
+
__napiInstance.exports['__napi_register__FileMap_struct_49']?.()
|
122
|
+
__napiInstance.exports['__napi_register____test_only_transfer_file_map_50']?.()
|
123
|
+
__napiInstance.exports['__napi_register__IS_WASM_51']?.()
|
124
|
+
}
|
125
|
+
module.exports.HashPlanner = __napiModule.exports.HashPlanner
|
126
|
+
module.exports.ImportResult = __napiModule.exports.ImportResult
|
127
|
+
module.exports.TaskHasher = __napiModule.exports.TaskHasher
|
128
|
+
module.exports.WorkspaceContext = __napiModule.exports.WorkspaceContext
|
129
|
+
module.exports.copy = __napiModule.exports.copy
|
130
|
+
module.exports.expandOutputs = __napiModule.exports.expandOutputs
|
131
|
+
module.exports.findImports = __napiModule.exports.findImports
|
132
|
+
module.exports.getFilesForOutputs = __napiModule.exports.getFilesForOutputs
|
133
|
+
module.exports.hashArray = __napiModule.exports.hashArray
|
134
|
+
module.exports.hashFile = __napiModule.exports.hashFile
|
135
|
+
module.exports.IS_WASM = __napiModule.exports.IS_WASM
|
136
|
+
module.exports.remove = __napiModule.exports.remove
|
137
|
+
module.exports.testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
|
138
|
+
module.exports.transferProjectGraph = __napiModule.exports.transferProjectGraph
|
139
|
+
module.exports.WorkspaceErrors = __napiModule.exports.WorkspaceErrors
|
Binary file
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
|
2
|
+
|
3
|
+
const handler = new MessageHandler({
|
4
|
+
onLoad({ wasmModule, wasmMemory }) {
|
5
|
+
const wasi = new WASI({
|
6
|
+
print: function () {
|
7
|
+
// eslint-disable-next-line no-console
|
8
|
+
console.log.apply(console, arguments)
|
9
|
+
},
|
10
|
+
printErr: function() {
|
11
|
+
// eslint-disable-next-line no-console
|
12
|
+
console.error.apply(console, arguments)
|
13
|
+
},
|
14
|
+
})
|
15
|
+
return instantiateNapiModuleSync(wasmModule, {
|
16
|
+
childThread: true,
|
17
|
+
wasi,
|
18
|
+
overwriteImports(importObject) {
|
19
|
+
importObject.env = {
|
20
|
+
...importObject.env,
|
21
|
+
...importObject.napi,
|
22
|
+
...importObject.emnapi,
|
23
|
+
memory: wasmMemory,
|
24
|
+
}
|
25
|
+
},
|
26
|
+
})
|
27
|
+
},
|
28
|
+
})
|
29
|
+
|
30
|
+
globalThis.onmessage = function (e) {
|
31
|
+
handler.handle(e)
|
32
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import fs from "node:fs";
|
2
|
+
import { createRequire } from "node:module";
|
3
|
+
import { parse } from "node:path";
|
4
|
+
import { WASI } from "node:wasi";
|
5
|
+
import { parentPort, Worker } from "node:worker_threads";
|
6
|
+
|
7
|
+
const require = createRequire(import.meta.url);
|
8
|
+
|
9
|
+
const { instantiateNapiModuleSync, MessageHandler, getDefaultContext } = require("@napi-rs/wasm-runtime");
|
10
|
+
|
11
|
+
if (parentPort) {
|
12
|
+
parentPort.on("message", (data) => {
|
13
|
+
globalThis.onmessage({ data });
|
14
|
+
});
|
15
|
+
}
|
16
|
+
|
17
|
+
Object.assign(globalThis, {
|
18
|
+
self: globalThis,
|
19
|
+
require,
|
20
|
+
Worker,
|
21
|
+
importScripts: function (f) {
|
22
|
+
;(0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f);
|
23
|
+
},
|
24
|
+
postMessage: function (msg) {
|
25
|
+
if (parentPort) {
|
26
|
+
parentPort.postMessage(msg);
|
27
|
+
}
|
28
|
+
},
|
29
|
+
});
|
30
|
+
|
31
|
+
const emnapiContext = getDefaultContext();
|
32
|
+
|
33
|
+
const __rootDir = parse(process.cwd()).root;
|
34
|
+
|
35
|
+
const handler = new MessageHandler({
|
36
|
+
onLoad({ wasmModule, wasmMemory }) {
|
37
|
+
const wasi = new WASI({
|
38
|
+
version: 'preview1',
|
39
|
+
env: process.env,
|
40
|
+
preopens: {
|
41
|
+
[__rootDir]: __rootDir,
|
42
|
+
},
|
43
|
+
});
|
44
|
+
|
45
|
+
return instantiateNapiModuleSync(wasmModule, {
|
46
|
+
childThread: true,
|
47
|
+
wasi,
|
48
|
+
context: emnapiContext,
|
49
|
+
overwriteImports(importObject) {
|
50
|
+
importObject.env = {
|
51
|
+
...importObject.env,
|
52
|
+
...importObject.napi,
|
53
|
+
...importObject.emnapi,
|
54
|
+
memory: wasmMemory
|
55
|
+
};
|
56
|
+
},
|
57
|
+
});
|
58
|
+
},
|
59
|
+
});
|
60
|
+
|
61
|
+
globalThis.onmessage = function (e) {
|
62
|
+
handler.handle(e);
|
63
|
+
};
|
@@ -79,13 +79,7 @@ function getSwcTranspiler(compilerOptions) {
|
|
79
79
|
return typeof cleanupFn === 'function' ? cleanupFn : () => { };
|
80
80
|
}
|
81
81
|
exports.getSwcTranspiler = getSwcTranspiler;
|
82
|
-
const registered = new Set();
|
83
82
|
function getTsNodeTranspiler(compilerOptions) {
|
84
|
-
// Just return if transpiler was already registered before.
|
85
|
-
const registrationKey = JSON.stringify(compilerOptions);
|
86
|
-
if (registered.has(registrationKey)) {
|
87
|
-
return () => { };
|
88
|
-
}
|
89
83
|
const { register } = require('ts-node');
|
90
84
|
// ts-node doesn't provide a cleanup method
|
91
85
|
const service = register({
|
@@ -94,7 +88,6 @@ function getTsNodeTranspiler(compilerOptions) {
|
|
94
88
|
// we already read and provide the compiler options, so prevent ts-node from reading them again
|
95
89
|
skipProject: true,
|
96
90
|
});
|
97
|
-
registered.add(registrationKey);
|
98
91
|
const { transpiler, swc } = service.options;
|
99
92
|
// Don't warn if a faster transpiler is enabled
|
100
93
|
if (!transpiler && !swc) {
|
@@ -147,6 +140,7 @@ function filterRecognizedTsConfigTsNodeOptions(jsonObject) {
|
|
147
140
|
const catchMissingProps = null;
|
148
141
|
return { recognized: filteredTsConfigOptions, unrecognized };
|
149
142
|
}
|
143
|
+
const registered = new Map();
|
150
144
|
function getTranspiler(compilerOptions, tsConfigRaw) {
|
151
145
|
const preferTsNode = process.env.NX_PREFER_TS_NODE === 'true';
|
152
146
|
if (!ts) {
|
@@ -160,13 +154,35 @@ function getTranspiler(compilerOptions, tsConfigRaw) {
|
|
160
154
|
compilerOptions.target = ts.ScriptTarget.ES2021;
|
161
155
|
compilerOptions.inlineSourceMap = true;
|
162
156
|
compilerOptions.skipLibCheck = true;
|
163
|
-
if
|
164
|
-
|
157
|
+
// Just return if transpiler was already registered before.
|
158
|
+
const registrationKey = JSON.stringify(compilerOptions);
|
159
|
+
const registrationEntry = registered.get(registrationKey);
|
160
|
+
if (registered.has(registrationKey)) {
|
161
|
+
registrationEntry.refCount++;
|
162
|
+
return registrationEntry.cleanup;
|
165
163
|
}
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
164
|
+
const _getTranspiler = swcNodeInstalled && !preferTsNode
|
165
|
+
? getSwcTranspiler
|
166
|
+
: tsNodeInstalled
|
167
|
+
? // We can fall back on ts-node if it's available
|
168
|
+
getTsNodeTranspiler
|
169
|
+
: undefined;
|
170
|
+
if (_getTranspiler) {
|
171
|
+
const transpilerCleanup = _getTranspiler(compilerOptions);
|
172
|
+
const currRegistrationEntry = {
|
173
|
+
refCount: 1,
|
174
|
+
cleanup: () => {
|
175
|
+
return () => {
|
176
|
+
currRegistrationEntry.refCount--;
|
177
|
+
if (currRegistrationEntry.refCount === 0) {
|
178
|
+
registered.delete(registrationKey);
|
179
|
+
transpilerCleanup();
|
180
|
+
}
|
181
|
+
};
|
182
|
+
},
|
183
|
+
};
|
184
|
+
registered.set(registrationKey, currRegistrationEntry);
|
185
|
+
return currRegistrationEntry.cleanup;
|
170
186
|
}
|
171
187
|
}
|
172
188
|
exports.getTranspiler = getTranspiler;
|
@@ -107,7 +107,6 @@ async function normalizePlugins(plugins, root) {
|
|
107
107
|
async function getDefaultPlugins(root) {
|
108
108
|
return [
|
109
109
|
(0, path_1.join)(__dirname, '../../plugins/js'),
|
110
|
-
(0, path_1.join)(__dirname, '../../plugins/target-defaults/target-defaults-plugin'),
|
111
110
|
...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
|
112
111
|
? [(0, path_1.join)(__dirname, '../../adapter/angular-json')]
|
113
112
|
: []),
|
@@ -1,15 +1,10 @@
|
|
1
1
|
import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json';
|
2
2
|
import { ProjectGraphExternalNode } from '../../config/project-graph';
|
3
3
|
import { ProjectConfiguration, ProjectMetadata, TargetConfiguration, TargetMetadata } from '../../config/workspace-json-project-json';
|
4
|
-
import { ONLY_MODIFIES_EXISTING_TARGET } from '../../plugins/target-defaults/symbols';
|
5
4
|
import { LoadedNxPlugin } from '../plugins/internal-api';
|
6
5
|
export type SourceInformation = [file: string | null, plugin: string];
|
7
6
|
export type ConfigurationSourceMaps = Record<string, Record<string, SourceInformation>>;
|
8
|
-
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Record<string, ProjectConfiguration>, project: ProjectConfiguration
|
9
|
-
targets?: Record<string, TargetConfiguration & {
|
10
|
-
[ONLY_MODIFIES_EXISTING_TARGET]?: boolean;
|
11
|
-
}>;
|
12
|
-
}, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation, skipTargetNormalization?: boolean): void;
|
7
|
+
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Record<string, ProjectConfiguration>, project: ProjectConfiguration, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation, skipTargetNormalization?: boolean): void;
|
13
8
|
export declare function mergeMetadata<T = ProjectMetadata | TargetMetadata>(sourceMap: Record<string, [file: string, plugin: string]>, sourceInformation: [file: string, plugin: string], baseSourceMapPath: string, metadata: T, matchingMetadata?: T): T;
|
14
9
|
export type ConfigurationResult = {
|
15
10
|
/**
|
@@ -44,6 +39,7 @@ export declare function createProjectConfigurations(root: string, nxJson: NxJson
|
|
44
39
|
plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
|
45
40
|
export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
|
46
41
|
export declare function validateProject(project: ProjectConfiguration, knownProjects: Record<string, ProjectConfiguration>): void;
|
42
|
+
export declare function mergeTargetDefaultWithTargetDefinition(targetName: string, project: ProjectConfiguration, targetDefault: Partial<TargetConfiguration>, sourceMap: Record<string, SourceInformation>): TargetConfiguration;
|
47
43
|
/**
|
48
44
|
* Merges two targets.
|
49
45
|
*
|
@@ -68,4 +64,10 @@ export declare function mergeTargetConfigurations(target: TargetConfiguration, b
|
|
68
64
|
export declare function isCompatibleTarget(a: TargetConfiguration, b: TargetConfiguration): boolean;
|
69
65
|
export declare function resolveNxTokensInOptions<T extends Object | Array<unknown>>(object: T, project: ProjectConfiguration, key: string): T;
|
70
66
|
export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];
|
67
|
+
/**
|
68
|
+
* Expand's `command` syntactic sugar and replaces tokens in options.
|
69
|
+
* @param target The target to normalize
|
70
|
+
* @param project The project that the target belongs to
|
71
|
+
* @returns The normalized target configuration
|
72
|
+
*/
|
71
73
|
export declare function normalizeTarget(target: TargetConfiguration, project: ProjectConfiguration): TargetConfiguration<any>;
|