nx 21.3.0-canary.20250712-18e5d95 → 21.3.0-canary.20250716-46d21c7

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.
@@ -121,19 +121,26 @@ function normalizeOptions(options) {
121
121
  return options;
122
122
  }
123
123
  function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
124
+ if (command.indexOf('{args.') > -1 && command.indexOf('{args}') > -1) {
125
+ throw new Error('Command should not contain both {args} and {args.*} values. Please choose one to use.');
126
+ }
124
127
  if (command.indexOf('{args.') > -1) {
125
128
  const regex = /{args\.([^}]+)}/g;
126
129
  return command.replace(regex, (_, group) => opts.parsedArgs[group] !== undefined ? opts.parsedArgs[group] : '');
127
130
  }
131
+ else if (command.indexOf('{args}') > -1) {
132
+ const regex = /{args}/g;
133
+ const args = [
134
+ ...unknownOptionsToArgsArray(opts),
135
+ ...unparsedOptionsToArgsArray(opts),
136
+ ];
137
+ const argsString = `${args.join(' ')} ${opts.args ?? ''}`;
138
+ return command.replace(regex, argsString);
139
+ }
128
140
  else if (forwardAllArgs) {
129
141
  let args = '';
130
142
  if (Object.keys(opts.unknownOptions ?? {}).length > 0) {
131
- const unknownOptionsArgs = Object.keys(opts.unknownOptions)
132
- .filter((k) => typeof opts.unknownOptions[k] !== 'object' &&
133
- opts.parsedArgs[k] === opts.unknownOptions[k])
134
- .map((k) => `--${k}=${opts.unknownOptions[k]}`)
135
- .map(wrapArgIntoQuotesIfNeeded)
136
- .join(' ');
143
+ const unknownOptionsArgs = unknownOptionsToArgsArray(opts).join(' ');
137
144
  if (unknownOptionsArgs) {
138
145
  args += ` ${unknownOptionsArgs}`;
139
146
  }
@@ -142,11 +149,9 @@ function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
142
149
  args += ` ${opts.args}`;
143
150
  }
144
151
  if (opts.__unparsed__?.length > 0) {
145
- const filteredParsedOptions = filterPropKeysFromUnParsedOptions(opts.__unparsed__, opts.parsedArgs);
152
+ const filteredParsedOptions = unparsedOptionsToArgsArray(opts);
146
153
  if (filteredParsedOptions.length > 0) {
147
- args += ` ${filteredParsedOptions
148
- .map(wrapArgIntoQuotesIfNeeded)
149
- .join(' ')}`;
154
+ args += ` ${filteredParsedOptions.join(' ')}`;
150
155
  }
151
156
  }
152
157
  return `${command}${args}`;
@@ -155,6 +160,20 @@ function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
155
160
  return command;
156
161
  }
157
162
  }
163
+ function unknownOptionsToArgsArray(opts) {
164
+ return Object.keys(opts.unknownOptions ?? {})
165
+ .filter((k) => typeof opts.unknownOptions[k] !== 'object' &&
166
+ opts.parsedArgs[k] === opts.unknownOptions[k])
167
+ .map((k) => `--${k}=${opts.unknownOptions[k]}`)
168
+ .map(wrapArgIntoQuotesIfNeeded);
169
+ }
170
+ function unparsedOptionsToArgsArray(opts) {
171
+ const filteredParsedOptions = filterPropKeysFromUnParsedOptions(opts.__unparsed__, opts.parsedArgs);
172
+ if (filteredParsedOptions.length > 0) {
173
+ return filteredParsedOptions.map(wrapArgIntoQuotesIfNeeded);
174
+ }
175
+ return [];
176
+ }
158
177
  function parseArgs(unparsedCommandArgs, unknownOptions, args) {
159
178
  if (!args) {
160
179
  return { ...unknownOptions, ...unparsedCommandArgs };
Binary file
@@ -24,7 +24,7 @@ export declare function registerTsProject(tsConfigPath: string): () => void;
24
24
  */
25
25
  export declare function registerTsProject(path: string, configFilename: string): any;
26
26
  export declare function getSwcTranspiler(compilerOptions: CompilerOptions): (...args: unknown[]) => unknown;
27
- export declare function getTsNodeTranspiler(compilerOptions: CompilerOptions, tsNodeOptions?: TsConfigOptions): (...args: unknown[]) => unknown;
27
+ export declare function getTsNodeTranspiler(compilerOptions: CompilerOptions, tsNodeOptions?: TsConfigOptions, preferTsNode?: boolean): (...args: unknown[]) => unknown;
28
28
  export declare function getTranspiler(compilerOptions: CompilerOptions, tsConfigRaw?: unknown): () => (...args: unknown[]) => unknown;
29
29
  /**
30
30
  * Register ts-node or swc-node given a set of compiler options.
@@ -91,7 +91,7 @@ function getSwcTranspiler(compilerOptions) {
91
91
  const cleanupFn = register(compilerOptions);
92
92
  return typeof cleanupFn === 'function' ? cleanupFn : () => { };
93
93
  }
94
- function getTsNodeTranspiler(compilerOptions, tsNodeOptions) {
94
+ function getTsNodeTranspiler(compilerOptions, tsNodeOptions, preferTsNode) {
95
95
  const { register } = require('ts-node');
96
96
  // ts-node doesn't provide a cleanup method
97
97
  const service = register({
@@ -106,7 +106,7 @@ function getTsNodeTranspiler(compilerOptions, tsNodeOptions) {
106
106
  });
107
107
  const { transpiler, swc } = service.options;
108
108
  // Don't warn if a faster transpiler is enabled
109
- if (!transpiler && !swc) {
109
+ if (!transpiler && !swc && !preferTsNode) {
110
110
  warnTsNodeUsage();
111
111
  }
112
112
  return () => {
@@ -170,6 +170,14 @@ function getTranspiler(compilerOptions, tsConfigRaw) {
170
170
  compilerOptions.target = ts.ScriptTarget.ES2021;
171
171
  compilerOptions.inlineSourceMap = true;
172
172
  compilerOptions.skipLibCheck = true;
173
+ // These options are different per project, and since they are not needed for transpilation, we can remove them so we have more cache hits.
174
+ compilerOptions.outDir = undefined;
175
+ compilerOptions.outFile = undefined;
176
+ compilerOptions.declaration = undefined;
177
+ compilerOptions.declarationMap = undefined;
178
+ compilerOptions.composite = undefined;
179
+ compilerOptions.tsBuildInfoFile = undefined;
180
+ delete compilerOptions.strict;
173
181
  let _getTranspiler;
174
182
  let registrationKey = JSON.stringify(compilerOptions);
175
183
  let tsNodeOptions;
@@ -193,7 +201,7 @@ function getTranspiler(compilerOptions, tsConfigRaw) {
193
201
  return registrationEntry.cleanup;
194
202
  }
195
203
  if (_getTranspiler) {
196
- const transpilerCleanup = _getTranspiler(compilerOptions, tsNodeOptions);
204
+ const transpilerCleanup = _getTranspiler(compilerOptions, tsNodeOptions, preferTsNode);
197
205
  const currRegistrationEntry = {
198
206
  refCount: 1,
199
207
  cleanup: () => {