@nx/js 24.0.6 → 24.1.0-canary.20261111-edd9940
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 +1 -1
- package/dist/internal.js +2 -1
- package/dist/src/executors/verdaccio/verdaccio.impl.js +26 -0
- package/dist/src/generators/typescript-sync/typescript-sync.js +21 -17
- 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/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
|
@@ -35,4 +35,4 @@ export { stripGlobToBaseDir } from './src/utils/strip-glob-to-base-dir';
|
|
|
35
35
|
export { addLocalRegistryScripts } from './src/utils/add-local-registry-scripts';
|
|
36
36
|
export type { LibraryGeneratorSchema } from './src/generators/library/schema';
|
|
37
37
|
export { addReleaseConfigForNonTsSolution, addReleaseConfigForTsSolution, releaseTasks, } from './src/generators/library/utils/add-release-config';
|
|
38
|
-
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
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// the @nx/js equivalent of `@nx/devkit/internal`.
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
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;
|
|
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; } });
|
|
@@ -133,3 +133,4 @@ Object.defineProperty(exports, "swcHelpersVersion", { enumerable: true, get: fun
|
|
|
133
133
|
Object.defineProperty(exports, "swcNodeVersion", { enumerable: true, get: function () { return versions_1.swcNodeVersion; } });
|
|
134
134
|
Object.defineProperty(exports, "tsLibVersion", { enumerable: true, get: function () { return versions_1.tsLibVersion; } });
|
|
135
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) {
|
|
@@ -25,6 +25,7 @@ async function syncGenerator(tree) {
|
|
|
25
25
|
composite: new Map(),
|
|
26
26
|
content: new Map(),
|
|
27
27
|
exists: new Map(),
|
|
28
|
+
extendedConfigs: new Map(),
|
|
28
29
|
};
|
|
29
30
|
// Root tsconfig containing project references for the whole workspace
|
|
30
31
|
const rootTsconfigPath = 'tsconfig.json';
|
|
@@ -132,7 +133,7 @@ async function syncGenerator(tree) {
|
|
|
132
133
|
continue;
|
|
133
134
|
}
|
|
134
135
|
// Collect the dependencies of the source project
|
|
135
|
-
const dependencies = collectProjectDependencies(
|
|
136
|
+
const dependencies = collectProjectDependencies(projectName, projectGraph, collectedDependencies);
|
|
136
137
|
let foundRuntimeTsConfig = false;
|
|
137
138
|
for (const runtimeTsConfigFileName of runtimeTsConfigFileNames) {
|
|
138
139
|
const runtimeTsConfigPath = (0, devkit_1.joinPathFragments)(sourceProjectNode.data.root, runtimeTsConfigFileName);
|
|
@@ -148,7 +149,7 @@ async function syncGenerator(tree) {
|
|
|
148
149
|
// duplicate the project references in the tsconfig.json file
|
|
149
150
|
let keepReferencesInTsconfigJson = true;
|
|
150
151
|
if (foundRuntimeTsConfig) {
|
|
151
|
-
const sourceProjectTsconfig = parseTsconfig(sourceProjectTsconfigPath, tsSysFromTree);
|
|
152
|
+
const sourceProjectTsconfig = parseTsconfig(sourceProjectTsconfigPath, tsSysFromTree, tsconfigInfoCaches);
|
|
152
153
|
keepReferencesInTsconfigJson = sourceProjectTsconfig.fileNames.length > 0;
|
|
153
154
|
}
|
|
154
155
|
updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, sourceProjectTsconfigPath, keepReferencesInTsconfigJson ? dependencies : [], sourceProjectNode.data.root, projectRoots, changedFiles);
|
|
@@ -185,8 +186,8 @@ function readRawTsconfigContents(tree, tsconfigInfoCaches, tsconfigPath) {
|
|
|
185
186
|
}
|
|
186
187
|
return tsconfigInfoCaches.content.get(tsconfigPath);
|
|
187
188
|
}
|
|
188
|
-
function parseTsconfig(tsconfigPath, sys) {
|
|
189
|
-
return ts.parseJsonConfigFileContent(ts.readConfigFile(tsconfigPath, sys.readFile).config, sys, (0, posix_1.dirname)(tsconfigPath));
|
|
189
|
+
function parseTsconfig(tsconfigPath, sys, tsconfigInfoCaches) {
|
|
190
|
+
return ts.parseJsonConfigFileContent(ts.readConfigFile(tsconfigPath, sys.readFile).config, sys, (0, posix_1.dirname)(tsconfigPath), undefined, undefined, undefined, undefined, tsconfigInfoCaches.extendedConfigs);
|
|
190
191
|
}
|
|
191
192
|
/**
|
|
192
193
|
* Within the context of a sync generator, performance is a key concern,
|
|
@@ -233,7 +234,7 @@ function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsCon
|
|
|
233
234
|
// reference path is relative to the tsconfig file
|
|
234
235
|
const resolvedRefPath = getTsConfigPathFromReferencePath(tsConfigPath, ref.path);
|
|
235
236
|
if (isProjectReferenceWithinNxProject(resolvedRefPath, projectRoot, projectRoots) ||
|
|
236
|
-
isProjectReferenceIgnored(tree, resolvedRefPath)) {
|
|
237
|
+
isProjectReferenceIgnored(tree, tsconfigInfoCaches, resolvedRefPath)) {
|
|
237
238
|
// we keep all references within the current Nx project or that are ignored
|
|
238
239
|
references.push(ref);
|
|
239
240
|
newReferencesSet.add(normalizedPath);
|
|
@@ -313,7 +314,7 @@ function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsCon
|
|
|
313
314
|
// TODO(leo): follow up with the TypeScript team to confirm if we really need
|
|
314
315
|
// to reference transitive dependencies.
|
|
315
316
|
// Collect the dependencies of a project recursively sorted from root to leaf
|
|
316
|
-
function collectProjectDependencies(
|
|
317
|
+
function collectProjectDependencies(projectName, projectGraph, collectedDependencies) {
|
|
317
318
|
if (collectedDependencies.has(projectName)) {
|
|
318
319
|
// We've already collected the dependencies for this project
|
|
319
320
|
return collectedDependencies.get(projectName);
|
|
@@ -335,7 +336,7 @@ function collectProjectDependencies(tree, projectName, projectGraph, collectedDe
|
|
|
335
336
|
continue;
|
|
336
337
|
}
|
|
337
338
|
// Recursively get the dependencies of the target project
|
|
338
|
-
const transitiveDependencies = collectProjectDependencies(
|
|
339
|
+
const transitiveDependencies = collectProjectDependencies(dep.target, projectGraph, collectedDependencies);
|
|
339
340
|
for (const transitiveDep of transitiveDependencies) {
|
|
340
341
|
if (!collectedDependencies
|
|
341
342
|
.get(projectName)
|
|
@@ -374,16 +375,19 @@ function isProjectReferenceWithinNxProject(refTsConfigPath, projectRoot, project
|
|
|
374
375
|
// it's inside the project root, so it's an internal project reference
|
|
375
376
|
return true;
|
|
376
377
|
}
|
|
377
|
-
function isProjectReferenceIgnored(tree, refTsConfigPath) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
378
|
+
function isProjectReferenceIgnored(tree, tsconfigInfoCaches, refTsConfigPath) {
|
|
379
|
+
if (!tsconfigInfoCaches.ignore) {
|
|
380
|
+
const ig = (0, ignore_1.default)();
|
|
381
|
+
if (tree.exists('.gitignore')) {
|
|
382
|
+
ig.add('.git');
|
|
383
|
+
ig.add(tree.read('.gitignore', 'utf-8'));
|
|
384
|
+
}
|
|
385
|
+
if (tree.exists('.nxignore')) {
|
|
386
|
+
ig.add(tree.read('.nxignore', 'utf-8'));
|
|
387
|
+
}
|
|
388
|
+
tsconfigInfoCaches.ignore = ig;
|
|
385
389
|
}
|
|
386
|
-
return
|
|
390
|
+
return tsconfigInfoCaches.ignore.ignores(refTsConfigPath);
|
|
387
391
|
}
|
|
388
392
|
function getTsConfigDirName(tsConfigPath) {
|
|
389
393
|
return tsConfigPath.endsWith('.json')
|
|
@@ -409,7 +413,7 @@ function patchTsconfigJsonReferences(tree, tsconfigInfoCaches, tsconfigPath, upd
|
|
|
409
413
|
}
|
|
410
414
|
function hasCompositeEnabled(tsSysFromTree, tsconfigInfoCaches, tsconfigPath) {
|
|
411
415
|
if (!tsconfigInfoCaches.composite.has(tsconfigPath)) {
|
|
412
|
-
const parsed = parseTsconfig(tsconfigPath, tsSysFromTree);
|
|
416
|
+
const parsed = parseTsconfig(tsconfigPath, { ...tsSysFromTree, readDirectory: () => [] }, tsconfigInfoCaches);
|
|
413
417
|
tsconfigInfoCaches.composite.set(tsconfigPath, parsed.options.composite === true);
|
|
414
418
|
}
|
|
415
419
|
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
|
+
```
|
|
@@ -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-canary.20261111-edd9940",
|
|
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-canary.20261111-edd9940",
|
|
166
|
+
"@nx/workspace": "24.1.0-canary.20261111-edd9940",
|
|
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-canary.20261111-edd9940",
|
|
187
|
+
"@nx/eslint": "24.1.0-canary.20261111-edd9940",
|
|
188
|
+
"@nx/jest": "24.1.0-canary.20261111-edd9940",
|
|
189
|
+
"@nx/oxlint": "24.1.0-canary.20261111-edd9940",
|
|
190
|
+
"@nx/rollup": "24.1.0-canary.20261111-edd9940",
|
|
191
|
+
"@nx/vite": "24.1.0-canary.20261111-edd9940",
|
|
192
|
+
"@nx/vitest": "24.1.0-canary.20261111-edd9940",
|
|
193
|
+
"nx": "24.1.0-canary.20261111-edd9940"
|
|
194
194
|
},
|
|
195
195
|
"peerDependencies": {
|
|
196
196
|
"@swc/cli": ">=0.6.0 <0.9.0",
|