@nx/js 24.0.4 → 24.0.6
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/dist/internal.d.ts +1 -0
- package/dist/internal.js +4 -2
- package/dist/src/generators/library/utils/add-release-config.js +1 -1
- package/dist/src/release/utils/update-lock-file.js +21 -1
- package/dist/src/utils/find-npm-dependencies.js +54 -14
- package/dist/src/utils/package-json/runtime-dependencies.d.ts +1 -0
- package/dist/src/utils/package-json/runtime-dependencies.js +14 -0
- package/package.json +11 -11
package/dist/internal.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { walkTsconfigExtendsChain, type RawTsconfigJsonCache, } from './src/util
|
|
|
5
5
|
export { isEsmProject } from './src/utils/module-format/is-esm-project';
|
|
6
6
|
export { PNPM_INSTALL_SETTINGS_INPUTS, PNPM_MAJOR_RUNTIME_INPUT, pnpmInstallSettingsInputsForInferredTarget, shouldIncludePnpmMajorRuntimeInput, } from './src/utils/pnpm-install-settings-inputs';
|
|
7
7
|
export { addPnpmDeployOutputCacheInputs } from './src/utils/pnpm-deploy-output-cache-inputs';
|
|
8
|
+
export { readRuntimeDependencies } from './src/utils/package-json/runtime-dependencies';
|
|
8
9
|
export type { MatchedTargetRef } from './src/utils/target-defaults-matching';
|
|
9
10
|
export { TS_SOLUTION_SETUP_TSCONFIG_INPUT, addProjectToTsSolutionWorkspace, assertNotUsingTsSolutionSetup, findRuntimeTsConfigName, getDefinedCustomConditionName, getProjectSourceRoot, getProjectType, isUsingTsSolutionSetup, shouldConfigureTsSolutionSetup, updateTsconfigFiles, } from './src/utils/typescript/ts-solution-setup';
|
|
10
11
|
export { ensureTypescriptPlugin, registerTypescriptPluginForTypecheck, } from './src/utils/typescript/add-typescript-plugin';
|
package/dist/internal.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// internal consumers and may change without semver protection. Consider it
|
|
6
6
|
// the @nx/js equivalent of `@nx/devkit/internal`.
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
9
|
-
exports.typesNodeVersion = exports.tsLibVersion = exports.swcNodeVersion = exports.swcHelpersVersion = exports.swcCoreVersion = exports.swcCliVersion = exports.prettierVersion = exports.esbuildVersion = exports.nxVersion = exports.releaseTasks = exports.addReleaseConfigForTsSolution = exports.addReleaseConfigForNonTsSolution = exports.addLocalRegistryScripts = exports.stripGlobToBaseDir = exports.getImportPath = exports.createGlobPatternsForDependencies = exports.addLintingToProject = exports.detectLinters = exports.normalizeUnitTestRunnerOption = exports.normalizeLinterOption = exports.selectTypecheckTsConfig = exports.createTypecheckTarget = exports.isValidPackageJsonBuildConfig = exports.addBuildAndWatchDepsTargets = void 0;
|
|
8
|
+
exports.getProjectPackageManagerWorkspaceStateWarningTask = exports.getProjectPackageManagerWorkspaceState = exports.getNpmScope = exports.sortPackageJsonFields = exports.CopyAssetsHandler = exports.addSwcRegisterDependencies = exports.addSwcDependencies = exports.acknowledgeSwcBuildScripts = exports.addSwcTestConfig = exports.addSwcConfig = exports.createTmpTsConfig = exports.computeCompilerOptionsPaths = exports.calculateProjectDependencies = exports.calculateProjectBuildableDependencies = exports.compileTypeScript = exports.getNeededCompilerOptionOverrides = exports.isTypescriptVersionAtLeast = exports.getTsConfigModuleResolution = exports.getRangeMinimum = exports.ensureTypescript = exports.createTreeParseConfigHost = exports.getTsConfigBaseOptions = exports.registerTypescriptPluginForTypecheck = exports.ensureTypescriptPlugin = exports.updateTsconfigFiles = exports.shouldConfigureTsSolutionSetup = exports.isUsingTsSolutionSetup = exports.getProjectType = exports.getProjectSourceRoot = exports.getDefinedCustomConditionName = exports.findRuntimeTsConfigName = exports.assertNotUsingTsSolutionSetup = exports.addProjectToTsSolutionWorkspace = exports.TS_SOLUTION_SETUP_TSCONFIG_INPUT = exports.readRuntimeDependencies = exports.addPnpmDeployOutputCacheInputs = exports.shouldIncludePnpmMajorRuntimeInput = exports.pnpmInstallSettingsInputsForInferredTarget = exports.PNPM_MAJOR_RUNTIME_INPUT = exports.PNPM_INSTALL_SETTINGS_INPUTS = exports.isEsmProject = exports.walkTsconfigExtendsChain = exports.findProjectsNpmDependencies = exports.isBuiltinModuleImport = exports.TargetProjectLocator = exports.requireWithTsconfigFallback = exports.registerTsConfigPaths = exports.registerTsProject = exports.loadTsFile = exports.forceRegisterEsmLoader = void 0;
|
|
9
|
+
exports.typesNodeVersion = exports.tsLibVersion = exports.swcNodeVersion = exports.swcHelpersVersion = exports.swcCoreVersion = exports.swcCliVersion = exports.prettierVersion = exports.esbuildVersion = exports.nxVersion = exports.releaseTasks = exports.addReleaseConfigForTsSolution = exports.addReleaseConfigForNonTsSolution = exports.addLocalRegistryScripts = exports.stripGlobToBaseDir = exports.getImportPath = exports.createGlobPatternsForDependencies = exports.addLintingToProject = exports.detectLinters = exports.normalizeUnitTestRunnerOption = exports.normalizeLinterOption = exports.selectTypecheckTsConfig = exports.createTypecheckTarget = exports.isValidPackageJsonBuildConfig = exports.addBuildAndWatchDepsTargets = exports.findNpmDependencies = void 0;
|
|
10
10
|
// Re-exports of nx-source internals.
|
|
11
11
|
var internal_1 = require("@nx/devkit/internal");
|
|
12
12
|
Object.defineProperty(exports, "forceRegisterEsmLoader", { enumerable: true, get: function () { return internal_1.forceRegisterEsmLoader; } });
|
|
@@ -34,6 +34,8 @@ Object.defineProperty(exports, "pnpmInstallSettingsInputsForInferredTarget", { e
|
|
|
34
34
|
Object.defineProperty(exports, "shouldIncludePnpmMajorRuntimeInput", { enumerable: true, get: function () { return pnpm_install_settings_inputs_1.shouldIncludePnpmMajorRuntimeInput; } });
|
|
35
35
|
var pnpm_deploy_output_cache_inputs_1 = require("./src/utils/pnpm-deploy-output-cache-inputs");
|
|
36
36
|
Object.defineProperty(exports, "addPnpmDeployOutputCacheInputs", { enumerable: true, get: function () { return pnpm_deploy_output_cache_inputs_1.addPnpmDeployOutputCacheInputs; } });
|
|
37
|
+
var runtime_dependencies_1 = require("./src/utils/package-json/runtime-dependencies");
|
|
38
|
+
Object.defineProperty(exports, "readRuntimeDependencies", { enumerable: true, get: function () { return runtime_dependencies_1.readRuntimeDependencies; } });
|
|
37
39
|
// TS solution setup detection
|
|
38
40
|
var ts_solution_setup_1 = require("./src/utils/typescript/ts-solution-setup");
|
|
39
41
|
Object.defineProperty(exports, "TS_SOLUTION_SETUP_TSCONFIG_INPUT", { enumerable: true, get: function () { return ts_solution_setup_1.TS_SOLUTION_SETUP_TSCONFIG_INPUT; } });
|
|
@@ -17,7 +17,7 @@ async function addReleaseConfigForTsSolution(tree, projectName, projectConfigura
|
|
|
17
17
|
nxJson.release = {
|
|
18
18
|
...nxJson.release,
|
|
19
19
|
version: {
|
|
20
|
-
preVersionCommand: `${pmc.
|
|
20
|
+
preVersionCommand: `${pmc.exec} nx run-many -t build`,
|
|
21
21
|
...nxJson.release?.version,
|
|
22
22
|
},
|
|
23
23
|
};
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateLockFile = updateLockFile;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
6
8
|
const internal_1 = require("@nx/devkit/internal");
|
|
7
9
|
const semver_1 = require("semver");
|
|
8
10
|
async function updateLockFile(cwd, { dryRun, verbose, options, }) {
|
|
@@ -22,7 +24,8 @@ async function updateLockFile(cwd, { dryRun, verbose, options, }) {
|
|
|
22
24
|
return [];
|
|
23
25
|
}
|
|
24
26
|
const workspacesEnabled = (0, devkit_1.isWorkspacesEnabled)(packageManager, cwd);
|
|
25
|
-
if (!workspacesEnabled
|
|
27
|
+
if (!workspacesEnabled &&
|
|
28
|
+
!(packageManager === 'npm' && isNpmLockFileRootVersionStale(cwd))) {
|
|
26
29
|
if (verbose) {
|
|
27
30
|
console.log(`\nSkipped lock file update because ${packageManager} workspaces are not enabled.`);
|
|
28
31
|
}
|
|
@@ -94,6 +97,23 @@ async function updateLockFile(cwd, { dryRun, verbose, options, }) {
|
|
|
94
97
|
}
|
|
95
98
|
return newlyChanged;
|
|
96
99
|
}
|
|
100
|
+
function isNpmLockFileRootVersionStale(cwd) {
|
|
101
|
+
try {
|
|
102
|
+
const lockFilePath = (0, path_1.join)(cwd, (0, internal_1.getLockFileName)('npm'));
|
|
103
|
+
if (!(0, fs_1.existsSync)(lockFilePath)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const { version } = (0, devkit_1.readJsonFile)((0, path_1.join)(cwd, 'package.json'));
|
|
107
|
+
const lockFile = (0, devkit_1.readJsonFile)(lockFilePath);
|
|
108
|
+
const lockFileRootVersion = lockFile.lockfileVersion === 1
|
|
109
|
+
? lockFile.version
|
|
110
|
+
: lockFile.packages?.['']?.version;
|
|
111
|
+
return !!version && lockFileRootVersion !== version;
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
97
117
|
/**
|
|
98
118
|
* Returns the set of modified, added, and untracked file paths reported by git.
|
|
99
119
|
* Used to detect all filesystem side-effects of the lock file update command.
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findNpmDependencies = findNpmDependencies;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
+
const semver_1 = require("semver");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
7
|
const ts_config_1 = require("./typescript/ts-config");
|
|
7
8
|
const internal_1 = require("@nx/devkit/internal");
|
|
9
|
+
const highestHelperVersions = new WeakMap();
|
|
8
10
|
/**
|
|
9
11
|
* Finds all npm dependencies and their expected versions for a given project.
|
|
10
12
|
*/
|
|
@@ -114,10 +116,11 @@ function readPackageJson(project, workspaceRoot) {
|
|
|
114
116
|
function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, buildTarget, runtimeHelpers, npmDeps) {
|
|
115
117
|
if (runtimeHelpers?.length > 0) {
|
|
116
118
|
for (const helper of runtimeHelpers) {
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
if (npmDeps[helper])
|
|
120
|
+
continue;
|
|
121
|
+
const version = findHelperVersion(projectGraph, sourceProject, helper);
|
|
122
|
+
if (version) {
|
|
123
|
+
npmDeps[helper] = version;
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
return;
|
|
@@ -127,9 +130,10 @@ function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, b
|
|
|
127
130
|
return;
|
|
128
131
|
if (target.executor === '@nx/js:tsc' && target.options?.tsConfig) {
|
|
129
132
|
const tsConfig = (0, ts_config_1.readTsConfig)((0, path_1.join)(workspaceRoot, target.options.tsConfig));
|
|
130
|
-
|
|
131
|
-
projectGraph
|
|
132
|
-
|
|
133
|
+
const version = tsConfig?.options['importHelpers'] &&
|
|
134
|
+
findHelperVersion(projectGraph, sourceProject, 'tslib');
|
|
135
|
+
if (version) {
|
|
136
|
+
npmDeps['tslib'] = version;
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
139
|
if (target.executor === '@nx/js:swc') {
|
|
@@ -139,10 +143,10 @@ function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, b
|
|
|
139
143
|
const swcConfig = (0, internal_1.fileExists)(swcConfigPath)
|
|
140
144
|
? (0, devkit_1.readJsonFile)(swcConfigPath)
|
|
141
145
|
: {};
|
|
142
|
-
|
|
143
|
-
projectGraph
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
const version = swcConfig?.jsc?.externalHelpers &&
|
|
147
|
+
findHelperVersion(projectGraph, sourceProject, '@swc/helpers');
|
|
148
|
+
if (version) {
|
|
149
|
+
npmDeps['@swc/helpers'] = version;
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
152
|
// For inferred targets or manually added run-commands, check if user is using `tsc` in build target.
|
|
@@ -151,13 +155,49 @@ function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, b
|
|
|
151
155
|
const tsConfigPath = resolveTsConfigForRunCommandsTarget(workspaceRoot, sourceProject, target.options);
|
|
152
156
|
if (tsConfigPath) {
|
|
153
157
|
const tsConfig = (0, ts_config_1.readTsConfig)(tsConfigPath);
|
|
154
|
-
|
|
155
|
-
projectGraph
|
|
156
|
-
|
|
158
|
+
const version = tsConfig?.options['importHelpers'] &&
|
|
159
|
+
findHelperVersion(projectGraph, sourceProject, 'tslib');
|
|
160
|
+
if (version) {
|
|
161
|
+
npmDeps['tslib'] = version;
|
|
157
162
|
}
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
}
|
|
166
|
+
function findHelperVersion(projectGraph, sourceProject, helper) {
|
|
167
|
+
const bareNode = projectGraph.externalNodes[`npm:${helper}`];
|
|
168
|
+
const bareLinkVersion = bareNode?.data.version.startsWith('link:')
|
|
169
|
+
? bareNode.data.version
|
|
170
|
+
: undefined;
|
|
171
|
+
if (bareNode && !bareLinkVersion) {
|
|
172
|
+
return bareNode.type === 'npm' ? bareNode.data.version : undefined;
|
|
173
|
+
}
|
|
174
|
+
// A helper with several versions can have only versioned nodes, for
|
|
175
|
+
// example when the pnpm root importer does not declare it, and an outside
|
|
176
|
+
// `link:` can then hold the bare name. Prefer the version that the project
|
|
177
|
+
// depends on, else the highest registry version, else the link.
|
|
178
|
+
const isHelperNode = (name) => projectGraph.externalNodes[name]?.type === 'npm' &&
|
|
179
|
+
projectGraph.externalNodes[name].data.packageName === helper;
|
|
180
|
+
const projectDependency = projectGraph.dependencies[sourceProject.name]?.find((dependency) => isHelperNode(dependency.target));
|
|
181
|
+
if (projectDependency) {
|
|
182
|
+
return projectGraph.externalNodes[projectDependency.target].data.version;
|
|
183
|
+
}
|
|
184
|
+
let versions = highestHelperVersions.get(projectGraph.externalNodes);
|
|
185
|
+
if (!versions) {
|
|
186
|
+
versions = new Map();
|
|
187
|
+
highestHelperVersions.set(projectGraph.externalNodes, versions);
|
|
188
|
+
}
|
|
189
|
+
if (!versions.has(helper)) {
|
|
190
|
+
const candidates = Object.keys(projectGraph.externalNodes)
|
|
191
|
+
.filter(isHelperNode)
|
|
192
|
+
.map((name) => projectGraph.externalNodes[name].data.version)
|
|
193
|
+
.filter((version) => (0, semver_1.valid)(version) !== null)
|
|
194
|
+
.sort(semver_1.rcompare);
|
|
195
|
+
// A stable version wins over a prerelease.
|
|
196
|
+
versions.set(helper, candidates.find((version) => (0, semver_1.prerelease)(version) === null) ??
|
|
197
|
+
candidates[0]);
|
|
198
|
+
}
|
|
199
|
+
return versions.get(helper) ?? bareLinkVersion;
|
|
200
|
+
}
|
|
161
201
|
function resolveTsConfigForRunCommandsTarget(workspaceRoot, sourceProject, targetOptions) {
|
|
162
202
|
const commandTsConfig = extractTsConfigFromCommand(targetOptions.command);
|
|
163
203
|
if (commandTsConfig) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readRuntimeDependencies(runtimeDependencies: string[], requirePaths: string[]): Record<string, string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readRuntimeDependencies = readRuntimeDependencies;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
|
+
function readRuntimeDependencies(runtimeDependencies, requirePaths) {
|
|
6
|
+
const dependencies = {};
|
|
7
|
+
for (const dependency of runtimeDependencies) {
|
|
8
|
+
const { name, version } = (0, internal_1.readModulePackageJson)(dependency, requirePaths).packageJson;
|
|
9
|
+
// An alias installs `name` in the folder `dependency`, which `require` loads.
|
|
10
|
+
dependencies[dependency] =
|
|
11
|
+
name === dependency ? version : `npm:${name}@${version}`;
|
|
12
|
+
}
|
|
13
|
+
return dependencies;
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "24.0.
|
|
3
|
+
"version": "24.0.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -162,8 +162,8 @@
|
|
|
162
162
|
"@babel/preset-env": "^7.23.2",
|
|
163
163
|
"@babel/preset-typescript": "^7.22.5",
|
|
164
164
|
"@babel/runtime": "^7.22.6",
|
|
165
|
-
"@nx/devkit": "24.0.
|
|
166
|
-
"@nx/workspace": "24.0.
|
|
165
|
+
"@nx/devkit": "24.0.6",
|
|
166
|
+
"@nx/workspace": "24.0.6",
|
|
167
167
|
"@zkochan/js-yaml": "0.0.7",
|
|
168
168
|
"babel-plugin-const-enum": "^1.0.1",
|
|
169
169
|
"babel-plugin-macros": "^3.1.0",
|
|
@@ -183,14 +183,14 @@
|
|
|
183
183
|
"tslib": "^2.3.0"
|
|
184
184
|
},
|
|
185
185
|
"devDependencies": {
|
|
186
|
-
"@nx/esbuild": "24.0.
|
|
187
|
-
"@nx/eslint": "24.0.
|
|
188
|
-
"@nx/jest": "24.0.
|
|
189
|
-
"@nx/oxlint": "24.0.
|
|
190
|
-
"@nx/rollup": "24.0.
|
|
191
|
-
"@nx/vite": "24.0.
|
|
192
|
-
"@nx/vitest": "24.0.
|
|
193
|
-
"nx": "24.0.
|
|
186
|
+
"@nx/esbuild": "24.0.6",
|
|
187
|
+
"@nx/eslint": "24.0.6",
|
|
188
|
+
"@nx/jest": "24.0.6",
|
|
189
|
+
"@nx/oxlint": "24.0.6",
|
|
190
|
+
"@nx/rollup": "24.0.6",
|
|
191
|
+
"@nx/vite": "24.0.6",
|
|
192
|
+
"@nx/vitest": "24.0.6",
|
|
193
|
+
"nx": "24.0.6"
|
|
194
194
|
},
|
|
195
195
|
"peerDependencies": {
|
|
196
196
|
"@swc/cli": ">=0.6.0 <0.9.0",
|