@nx/js 24.0.5 → 24.1.0-beta.0
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/babel.d.ts +0 -5
- package/dist/babel.js +1 -8
- package/dist/internal.d.ts +2 -1
- package/dist/internal.js +5 -2
- package/dist/src/executors/verdaccio/verdaccio.impl.js +26 -0
- package/dist/src/generators/library/utils/add-release-config.js +1 -1
- package/dist/src/generators/typescript-sync/typescript-sync.js +20 -14
- package/dist/src/migrations/update-24-1-0/replace-babel-class-properties-loose.d.ts +10 -0
- package/dist/src/migrations/update-24-1-0/replace-babel-class-properties-loose.js +99 -0
- package/dist/src/migrations/update-24-1-0/replace-babel-class-properties-loose.md +41 -0
- package/dist/src/release/utils/update-lock-file.js +21 -1
- package/dist/src/utils/package-json/runtime-dependencies.d.ts +1 -0
- package/dist/src/utils/package-json/runtime-dependencies.js +14 -0
- package/dist/src/utils/typescript/load-ts-transformers.js +2 -2
- package/migrations.json +6 -0
- package/package.json +11 -11
package/dist/babel.d.ts
CHANGED
package/dist/babel.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path_1 = require("path");
|
|
4
4
|
const semver_1 = require("semver");
|
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
module.exports = function (api, options = {}) {
|
|
7
6
|
api.assertVersion(7);
|
|
8
7
|
const isModern = api.caller((caller) => caller?.isModern);
|
|
@@ -11,13 +10,7 @@ module.exports = function (api, options = {}) {
|
|
|
11
10
|
// This is set by `@nx/rollup:rollup` executor
|
|
12
11
|
const isNxPackage = api.caller((caller) => caller?.isNxPackage);
|
|
13
12
|
const emitDecoratorMetadata = api.caller((caller) => caller?.emitDecoratorMetadata ?? true);
|
|
14
|
-
|
|
15
|
-
// so that we can sync the `loose` option with `@babel/preset-env`.
|
|
16
|
-
// TODO(v21): Remove classProperties since it's no longer needed, now that the class props transform is in preset-env.
|
|
17
|
-
const loose = options.classProperties?.loose ?? options.loose ?? true;
|
|
18
|
-
if (options.classProperties) {
|
|
19
|
-
devkit_1.logger.warn(`Use =\`loose\` option instead of \`classProperties.loose\`. The \`classProperties\` option will be removed in Nx 20`);
|
|
20
|
-
}
|
|
13
|
+
const loose = options.loose ?? true;
|
|
21
14
|
const plugins = [
|
|
22
15
|
!isNxPackage
|
|
23
16
|
? [
|
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';
|
|
@@ -34,4 +35,4 @@ export { stripGlobToBaseDir } from './src/utils/strip-glob-to-base-dir';
|
|
|
34
35
|
export { addLocalRegistryScripts } from './src/utils/add-local-registry-scripts';
|
|
35
36
|
export type { LibraryGeneratorSchema } from './src/generators/library/schema';
|
|
36
37
|
export { addReleaseConfigForNonTsSolution, addReleaseConfigForTsSolution, releaseTasks, } from './src/generators/library/utils/add-release-config';
|
|
37
|
-
export { nxVersion, esbuildVersion, prettierVersion, swcCliVersion, swcCoreVersion, swcHelpersVersion, swcNodeVersion, tsLibVersion, typesNodeVersion, } from './src/utils/versions';
|
|
38
|
+
export { nxVersion, esbuildVersion, prettierVersion, swcCliVersion, swcCoreVersion, swcHelpersVersion, swcNodeVersion, tsLibVersion, typesNodeVersion, typescriptVersion, } from './src/utils/versions';
|
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.typescriptVersion = 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; } });
|
|
@@ -131,3 +133,4 @@ Object.defineProperty(exports, "swcHelpersVersion", { enumerable: true, get: fun
|
|
|
131
133
|
Object.defineProperty(exports, "swcNodeVersion", { enumerable: true, get: function () { return versions_1.swcNodeVersion; } });
|
|
132
134
|
Object.defineProperty(exports, "tsLibVersion", { enumerable: true, get: function () { return versions_1.tsLibVersion; } });
|
|
133
135
|
Object.defineProperty(exports, "typesNodeVersion", { enumerable: true, get: function () { return versions_1.typesNodeVersion; } });
|
|
136
|
+
Object.defineProperty(exports, "typescriptVersion", { enumerable: true, get: function () { return versions_1.typescriptVersion; } });
|
|
@@ -91,6 +91,14 @@ function startVerdaccio(options, workspaceRoot) {
|
|
|
91
91
|
childProcess.on('error', (err) => {
|
|
92
92
|
reject(err);
|
|
93
93
|
});
|
|
94
|
+
childProcess.on('message', (message) => {
|
|
95
|
+
if (message?.verdaccio_started === true &&
|
|
96
|
+
process.env.NX_READY_SIGNAL_SOCKET) {
|
|
97
|
+
// Nx versions without signal readiness do not export this API.
|
|
98
|
+
const { emitReadySignal } = require('@nx/devkit');
|
|
99
|
+
emitReadySignal(getVerdaccioListeningUrl(options));
|
|
100
|
+
}
|
|
101
|
+
});
|
|
94
102
|
childProcess.on('disconnect', (err) => {
|
|
95
103
|
reject(err);
|
|
96
104
|
});
|
|
@@ -106,6 +114,24 @@ function startVerdaccio(options, workspaceRoot) {
|
|
|
106
114
|
});
|
|
107
115
|
});
|
|
108
116
|
}
|
|
117
|
+
function getVerdaccioListeningUrl(options) {
|
|
118
|
+
const listenAddress = options.listenAddress
|
|
119
|
+
? `${options.listenAddress}:${options.port}`
|
|
120
|
+
: String(options.port);
|
|
121
|
+
// Verdaccio accepts protocol prefixes without "//" and an empty host.
|
|
122
|
+
const address = /^(?:(https?):(?:\/\/)?)?(?:([^/:]*|\[[^\[\]]+\]):)?(\d+)\/?$/.exec(listenAddress);
|
|
123
|
+
if (!address)
|
|
124
|
+
return undefined;
|
|
125
|
+
const endpoint = `${address[1] ?? 'http'}://${address[2] || 'localhost'}:${address[3]}/`;
|
|
126
|
+
if (!URL.canParse(endpoint))
|
|
127
|
+
return undefined;
|
|
128
|
+
const url = new URL(endpoint);
|
|
129
|
+
if (url.hostname === '0.0.0.0')
|
|
130
|
+
url.hostname = '127.0.0.1';
|
|
131
|
+
if (url.hostname === '[::]')
|
|
132
|
+
url.hostname = '[::1]';
|
|
133
|
+
return url.href;
|
|
134
|
+
}
|
|
109
135
|
function createVerdaccioOptions(options, workspaceRoot) {
|
|
110
136
|
const verdaccioArgs = [];
|
|
111
137
|
if (options.config) {
|
|
@@ -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
|
};
|
|
@@ -132,7 +132,7 @@ async function syncGenerator(tree) {
|
|
|
132
132
|
continue;
|
|
133
133
|
}
|
|
134
134
|
// Collect the dependencies of the source project
|
|
135
|
-
const dependencies = collectProjectDependencies(
|
|
135
|
+
const dependencies = collectProjectDependencies(projectName, projectGraph, collectedDependencies);
|
|
136
136
|
let foundRuntimeTsConfig = false;
|
|
137
137
|
for (const runtimeTsConfigFileName of runtimeTsConfigFileNames) {
|
|
138
138
|
const runtimeTsConfigPath = (0, devkit_1.joinPathFragments)(sourceProjectNode.data.root, runtimeTsConfigFileName);
|
|
@@ -233,7 +233,7 @@ function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsCon
|
|
|
233
233
|
// reference path is relative to the tsconfig file
|
|
234
234
|
const resolvedRefPath = getTsConfigPathFromReferencePath(tsConfigPath, ref.path);
|
|
235
235
|
if (isProjectReferenceWithinNxProject(resolvedRefPath, projectRoot, projectRoots) ||
|
|
236
|
-
isProjectReferenceIgnored(tree, resolvedRefPath)) {
|
|
236
|
+
isProjectReferenceIgnored(tree, tsconfigInfoCaches, resolvedRefPath)) {
|
|
237
237
|
// we keep all references within the current Nx project or that are ignored
|
|
238
238
|
references.push(ref);
|
|
239
239
|
newReferencesSet.add(normalizedPath);
|
|
@@ -313,7 +313,7 @@ function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsCon
|
|
|
313
313
|
// TODO(leo): follow up with the TypeScript team to confirm if we really need
|
|
314
314
|
// to reference transitive dependencies.
|
|
315
315
|
// Collect the dependencies of a project recursively sorted from root to leaf
|
|
316
|
-
function collectProjectDependencies(
|
|
316
|
+
function collectProjectDependencies(projectName, projectGraph, collectedDependencies) {
|
|
317
317
|
if (collectedDependencies.has(projectName)) {
|
|
318
318
|
// We've already collected the dependencies for this project
|
|
319
319
|
return collectedDependencies.get(projectName);
|
|
@@ -335,7 +335,7 @@ function collectProjectDependencies(tree, projectName, projectGraph, collectedDe
|
|
|
335
335
|
continue;
|
|
336
336
|
}
|
|
337
337
|
// Recursively get the dependencies of the target project
|
|
338
|
-
const transitiveDependencies = collectProjectDependencies(
|
|
338
|
+
const transitiveDependencies = collectProjectDependencies(dep.target, projectGraph, collectedDependencies);
|
|
339
339
|
for (const transitiveDep of transitiveDependencies) {
|
|
340
340
|
if (!collectedDependencies
|
|
341
341
|
.get(projectName)
|
|
@@ -374,16 +374,19 @@ function isProjectReferenceWithinNxProject(refTsConfigPath, projectRoot, project
|
|
|
374
374
|
// it's inside the project root, so it's an internal project reference
|
|
375
375
|
return true;
|
|
376
376
|
}
|
|
377
|
-
function isProjectReferenceIgnored(tree, refTsConfigPath) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
377
|
+
function isProjectReferenceIgnored(tree, tsconfigInfoCaches, refTsConfigPath) {
|
|
378
|
+
if (!tsconfigInfoCaches.ignore) {
|
|
379
|
+
const ig = (0, ignore_1.default)();
|
|
380
|
+
if (tree.exists('.gitignore')) {
|
|
381
|
+
ig.add('.git');
|
|
382
|
+
ig.add(tree.read('.gitignore', 'utf-8'));
|
|
383
|
+
}
|
|
384
|
+
if (tree.exists('.nxignore')) {
|
|
385
|
+
ig.add(tree.read('.nxignore', 'utf-8'));
|
|
386
|
+
}
|
|
387
|
+
tsconfigInfoCaches.ignore = ig;
|
|
385
388
|
}
|
|
386
|
-
return
|
|
389
|
+
return tsconfigInfoCaches.ignore.ignores(refTsConfigPath);
|
|
387
390
|
}
|
|
388
391
|
function getTsConfigDirName(tsConfigPath) {
|
|
389
392
|
return tsConfigPath.endsWith('.json')
|
|
@@ -409,7 +412,10 @@ function patchTsconfigJsonReferences(tree, tsconfigInfoCaches, tsconfigPath, upd
|
|
|
409
412
|
}
|
|
410
413
|
function hasCompositeEnabled(tsSysFromTree, tsconfigInfoCaches, tsconfigPath) {
|
|
411
414
|
if (!tsconfigInfoCaches.composite.has(tsconfigPath)) {
|
|
412
|
-
const parsed = parseTsconfig(tsconfigPath,
|
|
415
|
+
const parsed = parseTsconfig(tsconfigPath, {
|
|
416
|
+
...tsSysFromTree,
|
|
417
|
+
readDirectory: () => [],
|
|
418
|
+
});
|
|
413
419
|
tsconfigInfoCaches.composite.set(tsconfigPath, parsed.options.composite === true);
|
|
414
420
|
}
|
|
415
421
|
return tsconfigInfoCaches.composite.get(tsconfigPath);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export default function replaceBabelClassPropertiesLoose(tree: Tree): Promise<{
|
|
3
|
+
nextSteps: string[];
|
|
4
|
+
agentContext: string[];
|
|
5
|
+
skipAgentic?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
nextSteps?: undefined;
|
|
8
|
+
agentContext?: undefined;
|
|
9
|
+
skipAgentic: boolean;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = replaceBabelClassPropertiesLoose;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const jsonc_parser_1 = require("jsonc-parser");
|
|
7
|
+
const FORMATTING_OPTIONS = {
|
|
8
|
+
formattingOptions: { keepLines: true, insertSpaces: true, tabSize: 2 },
|
|
9
|
+
};
|
|
10
|
+
const JSON_CONFIG_FILES = new Set([
|
|
11
|
+
'.babelrc',
|
|
12
|
+
'.babelrc.json',
|
|
13
|
+
'babel.config.json',
|
|
14
|
+
]);
|
|
15
|
+
const JS_CONFIG_FILE = /^(\.babelrc|babel\.config)\.(c|m)?(js|ts)$/;
|
|
16
|
+
// `@nx/react/babel` and `@nx/web/babel` forward their options to `@nx/js/babel`.
|
|
17
|
+
const NX_PRESETS = new Set([
|
|
18
|
+
'@nx/js/babel',
|
|
19
|
+
'@nx/react/babel',
|
|
20
|
+
'@nx/web/babel',
|
|
21
|
+
]);
|
|
22
|
+
async function replaceBabelClassPropertiesLoose(tree) {
|
|
23
|
+
const unparsable = [];
|
|
24
|
+
const jsConfigs = [];
|
|
25
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '', (path) => {
|
|
26
|
+
const name = (0, node_path_1.basename)(path);
|
|
27
|
+
const isJson = JSON_CONFIG_FILES.has(name);
|
|
28
|
+
if (!isJson && !JS_CONFIG_FILE.test(name))
|
|
29
|
+
return;
|
|
30
|
+
const content = tree.read(path, 'utf-8');
|
|
31
|
+
if (!isJson) {
|
|
32
|
+
// Preset options may be imported from another file, so flag every JS
|
|
33
|
+
// config that uses an Nx preset.
|
|
34
|
+
if ([...NX_PRESETS].some((preset) => content.includes(preset))) {
|
|
35
|
+
jsConfigs.push(path);
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!content.includes('classProperties'))
|
|
40
|
+
return;
|
|
41
|
+
const errors = [];
|
|
42
|
+
const config = (0, jsonc_parser_1.parse)(content, errors, { allowTrailingComma: true });
|
|
43
|
+
if (errors.length || !config || typeof config !== 'object') {
|
|
44
|
+
unparsable.push(path);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
let updated = content;
|
|
48
|
+
for (const optionsPath of findNxPresetOptions(config)) {
|
|
49
|
+
const options = getAt(config, optionsPath);
|
|
50
|
+
if (!options || !('classProperties' in options))
|
|
51
|
+
continue;
|
|
52
|
+
// `classProperties.loose` used to take precedence over `loose`.
|
|
53
|
+
const loose = options.classProperties?.loose;
|
|
54
|
+
if (loose !== undefined) {
|
|
55
|
+
updated = (0, jsonc_parser_1.applyEdits)(updated, (0, jsonc_parser_1.modify)(updated, [...optionsPath, 'loose'], loose, FORMATTING_OPTIONS));
|
|
56
|
+
}
|
|
57
|
+
updated = (0, jsonc_parser_1.applyEdits)(updated, (0, jsonc_parser_1.modify)(updated, [...optionsPath, 'classProperties'], undefined, FORMATTING_OPTIONS));
|
|
58
|
+
}
|
|
59
|
+
if (updated !== content)
|
|
60
|
+
tree.write(path, updated);
|
|
61
|
+
});
|
|
62
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
63
|
+
const nextSteps = [
|
|
64
|
+
...unparsable.map((path) => `Could not parse ${path}. If it passes \`classProperties.loose\` to an Nx babel preset, replace it with the \`loose\` option.`),
|
|
65
|
+
...jsConfigs.map((path) => `${path} uses an Nx babel preset. If its preset options set \`classProperties.loose\`, replace it with the \`loose\` option.`),
|
|
66
|
+
];
|
|
67
|
+
return nextSteps.length
|
|
68
|
+
? { nextSteps, agentContext: nextSteps }
|
|
69
|
+
: { skipAgentic: true };
|
|
70
|
+
}
|
|
71
|
+
// Babel accepts presets at the top level, under `env.<name>`, in `overrides[]`
|
|
72
|
+
// and under `overrides[].env.<name>`.
|
|
73
|
+
function findNxPresetOptions(config) {
|
|
74
|
+
const scopes = [[]];
|
|
75
|
+
(Array.isArray(config.overrides) ? config.overrides : []).forEach((_, i) => scopes.push(['overrides', i]));
|
|
76
|
+
for (const scope of [...scopes]) {
|
|
77
|
+
for (const env of Object.keys(getAt(config, [...scope, 'env']) ?? {})) {
|
|
78
|
+
scopes.push([...scope, 'env', env]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const result = [];
|
|
82
|
+
for (const scope of scopes) {
|
|
83
|
+
const presets = getAt(config, [...scope, 'presets']);
|
|
84
|
+
if (!Array.isArray(presets))
|
|
85
|
+
continue;
|
|
86
|
+
presets.forEach((preset, i) => {
|
|
87
|
+
if (Array.isArray(preset) &&
|
|
88
|
+
NX_PRESETS.has(preset[0]) &&
|
|
89
|
+
preset[1] &&
|
|
90
|
+
typeof preset[1] === 'object') {
|
|
91
|
+
result.push([...scope, 'presets', i, 1]);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
function getAt(value, path) {
|
|
98
|
+
return path.reduce((current, key) => current?.[key], value);
|
|
99
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#### Replace the `classProperties.loose` babel preset option with `loose`
|
|
2
|
+
|
|
3
|
+
The `classProperties` option of the `@nx/js/babel`, `@nx/react/babel` and `@nx/web/babel` presets is removed. Its `loose` value moves to the preset's `loose` option, so class fields compile the same way as before. When both are set, the `classProperties.loose` value is kept, because it used to take precedence.
|
|
4
|
+
|
|
5
|
+
The migration updates `.babelrc`, `.babelrc.json` and `babel.config.json` files, including presets under `env` and `overrides`. It lists JavaScript babel config files that use an Nx preset, and JSON files it cannot parse, so you can check them by hand.
|
|
6
|
+
|
|
7
|
+
#### Sample code changes
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```json title="libs/my-lib/.babelrc"
|
|
12
|
+
{
|
|
13
|
+
"presets": [
|
|
14
|
+
[
|
|
15
|
+
"@nx/js/babel",
|
|
16
|
+
{
|
|
17
|
+
"useBuiltIns": "usage",
|
|
18
|
+
"classProperties": {
|
|
19
|
+
"loose": false
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
##### After
|
|
28
|
+
|
|
29
|
+
```json title="libs/my-lib/.babelrc"
|
|
30
|
+
{
|
|
31
|
+
"presets": [
|
|
32
|
+
[
|
|
33
|
+
"@nx/js/babel",
|
|
34
|
+
{
|
|
35
|
+
"useBuiltIns": "usage",
|
|
36
|
+
"loose": false
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
```
|
|
@@ -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.
|
|
@@ -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
|
+
}
|
|
@@ -27,7 +27,7 @@ function detectTransformerFormat(plugin) {
|
|
|
27
27
|
}
|
|
28
28
|
return TransformerFormat.UNKNOWN;
|
|
29
29
|
}
|
|
30
|
-
function adaptFunctionBasedTransformer(plugin
|
|
30
|
+
function adaptFunctionBasedTransformer(plugin) {
|
|
31
31
|
// Handle direct function export
|
|
32
32
|
if (typeof plugin === 'function') {
|
|
33
33
|
return {
|
|
@@ -102,7 +102,7 @@ function loadTsTransformers(plugins, moduleResolver = require.resolve) {
|
|
|
102
102
|
// Adapt function-based transformers to standard format
|
|
103
103
|
if (format === TransformerFormat.FUNCTION_EXPORT) {
|
|
104
104
|
devkit_1.logger.debug(`Adapting function-based transformer: ${pluginName}`);
|
|
105
|
-
plugin = adaptFunctionBasedTransformer(plugin
|
|
105
|
+
plugin = adaptFunctionBasedTransformer(plugin);
|
|
106
106
|
}
|
|
107
107
|
else if (format === TransformerFormat.UNKNOWN) {
|
|
108
108
|
devkit_1.logger.warn(`${pluginName} is not a recognized Transformer Plugin format. It should export ` +
|
package/migrations.json
CHANGED
|
@@ -58,6 +58,12 @@
|
|
|
58
58
|
"description": "Add the workspace root pnpm-workspace.yaml, the pnpm settings fields of the root package.json, and a pnpm-major runtime probe to the inputs of build targets that emit the pruned pnpm deploy output (webpack, rspack, vite, esbuild with generatePackageJson; next, remix, tsc, swc with generateLockfile), so revoking a build-script approval, changing another pnpm install setting, or crossing the pnpm 10/11 boundary does not replay a cached output that still carries the old one.",
|
|
59
59
|
"implementation": "./dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs",
|
|
60
60
|
"documentation": "./dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs.md"
|
|
61
|
+
},
|
|
62
|
+
"update-24-1-0-replace-babel-class-properties-loose": {
|
|
63
|
+
"version": "24.1.0-beta.0",
|
|
64
|
+
"description": "Replaces the removed `classProperties.loose` option with `loose` for the `@nx/js/babel`, `@nx/react/babel` and `@nx/web/babel` presets in JSON babel config files.",
|
|
65
|
+
"implementation": "./dist/src/migrations/update-24-1-0/replace-babel-class-properties-loose",
|
|
66
|
+
"documentation": "./dist/src/migrations/update-24-1-0/replace-babel-class-properties-loose.md"
|
|
61
67
|
}
|
|
62
68
|
},
|
|
63
69
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "24.0.
|
|
3
|
+
"version": "24.1.0-beta.0",
|
|
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.1.0-beta.0",
|
|
166
|
+
"@nx/workspace": "24.1.0-beta.0",
|
|
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.1.0-beta.0",
|
|
187
|
+
"@nx/eslint": "24.1.0-beta.0",
|
|
188
|
+
"@nx/jest": "24.1.0-beta.0",
|
|
189
|
+
"@nx/oxlint": "24.1.0-beta.0",
|
|
190
|
+
"@nx/rollup": "24.1.0-beta.0",
|
|
191
|
+
"@nx/vite": "24.1.0-beta.0",
|
|
192
|
+
"@nx/vitest": "24.1.0-beta.0",
|
|
193
|
+
"nx": "24.1.0-beta.0"
|
|
194
194
|
},
|
|
195
195
|
"peerDependencies": {
|
|
196
196
|
"@swc/cli": ">=0.6.0 <0.9.0",
|