nx 21.2.0-beta.2 → 21.2.0-beta.3

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.
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[869],{932:()=>{}},s=>{var e;e=932,s(s.s=e)}]);
1
+ "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[869],{5873:()=>{}},s=>{var e;e=5873,s(s.s=e)}]);
@@ -73,6 +73,12 @@ export declare class NxCache {
73
73
  checkCacheFsInSync(): boolean
74
74
  }
75
75
 
76
+ export declare class NxConsolePreferences {
77
+ constructor(homeDir: string)
78
+ getAutoInstallPreference(): boolean | null
79
+ setAutoInstallPreference(autoInstall: boolean): void
80
+ }
81
+
76
82
  export declare class NxTaskHistory {
77
83
  constructor(db: ExternalObject<NxDbConnection>)
78
84
  recordTaskRuns(taskRuns: Array<TaskRun>): void
@@ -148,6 +154,8 @@ export interface CachedResult {
148
154
  size?: number
149
155
  }
150
156
 
157
+ export declare export declare function canInstallNxConsole(): boolean
158
+
151
159
  export declare export declare function closeDbConnection(connection: ExternalObject<NxDbConnection>): void
152
160
 
153
161
  export declare export declare function connectToNxDb(cacheDir: string, nxVersion: string, dbName?: string | undefined | null): ExternalObject<NxDbConnection>
@@ -235,11 +243,13 @@ export interface InputsInput {
235
243
  projects?: string | Array<string>
236
244
  }
237
245
 
246
+ export declare export declare function installNxConsole(): void
247
+
238
248
  export const IS_WASM: boolean
239
249
 
240
- export declare export declare function logError(message: string): void
250
+ export declare export declare function logDebug(message: string): void
241
251
 
242
- export declare export declare function logInfo(message: string): void
252
+ export declare export declare function logError(message: string): void
243
253
 
244
254
  /** Stripped version of the NxJson interface for use in rust */
245
255
  export interface NxJson {
@@ -368,6 +368,7 @@ module.exports.HashPlanner = nativeBinding.HashPlanner
368
368
  module.exports.HttpRemoteCache = nativeBinding.HttpRemoteCache
369
369
  module.exports.ImportResult = nativeBinding.ImportResult
370
370
  module.exports.NxCache = nativeBinding.NxCache
371
+ module.exports.NxConsolePreferences = nativeBinding.NxConsolePreferences
371
372
  module.exports.NxTaskHistory = nativeBinding.NxTaskHistory
372
373
  module.exports.RunningTasksService = nativeBinding.RunningTasksService
373
374
  module.exports.RustPseudoTerminal = nativeBinding.RustPseudoTerminal
@@ -375,6 +376,7 @@ module.exports.TaskDetails = nativeBinding.TaskDetails
375
376
  module.exports.TaskHasher = nativeBinding.TaskHasher
376
377
  module.exports.Watcher = nativeBinding.Watcher
377
378
  module.exports.WorkspaceContext = nativeBinding.WorkspaceContext
379
+ module.exports.canInstallNxConsole = nativeBinding.canInstallNxConsole
378
380
  module.exports.closeDbConnection = nativeBinding.closeDbConnection
379
381
  module.exports.connectToNxDb = nativeBinding.connectToNxDb
380
382
  module.exports.copy = nativeBinding.copy
@@ -387,9 +389,10 @@ module.exports.getFilesForOutputs = nativeBinding.getFilesForOutputs
387
389
  module.exports.getTransformableOutputs = nativeBinding.getTransformableOutputs
388
390
  module.exports.hashArray = nativeBinding.hashArray
389
391
  module.exports.hashFile = nativeBinding.hashFile
392
+ module.exports.installNxConsole = nativeBinding.installNxConsole
390
393
  module.exports.IS_WASM = nativeBinding.IS_WASM
394
+ module.exports.logDebug = nativeBinding.logDebug
391
395
  module.exports.logError = nativeBinding.logError
392
- module.exports.logInfo = nativeBinding.logInfo
393
396
  module.exports.parseTaskStatus = nativeBinding.parseTaskStatus
394
397
  module.exports.remove = nativeBinding.remove
395
398
  module.exports.restoreTerminal = nativeBinding.restoreTerminal
@@ -59,51 +59,57 @@ function __napi_rs_initialize_modules(__napiInstance) {
59
59
  __napiInstance.exports['__napi_register__get_transformable_outputs_5']?.()
60
60
  __napiInstance.exports['__napi_register__hash_array_6']?.()
61
61
  __napiInstance.exports['__napi_register__hash_file_7']?.()
62
- __napiInstance.exports['__napi_register__log_info_8']?.()
63
- __napiInstance.exports['__napi_register__log_error_9']?.()
64
- __napiInstance.exports['__napi_register__IS_WASM_10']?.()
65
- __napiInstance.exports['__napi_register__get_binary_target_11']?.()
66
- __napiInstance.exports['__napi_register__ImportResult_struct_12']?.()
67
- __napiInstance.exports['__napi_register__find_imports_13']?.()
68
- __napiInstance.exports['__napi_register__transfer_project_graph_14']?.()
69
- __napiInstance.exports['__napi_register__ExternalNode_struct_15']?.()
70
- __napiInstance.exports['__napi_register__Target_struct_16']?.()
71
- __napiInstance.exports['__napi_register__Project_struct_17']?.()
72
- __napiInstance.exports['__napi_register__ProjectGraph_struct_18']?.()
73
- __napiInstance.exports['__napi_register__HashPlanner_struct_19']?.()
74
- __napiInstance.exports['__napi_register__HashPlanner_impl_23']?.()
75
- __napiInstance.exports['__napi_register__HashDetails_struct_24']?.()
76
- __napiInstance.exports['__napi_register__HasherOptions_struct_25']?.()
77
- __napiInstance.exports['__napi_register__TaskHasher_struct_26']?.()
78
- __napiInstance.exports['__napi_register__TaskHasher_impl_29']?.()
79
- __napiInstance.exports['__napi_register__Task_struct_30']?.()
80
- __napiInstance.exports['__napi_register__TaskTarget_struct_31']?.()
81
- __napiInstance.exports['__napi_register__TaskResult_struct_32']?.()
82
- __napiInstance.exports['__napi_register__TaskGraph_struct_33']?.()
83
- __napiInstance.exports['__napi_register__FileData_struct_34']?.()
84
- __napiInstance.exports['__napi_register__InputsInput_struct_35']?.()
85
- __napiInstance.exports['__napi_register__FileSetInput_struct_36']?.()
86
- __napiInstance.exports['__napi_register__RuntimeInput_struct_37']?.()
87
- __napiInstance.exports['__napi_register__EnvironmentInput_struct_38']?.()
88
- __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_39']?.()
89
- __napiInstance.exports['__napi_register__DepsOutputsInput_struct_40']?.()
90
- __napiInstance.exports['__napi_register__NxJson_struct_41']?.()
91
- __napiInstance.exports['__napi_register__FileLock_struct_42']?.()
92
- __napiInstance.exports['__napi_register__FileLock_impl_44']?.()
93
- __napiInstance.exports['__napi_register__WorkspaceContext_struct_45']?.()
94
- __napiInstance.exports['__napi_register__WorkspaceContext_impl_56']?.()
95
- __napiInstance.exports['__napi_register__WorkspaceErrors_57']?.()
96
- __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_58']?.()
97
- __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_59']?.()
98
- __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_60']?.()
99
- __napiInstance.exports['__napi_register__FileMap_struct_61']?.()
100
- __napiInstance.exports['__napi_register____test_only_transfer_file_map_62']?.()
62
+ __napiInstance.exports['__napi_register__can_install_nx_console_8']?.()
63
+ __napiInstance.exports['__napi_register__install_nx_console_9']?.()
64
+ __napiInstance.exports['__napi_register__NxConsolePreferences_struct_10']?.()
65
+ __napiInstance.exports['__napi_register__NxConsolePreferences_impl_14']?.()
66
+ __napiInstance.exports['__napi_register__log_debug_15']?.()
67
+ __napiInstance.exports['__napi_register__log_error_16']?.()
68
+ __napiInstance.exports['__napi_register__IS_WASM_17']?.()
69
+ __napiInstance.exports['__napi_register__get_binary_target_18']?.()
70
+ __napiInstance.exports['__napi_register__ImportResult_struct_19']?.()
71
+ __napiInstance.exports['__napi_register__find_imports_20']?.()
72
+ __napiInstance.exports['__napi_register__transfer_project_graph_21']?.()
73
+ __napiInstance.exports['__napi_register__ExternalNode_struct_22']?.()
74
+ __napiInstance.exports['__napi_register__Target_struct_23']?.()
75
+ __napiInstance.exports['__napi_register__Project_struct_24']?.()
76
+ __napiInstance.exports['__napi_register__ProjectGraph_struct_25']?.()
77
+ __napiInstance.exports['__napi_register__HashPlanner_struct_26']?.()
78
+ __napiInstance.exports['__napi_register__HashPlanner_impl_30']?.()
79
+ __napiInstance.exports['__napi_register__HashDetails_struct_31']?.()
80
+ __napiInstance.exports['__napi_register__HasherOptions_struct_32']?.()
81
+ __napiInstance.exports['__napi_register__TaskHasher_struct_33']?.()
82
+ __napiInstance.exports['__napi_register__TaskHasher_impl_36']?.()
83
+ __napiInstance.exports['__napi_register__Task_struct_37']?.()
84
+ __napiInstance.exports['__napi_register__TaskTarget_struct_38']?.()
85
+ __napiInstance.exports['__napi_register__TaskResult_struct_39']?.()
86
+ __napiInstance.exports['__napi_register__TaskGraph_struct_40']?.()
87
+ __napiInstance.exports['__napi_register__FileData_struct_41']?.()
88
+ __napiInstance.exports['__napi_register__InputsInput_struct_42']?.()
89
+ __napiInstance.exports['__napi_register__FileSetInput_struct_43']?.()
90
+ __napiInstance.exports['__napi_register__RuntimeInput_struct_44']?.()
91
+ __napiInstance.exports['__napi_register__EnvironmentInput_struct_45']?.()
92
+ __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_46']?.()
93
+ __napiInstance.exports['__napi_register__DepsOutputsInput_struct_47']?.()
94
+ __napiInstance.exports['__napi_register__NxJson_struct_48']?.()
95
+ __napiInstance.exports['__napi_register__FileLock_struct_49']?.()
96
+ __napiInstance.exports['__napi_register__FileLock_impl_51']?.()
97
+ __napiInstance.exports['__napi_register__WorkspaceContext_struct_52']?.()
98
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_63']?.()
99
+ __napiInstance.exports['__napi_register__WorkspaceErrors_64']?.()
100
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_65']?.()
101
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_66']?.()
102
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_67']?.()
103
+ __napiInstance.exports['__napi_register__FileMap_struct_68']?.()
104
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_69']?.()
101
105
  }
102
106
  export const FileLock = __napiModule.exports.FileLock
103
107
  export const HashPlanner = __napiModule.exports.HashPlanner
104
108
  export const ImportResult = __napiModule.exports.ImportResult
109
+ export const NxConsolePreferences = __napiModule.exports.NxConsolePreferences
105
110
  export const TaskHasher = __napiModule.exports.TaskHasher
106
111
  export const WorkspaceContext = __napiModule.exports.WorkspaceContext
112
+ export const canInstallNxConsole = __napiModule.exports.canInstallNxConsole
107
113
  export const copy = __napiModule.exports.copy
108
114
  export const expandOutputs = __napiModule.exports.expandOutputs
109
115
  export const findImports = __napiModule.exports.findImports
@@ -112,9 +118,10 @@ export const getFilesForOutputs = __napiModule.exports.getFilesForOutputs
112
118
  export const getTransformableOutputs = __napiModule.exports.getTransformableOutputs
113
119
  export const hashArray = __napiModule.exports.hashArray
114
120
  export const hashFile = __napiModule.exports.hashFile
121
+ export const installNxConsole = __napiModule.exports.installNxConsole
115
122
  export const IS_WASM = __napiModule.exports.IS_WASM
123
+ export const logDebug = __napiModule.exports.logDebug
116
124
  export const logError = __napiModule.exports.logError
117
- export const logInfo = __napiModule.exports.logInfo
118
125
  export const remove = __napiModule.exports.remove
119
126
  export const testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
120
127
  export const transferProjectGraph = __napiModule.exports.transferProjectGraph
@@ -90,51 +90,57 @@ function __napi_rs_initialize_modules(__napiInstance) {
90
90
  __napiInstance.exports['__napi_register__get_transformable_outputs_5']?.()
91
91
  __napiInstance.exports['__napi_register__hash_array_6']?.()
92
92
  __napiInstance.exports['__napi_register__hash_file_7']?.()
93
- __napiInstance.exports['__napi_register__log_info_8']?.()
94
- __napiInstance.exports['__napi_register__log_error_9']?.()
95
- __napiInstance.exports['__napi_register__IS_WASM_10']?.()
96
- __napiInstance.exports['__napi_register__get_binary_target_11']?.()
97
- __napiInstance.exports['__napi_register__ImportResult_struct_12']?.()
98
- __napiInstance.exports['__napi_register__find_imports_13']?.()
99
- __napiInstance.exports['__napi_register__transfer_project_graph_14']?.()
100
- __napiInstance.exports['__napi_register__ExternalNode_struct_15']?.()
101
- __napiInstance.exports['__napi_register__Target_struct_16']?.()
102
- __napiInstance.exports['__napi_register__Project_struct_17']?.()
103
- __napiInstance.exports['__napi_register__ProjectGraph_struct_18']?.()
104
- __napiInstance.exports['__napi_register__HashPlanner_struct_19']?.()
105
- __napiInstance.exports['__napi_register__HashPlanner_impl_23']?.()
106
- __napiInstance.exports['__napi_register__HashDetails_struct_24']?.()
107
- __napiInstance.exports['__napi_register__HasherOptions_struct_25']?.()
108
- __napiInstance.exports['__napi_register__TaskHasher_struct_26']?.()
109
- __napiInstance.exports['__napi_register__TaskHasher_impl_29']?.()
110
- __napiInstance.exports['__napi_register__Task_struct_30']?.()
111
- __napiInstance.exports['__napi_register__TaskTarget_struct_31']?.()
112
- __napiInstance.exports['__napi_register__TaskResult_struct_32']?.()
113
- __napiInstance.exports['__napi_register__TaskGraph_struct_33']?.()
114
- __napiInstance.exports['__napi_register__FileData_struct_34']?.()
115
- __napiInstance.exports['__napi_register__InputsInput_struct_35']?.()
116
- __napiInstance.exports['__napi_register__FileSetInput_struct_36']?.()
117
- __napiInstance.exports['__napi_register__RuntimeInput_struct_37']?.()
118
- __napiInstance.exports['__napi_register__EnvironmentInput_struct_38']?.()
119
- __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_39']?.()
120
- __napiInstance.exports['__napi_register__DepsOutputsInput_struct_40']?.()
121
- __napiInstance.exports['__napi_register__NxJson_struct_41']?.()
122
- __napiInstance.exports['__napi_register__FileLock_struct_42']?.()
123
- __napiInstance.exports['__napi_register__FileLock_impl_44']?.()
124
- __napiInstance.exports['__napi_register__WorkspaceContext_struct_45']?.()
125
- __napiInstance.exports['__napi_register__WorkspaceContext_impl_56']?.()
126
- __napiInstance.exports['__napi_register__WorkspaceErrors_57']?.()
127
- __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_58']?.()
128
- __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_59']?.()
129
- __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_60']?.()
130
- __napiInstance.exports['__napi_register__FileMap_struct_61']?.()
131
- __napiInstance.exports['__napi_register____test_only_transfer_file_map_62']?.()
93
+ __napiInstance.exports['__napi_register__can_install_nx_console_8']?.()
94
+ __napiInstance.exports['__napi_register__install_nx_console_9']?.()
95
+ __napiInstance.exports['__napi_register__NxConsolePreferences_struct_10']?.()
96
+ __napiInstance.exports['__napi_register__NxConsolePreferences_impl_14']?.()
97
+ __napiInstance.exports['__napi_register__log_debug_15']?.()
98
+ __napiInstance.exports['__napi_register__log_error_16']?.()
99
+ __napiInstance.exports['__napi_register__IS_WASM_17']?.()
100
+ __napiInstance.exports['__napi_register__get_binary_target_18']?.()
101
+ __napiInstance.exports['__napi_register__ImportResult_struct_19']?.()
102
+ __napiInstance.exports['__napi_register__find_imports_20']?.()
103
+ __napiInstance.exports['__napi_register__transfer_project_graph_21']?.()
104
+ __napiInstance.exports['__napi_register__ExternalNode_struct_22']?.()
105
+ __napiInstance.exports['__napi_register__Target_struct_23']?.()
106
+ __napiInstance.exports['__napi_register__Project_struct_24']?.()
107
+ __napiInstance.exports['__napi_register__ProjectGraph_struct_25']?.()
108
+ __napiInstance.exports['__napi_register__HashPlanner_struct_26']?.()
109
+ __napiInstance.exports['__napi_register__HashPlanner_impl_30']?.()
110
+ __napiInstance.exports['__napi_register__HashDetails_struct_31']?.()
111
+ __napiInstance.exports['__napi_register__HasherOptions_struct_32']?.()
112
+ __napiInstance.exports['__napi_register__TaskHasher_struct_33']?.()
113
+ __napiInstance.exports['__napi_register__TaskHasher_impl_36']?.()
114
+ __napiInstance.exports['__napi_register__Task_struct_37']?.()
115
+ __napiInstance.exports['__napi_register__TaskTarget_struct_38']?.()
116
+ __napiInstance.exports['__napi_register__TaskResult_struct_39']?.()
117
+ __napiInstance.exports['__napi_register__TaskGraph_struct_40']?.()
118
+ __napiInstance.exports['__napi_register__FileData_struct_41']?.()
119
+ __napiInstance.exports['__napi_register__InputsInput_struct_42']?.()
120
+ __napiInstance.exports['__napi_register__FileSetInput_struct_43']?.()
121
+ __napiInstance.exports['__napi_register__RuntimeInput_struct_44']?.()
122
+ __napiInstance.exports['__napi_register__EnvironmentInput_struct_45']?.()
123
+ __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_46']?.()
124
+ __napiInstance.exports['__napi_register__DepsOutputsInput_struct_47']?.()
125
+ __napiInstance.exports['__napi_register__NxJson_struct_48']?.()
126
+ __napiInstance.exports['__napi_register__FileLock_struct_49']?.()
127
+ __napiInstance.exports['__napi_register__FileLock_impl_51']?.()
128
+ __napiInstance.exports['__napi_register__WorkspaceContext_struct_52']?.()
129
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_63']?.()
130
+ __napiInstance.exports['__napi_register__WorkspaceErrors_64']?.()
131
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_65']?.()
132
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_66']?.()
133
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_67']?.()
134
+ __napiInstance.exports['__napi_register__FileMap_struct_68']?.()
135
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_69']?.()
132
136
  }
133
137
  module.exports.FileLock = __napiModule.exports.FileLock
134
138
  module.exports.HashPlanner = __napiModule.exports.HashPlanner
135
139
  module.exports.ImportResult = __napiModule.exports.ImportResult
140
+ module.exports.NxConsolePreferences = __napiModule.exports.NxConsolePreferences
136
141
  module.exports.TaskHasher = __napiModule.exports.TaskHasher
137
142
  module.exports.WorkspaceContext = __napiModule.exports.WorkspaceContext
143
+ module.exports.canInstallNxConsole = __napiModule.exports.canInstallNxConsole
138
144
  module.exports.copy = __napiModule.exports.copy
139
145
  module.exports.expandOutputs = __napiModule.exports.expandOutputs
140
146
  module.exports.findImports = __napiModule.exports.findImports
@@ -143,9 +149,10 @@ module.exports.getFilesForOutputs = __napiModule.exports.getFilesForOutputs
143
149
  module.exports.getTransformableOutputs = __napiModule.exports.getTransformableOutputs
144
150
  module.exports.hashArray = __napiModule.exports.hashArray
145
151
  module.exports.hashFile = __napiModule.exports.hashFile
152
+ module.exports.installNxConsole = __napiModule.exports.installNxConsole
146
153
  module.exports.IS_WASM = __napiModule.exports.IS_WASM
154
+ module.exports.logDebug = __napiModule.exports.logDebug
147
155
  module.exports.logError = __napiModule.exports.logError
148
- module.exports.logInfo = __napiModule.exports.logInfo
149
156
  module.exports.remove = __napiModule.exports.remove
150
157
  module.exports.testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
151
158
  module.exports.transferProjectGraph = __napiModule.exports.transferProjectGraph
Binary file
@@ -9,6 +9,7 @@ const object_sort_1 = require("../../../utils/object-sort");
9
9
  const project_graph_builder_1 = require("../../../project-graph/project-graph-builder");
10
10
  const project_graph_1 = require("../../../config/project-graph");
11
11
  const file_hasher_1 = require("../../../hasher/file-hasher");
12
+ const project_graph_pruning_1 = require("./project-graph-pruning");
12
13
  // we use key => node map to avoid duplicate work when parsing keys
13
14
  let keyMap = new Map();
14
15
  let currentLockFileHash;
@@ -278,7 +279,7 @@ function parseBaseVersion(rawVersion, isV5) {
278
279
  function stringifyPnpmLockfile(graph, rootLockFileContent, packageJson) {
279
280
  const data = (0, pnpm_normalizer_1.parseAndNormalizePnpmLockfile)(rootLockFileContent);
280
281
  const { lockfileVersion, packages } = data;
281
- const rootSnapshot = mapRootSnapshot(packageJson, packages, graph.externalNodes, +lockfileVersion);
282
+ const rootSnapshot = mapRootSnapshot(packageJson, packages, graph, +lockfileVersion);
282
283
  const snapshots = mapSnapshots(data.packages, graph.externalNodes, +lockfileVersion);
283
284
  const output = {
284
285
  ...data,
@@ -397,7 +398,7 @@ function versionIsAlias(key, versionExpr, lockfileVersion) {
397
398
  ? key.startsWith(`${packageName}/${version}`)
398
399
  : key.startsWith(`${packageName}@${version}`);
399
400
  }
400
- function mapRootSnapshot(packageJson, packages, nodes, lockfileVersion) {
401
+ function mapRootSnapshot(packageJson, packages, graph, lockfileVersion) {
401
402
  const snapshot = { specifiers: {} };
402
403
  [
403
404
  'dependencies',
@@ -408,7 +409,14 @@ function mapRootSnapshot(packageJson, packages, nodes, lockfileVersion) {
408
409
  if (packageJson[depType]) {
409
410
  Object.keys(packageJson[depType]).forEach((packageName) => {
410
411
  const version = packageJson[depType][packageName];
411
- const node = nodes[`npm:${packageName}@${version}`] || nodes[`npm:${packageName}`];
412
+ const node = graph.externalNodes[`npm:${packageName}@${version}`] ||
413
+ (graph.externalNodes[`npm:${packageName}`] &&
414
+ graph.externalNodes[`npm:${packageName}`].data.version === version
415
+ ? graph.externalNodes[`npm:${packageName}`]
416
+ : (0, project_graph_pruning_1.findNodeMatchingVersion)(graph, packageName, version));
417
+ if (!node) {
418
+ throw new Error(`Could not find external node for package ${packageName}@${version}.`);
419
+ }
412
420
  snapshot.specifiers[packageName] = version;
413
421
  // peer dependencies are mapped to dependencies
414
422
  let section = depType === 'peerDependencies' ? 'dependencies' : depType;
@@ -1,7 +1,8 @@
1
- import { ProjectGraph } from '../../../config/project-graph';
1
+ import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
2
2
  import { PackageJson } from '../../../utils/package-json';
3
3
  /**
4
4
  * Prune project graph's external nodes and their dependencies
5
5
  * based on the pruned package.json
6
6
  */
7
7
  export declare function pruneProjectGraph(graph: ProjectGraph, prunedPackageJson: PackageJson): ProjectGraph;
8
+ export declare function findNodeMatchingVersion(graph: ProjectGraph, packageName: string, versionExpr: string): ProjectGraphExternalNode;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.pruneProjectGraph = pruneProjectGraph;
4
+ exports.findNodeMatchingVersion = findNodeMatchingVersion;
4
5
  const semver_1 = require("semver");
5
6
  const project_graph_builder_1 = require("../../../project-graph/project-graph-builder");
6
7
  const operators_1 = require("../../../project-graph/operators");
@@ -92,6 +93,9 @@ function rehoistNodes(graph, packageJsonDeps, builder) {
92
93
  }
93
94
  }
94
95
  });
96
+ if (!packagesToRehoist.size) {
97
+ return;
98
+ }
95
99
  // invert dependencies for easier traversal back
96
100
  const invertedGraph = (0, operators_1.reverse)(builder.graph);
97
101
  const invBuilder = new project_graph_builder_1.ProjectGraphBuilder(invertedGraph, {});
@@ -90,9 +90,8 @@ class TargetProjectLocator {
90
90
  return externalProject;
91
91
  }
92
92
  if (this.tsConfig.config) {
93
- // TODO(meeroslav): this block is probably obsolete
94
- // and existed only because of the incomplete `paths` matching
95
- // if import cannot be matched using tsconfig `paths` the compilation would fail anyway
93
+ // TODO: this can be removed once we rework resolveImportWithRequire below
94
+ // to properly handle ESM (exports, imports, conditions)
96
95
  const resolvedProject = this.resolveImportWithTypescript(importExpr, filePath);
97
96
  if (resolvedProject) {
98
97
  return resolvedProject;
@@ -256,21 +255,32 @@ class TargetProjectLocator {
256
255
  }
257
256
  resolveImportWithTypescript(normalizedImportExpr, filePath) {
258
257
  let resolvedModule;
259
- if (this.typescriptResolutionCache.has(normalizedImportExpr)) {
260
- resolvedModule = this.typescriptResolutionCache.get(normalizedImportExpr);
258
+ const projectName = (0, find_project_for_path_1.findProjectForPath)(filePath, this.projectRootMappings);
259
+ const cacheScope = projectName
260
+ ? // fall back to the project name if the project root can't be determined
261
+ this.nodes[projectName]?.data?.root || projectName
262
+ : // fall back to the file path if the project can't be determined
263
+ filePath;
264
+ const cacheKey = `${normalizedImportExpr}__${cacheScope}`;
265
+ if (this.typescriptResolutionCache.has(cacheKey)) {
266
+ resolvedModule = this.typescriptResolutionCache.get(cacheKey);
261
267
  }
262
268
  else {
263
269
  resolvedModule = (0, typescript_1.resolveModuleByImport)(normalizedImportExpr, filePath, this.tsConfig.absolutePath);
264
- this.typescriptResolutionCache.set(normalizedImportExpr, resolvedModule ? resolvedModule : null);
270
+ this.typescriptResolutionCache.set(cacheKey, resolvedModule ? resolvedModule : null);
265
271
  }
266
- // TODO: vsavkin temporary workaround. Remove it once we reworking handling of npm packages.
267
- if (resolvedModule && resolvedModule.indexOf('node_modules/') === -1) {
272
+ if (!resolvedModule) {
273
+ return;
274
+ }
275
+ const nodeModulesIndex = resolvedModule.lastIndexOf('node_modules/');
276
+ if (nodeModulesIndex === -1) {
268
277
  const resolvedProject = this.findProjectOfResolvedModule(resolvedModule);
269
- if (resolvedProject) {
270
- return resolvedProject;
271
- }
278
+ return resolvedProject;
272
279
  }
273
- return;
280
+ // strip the node_modules/ prefix from the resolved module path
281
+ const packagePath = resolvedModule.substring(nodeModulesIndex + 'node_modules/'.length);
282
+ const externalProject = this.findNpmProjectFromImport(packagePath, filePath);
283
+ return externalProject;
274
284
  }
275
285
  resolveImportWithRequire(normalizedImportExpr, filePath) {
276
286
  return (0, node_path_1.relative)(workspace_root_1.workspaceRoot, require.resolve(normalizedImportExpr, {
@@ -1,3 +1,4 @@
1
+ import type { TsConfigOptions } from 'ts-node';
1
2
  import type { CompilerOptions } from 'typescript';
2
3
  /**
3
4
  * Optionally, if swc-node and tsconfig-paths are available in the current workspace, apply the require
@@ -23,7 +24,7 @@ export declare function registerTsProject(tsConfigPath: string): () => void;
23
24
  */
24
25
  export declare function registerTsProject(path: string, configFilename: string): any;
25
26
  export declare function getSwcTranspiler(compilerOptions: CompilerOptions): (...args: unknown[]) => unknown;
26
- export declare function getTsNodeTranspiler(compilerOptions: CompilerOptions): (...args: unknown[]) => unknown;
27
+ export declare function getTsNodeTranspiler(compilerOptions: CompilerOptions, tsNodeOptions?: TsConfigOptions): (...args: unknown[]) => unknown;
27
28
  export declare function getTranspiler(compilerOptions: CompilerOptions, tsConfigRaw?: unknown): () => (...args: unknown[]) => unknown;
28
29
  /**
29
30
  * Register ts-node or swc-node given a set of compiler options.
@@ -33,7 +34,7 @@ export declare function getTranspiler(compilerOptions: CompilerOptions, tsConfig
33
34
  *
34
35
  * @returns cleanup method
35
36
  */
36
- export declare function registerTranspiler(compilerOptions: CompilerOptions): () => void;
37
+ export declare function registerTranspiler(compilerOptions: CompilerOptions, tsConfigRaw?: unknown): () => void;
37
38
  /**
38
39
  * @param tsConfigPath Adds the paths from a tsconfig file into node resolutions
39
40
  * @returns cleanup function
@@ -9,6 +9,7 @@ exports.registerTsConfigPaths = registerTsConfigPaths;
9
9
  exports.getTsNodeCompilerOptions = getTsNodeCompilerOptions;
10
10
  const path_1 = require("path");
11
11
  const logger_1 = require("../../../utils/logger");
12
+ const typescript_1 = require("./typescript");
12
13
  const swcNodeInstalled = packageIsInstalled('@swc-node/register');
13
14
  const tsNodeInstalled = packageIsInstalled('ts-node/register');
14
15
  let ts;
@@ -53,10 +54,10 @@ function registerTsProject(path, configFilename) {
53
54
  return () => { };
54
55
  }
55
56
  const tsConfigPath = configFilename ? (0, path_1.join)(path, configFilename) : path;
56
- const compilerOptions = readCompilerOptions(tsConfigPath);
57
+ const { compilerOptions, tsConfigRaw } = readCompilerOptions(tsConfigPath);
57
58
  const cleanupFunctions = [
58
59
  registerTsConfigPaths(tsConfigPath),
59
- registerTranspiler(compilerOptions),
60
+ registerTranspiler(compilerOptions, tsConfigRaw),
60
61
  ];
61
62
  // Add ESM support for `.ts` files.
62
63
  // NOTE: There is no cleanup function for this, as it's not possible to unregister the loader.
@@ -90,12 +91,16 @@ function getSwcTranspiler(compilerOptions) {
90
91
  const cleanupFn = register(compilerOptions);
91
92
  return typeof cleanupFn === 'function' ? cleanupFn : () => { };
92
93
  }
93
- function getTsNodeTranspiler(compilerOptions) {
94
+ function getTsNodeTranspiler(compilerOptions, tsNodeOptions) {
94
95
  const { register } = require('ts-node');
95
96
  // ts-node doesn't provide a cleanup method
96
97
  const service = register({
98
+ ...tsNodeOptions,
97
99
  transpileOnly: true,
98
- compilerOptions: getTsNodeCompilerOptions(compilerOptions),
100
+ compilerOptions: getTsNodeCompilerOptions({
101
+ ...tsNodeOptions?.compilerOptions,
102
+ ...compilerOptions,
103
+ }),
99
104
  // we already read and provide the compiler options, so prevent ts-node from reading them again
100
105
  skipProject: true,
101
106
  });
@@ -165,21 +170,30 @@ function getTranspiler(compilerOptions, tsConfigRaw) {
165
170
  compilerOptions.target = ts.ScriptTarget.ES2021;
166
171
  compilerOptions.inlineSourceMap = true;
167
172
  compilerOptions.skipLibCheck = true;
173
+ let _getTranspiler;
174
+ let registrationKey = JSON.stringify(compilerOptions);
175
+ let tsNodeOptions;
176
+ if (swcNodeInstalled && !preferTsNode) {
177
+ _getTranspiler = getSwcTranspiler;
178
+ }
179
+ else if (tsNodeInstalled) {
180
+ // We can fall back on ts-node if it's available
181
+ _getTranspiler = getTsNodeTranspiler;
182
+ tsNodeOptions = filterRecognizedTsConfigTsNodeOptions(tsConfigRaw?.['ts-node']).recognized;
183
+ // include ts-node options in the registration key
184
+ registrationKey += JSON.stringify(tsNodeOptions);
185
+ }
186
+ else {
187
+ _getTranspiler = undefined;
188
+ }
168
189
  // Just return if transpiler was already registered before.
169
- const registrationKey = JSON.stringify(compilerOptions);
170
190
  const registrationEntry = registered.get(registrationKey);
171
191
  if (registered.has(registrationKey)) {
172
192
  registrationEntry.refCount++;
173
193
  return registrationEntry.cleanup;
174
194
  }
175
- const _getTranspiler = swcNodeInstalled && !preferTsNode
176
- ? getSwcTranspiler
177
- : tsNodeInstalled
178
- ? // We can fall back on ts-node if it's available
179
- getTsNodeTranspiler
180
- : undefined;
181
195
  if (_getTranspiler) {
182
- const transpilerCleanup = _getTranspiler(compilerOptions);
196
+ const transpilerCleanup = _getTranspiler(compilerOptions, tsNodeOptions);
183
197
  const currRegistrationEntry = {
184
198
  refCount: 1,
185
199
  cleanup: () => {
@@ -204,9 +218,9 @@ function getTranspiler(compilerOptions, tsConfigRaw) {
204
218
  *
205
219
  * @returns cleanup method
206
220
  */
207
- function registerTranspiler(compilerOptions) {
221
+ function registerTranspiler(compilerOptions, tsConfigRaw) {
208
222
  // Function to register transpiler that returns cleanup function
209
- const transpiler = getTranspiler(compilerOptions);
223
+ const transpiler = getTranspiler(compilerOptions, tsConfigRaw);
210
224
  if (!transpiler) {
211
225
  warnNoTranspiler();
212
226
  return () => { };
@@ -245,7 +259,9 @@ function registerTsConfigPaths(tsConfigPath) {
245
259
  function readCompilerOptions(tsConfigPath) {
246
260
  const preferTsNode = process.env.NX_PREFER_TS_NODE === 'true';
247
261
  if (swcNodeInstalled && !preferTsNode) {
248
- return readCompilerOptionsWithSwc(tsConfigPath);
262
+ return {
263
+ compilerOptions: readCompilerOptionsWithSwc(tsConfigPath),
264
+ };
249
265
  }
250
266
  else {
251
267
  return readCompilerOptionsWithTypescript(tsConfigPath);
@@ -261,16 +277,14 @@ function readCompilerOptionsWithSwc(tsConfigPath) {
261
277
  return compilerOptions;
262
278
  }
263
279
  function readCompilerOptionsWithTypescript(tsConfigPath) {
264
- if (!ts) {
265
- ts = require('typescript');
266
- }
267
- const { readConfigFile, parseJsonConfigFileContent, sys } = ts;
268
- const jsonContent = readConfigFile(tsConfigPath, sys.readFile);
269
- const { options } = parseJsonConfigFileContent(jsonContent.config, sys, (0, path_1.dirname)(tsConfigPath));
280
+ const { options, raw } = (0, typescript_1.readTsConfigWithoutFiles)(tsConfigPath);
270
281
  // This property is returned in compiler options for some reason, but not part of the typings.
271
282
  // ts-node fails on unknown props, so we have to remove it.
272
283
  delete options.configFilePath;
273
- return options;
284
+ return {
285
+ compilerOptions: options,
286
+ tsConfigRaw: raw,
287
+ };
274
288
  }
275
289
  function loadTsConfigPaths() {
276
290
  try {
@@ -1,6 +1,7 @@
1
1
  import type * as ts from 'typescript';
2
2
  import type { Node, SyntaxKind } from 'typescript';
3
- export declare function readTsConfig(tsConfigPath: string): ts.ParsedCommandLine;
3
+ export declare function readTsConfig(tsConfigPath: string, sys?: ts.System): ts.ParsedCommandLine;
4
+ export declare function readTsConfigWithoutFiles(tsConfigPath: string): ts.ParsedCommandLine;
4
5
  export declare function readTsConfigOptions(tsConfigPath: string): ts.CompilerOptions;
5
6
  /**
6
7
  * Find a module based on its import
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readTsConfig = readTsConfig;
4
+ exports.readTsConfigWithoutFiles = readTsConfigWithoutFiles;
4
5
  exports.readTsConfigOptions = readTsConfigOptions;
5
6
  exports.resolveModuleByImport = resolveModuleByImport;
6
7
  exports.getRootTsConfigFileName = getRootTsConfigFileName;
@@ -11,25 +12,29 @@ const fs_1 = require("fs");
11
12
  const path_1 = require("path");
12
13
  const normalizedAppRoot = workspace_root_1.workspaceRoot.replace(/\\/g, '/');
13
14
  let tsModule;
14
- function readTsConfig(tsConfigPath) {
15
+ function readTsConfig(tsConfigPath, sys) {
15
16
  if (!tsModule) {
16
17
  tsModule = require('typescript');
17
18
  }
18
- const readResult = tsModule.readConfigFile(tsConfigPath, tsModule.sys.readFile);
19
- return tsModule.parseJsonConfigFileContent(readResult.config, tsModule.sys, (0, path_1.dirname)(tsConfigPath));
19
+ sys ??= tsModule.sys;
20
+ const readResult = tsModule.readConfigFile(tsConfigPath, sys.readFile);
21
+ return tsModule.parseJsonConfigFileContent(readResult.config, sys, (0, path_1.dirname)(tsConfigPath));
20
22
  }
21
- function readTsConfigOptions(tsConfigPath) {
23
+ function readTsConfigWithoutFiles(tsConfigPath) {
22
24
  if (!tsModule) {
23
25
  tsModule = require('typescript');
24
26
  }
25
- const readResult = tsModule.readConfigFile(tsConfigPath, tsModule.sys.readFile);
26
27
  // We only care about options, so we don't need to scan source files, and thus
27
28
  // `readDirectory` is stubbed for performance.
28
- const host = {
29
+ const sys = {
29
30
  ...tsModule.sys,
30
31
  readDirectory: () => [],
31
32
  };
32
- return tsModule.parseJsonConfigFileContent(readResult.config, host, (0, path_1.dirname)(tsConfigPath)).options;
33
+ return readTsConfig(tsConfigPath, sys);
34
+ }
35
+ function readTsConfigOptions(tsConfigPath) {
36
+ const { options } = readTsConfigWithoutFiles(tsConfigPath);
37
+ return options;
33
38
  }
34
39
  let compilerHost;
35
40
  /**