@nx/js 22.7.0-pr.35356.e1b62ce → 22.7.0-rc.1
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/package.json +4 -4
- package/src/executors/node/lib/output-file.d.ts +9 -0
- package/src/executors/node/lib/output-file.d.ts.map +1 -0
- package/src/executors/node/lib/output-file.js +19 -0
- package/src/executors/node/node.impl.d.ts.map +1 -1
- package/src/executors/node/node.impl.js +28 -11
- package/src/executors/tsc/lib/typescript-compilation.js +0 -1
- package/src/generators/typescript-sync/typescript-sync.d.ts.map +1 -1
- package/src/generators/typescript-sync/typescript-sync.js +7 -0
- package/src/plugins/typescript/plugin.js +10 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "22.7.0-
|
|
3
|
+
"version": "22.7.0-rc.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
|
|
6
6
|
"repository": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@babel/preset-env": "^7.23.2",
|
|
41
41
|
"@babel/preset-typescript": "^7.22.5",
|
|
42
42
|
"@babel/runtime": "^7.22.6",
|
|
43
|
-
"@nx/devkit": "22.7.0-
|
|
44
|
-
"@nx/workspace": "22.7.0-
|
|
43
|
+
"@nx/devkit": "22.7.0-rc.1",
|
|
44
|
+
"@nx/workspace": "22.7.0-rc.1",
|
|
45
45
|
"@zkochan/js-yaml": "0.0.7",
|
|
46
46
|
"babel-plugin-const-enum": "^1.0.1",
|
|
47
47
|
"babel-plugin-macros": "^3.1.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"tslib": "^2.3.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"nx": "22.7.0-
|
|
64
|
+
"nx": "22.7.0-rc.1"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"verdaccio": "^6.0.5"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface OutputFileNameOptions {
|
|
2
|
+
buildTargetExecutor: string;
|
|
3
|
+
main: string;
|
|
4
|
+
outputPath: string;
|
|
5
|
+
rootDir: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function getOutputFileName({ buildTargetExecutor, main, outputPath, rootDir, }: OutputFileNameOptions): string;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=output-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-file.d.ts","sourceRoot":"","sources":["../../../../../../../packages/js/src/executors/node/lib/output-file.ts"],"names":[],"mappings":"AAIA,UAAU,qBAAqB;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,mBAAmB,EACnB,IAAI,EACJ,UAAU,EACV,OAAO,GACR,EAAE,qBAAqB,GAAG,MAAM,CAqBhC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOutputFileName = getOutputFileName;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const path_2 = require("nx/src/utils/path");
|
|
6
|
+
const get_main_file_dir_1 = require("../../../utils/get-main-file-dir");
|
|
7
|
+
function getOutputFileName({ buildTargetExecutor, main, outputPath, rootDir, }) {
|
|
8
|
+
const fileName = `${(0, path_1.parse)(main).name}.js`;
|
|
9
|
+
if (buildTargetExecutor !== '@nx/js:tsc' &&
|
|
10
|
+
buildTargetExecutor !== '@nx/js:swc') {
|
|
11
|
+
return fileName;
|
|
12
|
+
}
|
|
13
|
+
const mainDirectory = (0, path_2.normalizePath)((0, path_1.dirname)(main));
|
|
14
|
+
const normalizedOutputPath = (0, path_2.normalizePath)(outputPath);
|
|
15
|
+
const isMainInsideOutputPath = mainDirectory === normalizedOutputPath ||
|
|
16
|
+
mainDirectory.startsWith(`${normalizedOutputPath}/`);
|
|
17
|
+
const base = isMainInsideOutputPath ? normalizedOutputPath : rootDir;
|
|
18
|
+
return (0, path_2.joinPathFragments)((0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(main, base), fileName);
|
|
19
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAQhB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAe,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAqB5D,wBAAuB,YAAY,CACjC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe;aAgEb,OAAO;cACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;cA6QhC;
|
|
1
|
+
{"version":3,"file":"node.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAQhB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAe,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAqB5D,wBAAuB,YAAY,CACjC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe;aAgEb,OAAO;cACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;cA6QhC;AA6ID,eAAe,YAAY,CAAC"}
|
|
@@ -15,9 +15,9 @@ const kill_tree_1 = require("./lib/kill-tree");
|
|
|
15
15
|
const line_aware_writer_1 = require("./lib/line-aware-writer");
|
|
16
16
|
const coalescing_debounce_1 = require("./lib/coalescing-debounce");
|
|
17
17
|
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
18
|
-
const get_main_file_dir_1 = require("../../utils/get-main-file-dir");
|
|
19
18
|
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
20
19
|
const detect_module_format_1 = require("./lib/detect-module-format");
|
|
20
|
+
const output_file_1 = require("./lib/output-file");
|
|
21
21
|
const globalLineAwareWriter = new line_aware_writer_1.LineAwareWriter();
|
|
22
22
|
async function* nodeExecutor(options, context) {
|
|
23
23
|
process.env.NODE_ENV ??= context?.configurationName ?? 'development';
|
|
@@ -295,7 +295,11 @@ function calculateResolveMappings(context, options) {
|
|
|
295
295
|
const { dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, parsed.project, parsed.target, parsed.configuration);
|
|
296
296
|
return dependencies.reduce((m, c) => {
|
|
297
297
|
if (c.node.type !== 'npm' && c.outputs[0] != null) {
|
|
298
|
-
|
|
298
|
+
// `outputs` are cache patterns and may contain globs (e.g. from the
|
|
299
|
+
// inferred `@nx/js/typescript` build target). Strip the glob portion
|
|
300
|
+
// so the runtime require overrides resolve to the actual output dir.
|
|
301
|
+
const outputDir = stripGlobToBaseDir(c.outputs[0]);
|
|
302
|
+
m[c.name] = (0, devkit_1.joinPathFragments)(context.root, outputDir);
|
|
299
303
|
}
|
|
300
304
|
return m;
|
|
301
305
|
}, {});
|
|
@@ -329,7 +333,13 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
|
|
|
329
333
|
projectRoot: project.data.root,
|
|
330
334
|
workspaceRoot: context.root,
|
|
331
335
|
});
|
|
332
|
-
|
|
336
|
+
// `outputs` are cache patterns and may contain globs (e.g. the inferred
|
|
337
|
+
// `@nx/js/typescript` build target scopes its output to
|
|
338
|
+
// `{projectRoot}/dist/**/*.{js,...}` to avoid caching non-tsc files).
|
|
339
|
+
// Strip the glob portion back to the last path separator before it to
|
|
340
|
+
// recover the base output directory.
|
|
341
|
+
const outputDir = stripGlobToBaseDir(outputFilePath);
|
|
342
|
+
return path.join(outputDir, 'main.js');
|
|
333
343
|
}
|
|
334
344
|
const fallbackFile = path.join('dist', project.data.root, 'main.js');
|
|
335
345
|
devkit_1.logger.warn(`Build option ${chalk_1.default.bold('outputFileName')} not set for ${chalk_1.default.bold(project.name)}. Using fallback value of ${chalk_1.default.bold(fallbackFile)}.`);
|
|
@@ -337,17 +347,24 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
|
|
|
337
347
|
}
|
|
338
348
|
let outputFileName = buildOptions.outputFileName;
|
|
339
349
|
if (!outputFileName) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
outputFileName = fileName;
|
|
347
|
-
}
|
|
350
|
+
outputFileName = (0, output_file_1.getOutputFileName)({
|
|
351
|
+
buildTargetExecutor,
|
|
352
|
+
main: buildOptions.main,
|
|
353
|
+
outputPath: buildOptions.outputPath,
|
|
354
|
+
rootDir: buildOptions.rootDir ?? project.data.root,
|
|
355
|
+
});
|
|
348
356
|
}
|
|
349
357
|
return (0, path_1.join)(context.root, buildOptions.outputPath, outputFileName);
|
|
350
358
|
}
|
|
359
|
+
function stripGlobToBaseDir(pathWithGlob) {
|
|
360
|
+
const globIdx = pathWithGlob.search(/[*?[{(]/);
|
|
361
|
+
if (globIdx === -1) {
|
|
362
|
+
return pathWithGlob.replace(/[\\/]+$/, '');
|
|
363
|
+
}
|
|
364
|
+
const prefix = pathWithGlob.slice(0, globIdx);
|
|
365
|
+
const lastSep = Math.max(prefix.lastIndexOf('/'), prefix.lastIndexOf('\\'));
|
|
366
|
+
return lastSep === -1 ? '' : prefix.slice(0, lastSep);
|
|
367
|
+
}
|
|
351
368
|
function fileToRunCorrectPath(fileToRun) {
|
|
352
369
|
if ((0, fileutils_1.fileExists)(fileToRun))
|
|
353
370
|
return fileToRun;
|
|
@@ -61,7 +61,6 @@ function* compileTS(context, logger, hooks, reporters) {
|
|
|
61
61
|
});
|
|
62
62
|
const rootNames = Object.keys(context);
|
|
63
63
|
const solutionBuilder = ts.createSolutionBuilder(solutionBuilderHost, rootNames, {});
|
|
64
|
-
// eslint-disable-next-line no-constant-condition
|
|
65
64
|
while (true) {
|
|
66
65
|
project = solutionBuilder.getNextInvalidatedProject();
|
|
67
66
|
if (!project) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-sync.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/typescript-sync/typescript-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAIpB,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"typescript-sync.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/typescript-sync/typescript-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAIpB,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AA4CtC,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAyQ5E;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -199,6 +199,7 @@ function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsCon
|
|
|
199
199
|
const stringifiedJsonContents = readRawTsconfigContents(tree, tsconfigInfoCaches, tsConfigPath);
|
|
200
200
|
const tsConfig = (0, devkit_1.parseJson)(stringifiedJsonContents);
|
|
201
201
|
const ignoredReferences = new Set(tsConfig.nx?.sync?.ignoredReferences ?? []);
|
|
202
|
+
const ignoredDependencies = new Set(tsConfig.nx?.sync?.ignoredDependencies ?? []);
|
|
202
203
|
// We have at least one dependency so we can safely set it to an empty array if not already set
|
|
203
204
|
const references = [];
|
|
204
205
|
const originalReferencesSet = new Set();
|
|
@@ -236,6 +237,12 @@ function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsCon
|
|
|
236
237
|
}
|
|
237
238
|
}
|
|
238
239
|
for (const dep of dependencies) {
|
|
240
|
+
if (ignoredDependencies.has(dep.name)) {
|
|
241
|
+
// The user has explicitly opted out of this dependency edge, typically
|
|
242
|
+
// to break a circular project reference graph that the project graph
|
|
243
|
+
// intentionally allows.
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
239
246
|
// Ensure the project reference for the target is set if we can find the
|
|
240
247
|
// relevant tsconfig file
|
|
241
248
|
let referencePath;
|
|
@@ -456,17 +456,18 @@ function getInputs(namedInputs, config, tsConfig, internalProjectReferences, wor
|
|
|
456
456
|
if (excludePaths.size) {
|
|
457
457
|
inputs.push(...Array.from(excludePaths).map((p) => `!${pathToInputOrOutput((0, devkit_1.joinPathFragments)(config.project.root, p), workspaceRoot, config.project)}`));
|
|
458
458
|
}
|
|
459
|
-
// tsc --build reads .d.ts and .tsbuildinfo files from dependent
|
|
460
|
-
// the source files of dependencies. This correctly tracks build
|
|
461
|
-
// both external project references and same-project task
|
|
462
|
-
// build-native producing .d.ts files that may be excluded
|
|
463
|
-
// via .nxignore.
|
|
459
|
+
// tsc --build reads .d.ts/.d.cts/.d.mts and .tsbuildinfo files from dependent
|
|
460
|
+
// tasks, not the source files of dependencies. This correctly tracks build
|
|
461
|
+
// outputs from both external project references and same-project task
|
|
462
|
+
// dependencies (e.g. build-native producing .d.ts files that may be excluded
|
|
463
|
+
// from file watching via .nxignore). Declaration files are also read from
|
|
464
|
+
// the deps projects sources.
|
|
464
465
|
inputs.push({
|
|
465
|
-
dependentTasksOutputFiles: '**/*.{d.ts,tsbuildinfo}',
|
|
466
|
+
dependentTasksOutputFiles: '**/*.{d.ts,d.cts,d.mts,tsbuildinfo}',
|
|
466
467
|
transitive: true,
|
|
467
468
|
});
|
|
468
469
|
inputs.push({
|
|
469
|
-
fileset: '{projectRoot}/**/*.d.ts',
|
|
470
|
+
fileset: '{projectRoot}/**/*.{d.ts,d.cts,d.mts}',
|
|
470
471
|
dependencies: true,
|
|
471
472
|
});
|
|
472
473
|
const externalRefPatterns = getExternalProjectReferenceTsconfigPatterns(tsConfig, internalProjectReferences, workspaceRoot, config.project, cache);
|
|
@@ -499,9 +500,9 @@ function getOutputs(config, rootTsConfig, internalProjectReferences, workspaceRo
|
|
|
499
500
|
}
|
|
500
501
|
else if (tsConfig.options.outDir) {
|
|
501
502
|
if (emitDeclarationOnly) {
|
|
502
|
-
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.d.ts'), workspaceRoot, config.project));
|
|
503
|
+
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.{d.ts,d.cts,d.mts}'), workspaceRoot, config.project));
|
|
503
504
|
if (tsConfig.options.declarationMap) {
|
|
504
|
-
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.d.ts.map'), workspaceRoot, config.project));
|
|
505
|
+
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.{d.ts,d.cts,d.mts}.map'), workspaceRoot, config.project));
|
|
505
506
|
}
|
|
506
507
|
}
|
|
507
508
|
else {
|