@nx/react 23.0.0-beta.17 → 23.0.0-beta.19

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/index.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- import { NxReactWebpackPlugin as _NxReactWebpackPlugin } from './plugins/nx-react-webpack-plugin/nx-react-webpack-plugin';
2
- /** @deprecated Use '@nx/react/webpack-plugin' instead, which can improve graph creation by 150-200ms per file. */
3
- export declare const NxReactWebpackPlugin: typeof _NxReactWebpackPlugin;
4
1
  export { extraEslintDependencies, extendReactEslintJson, } from './src/utils/lint';
5
2
  export { assertValidStyle } from './src/utils/assertion';
6
3
  export { reactDomVersion, reactVersion } from './src/utils/versions';
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,IAAI,qBAAqB,EAAE,MAAM,2DAA2D,CAAC;AAE1H,kHAAkH;AAClH,eAAO,MAAM,oBAAoB,8BAAwB,CAAC;AAE1D,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,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;AACjE,OAAO,EAAE,+BAA+B,EAAE,MAAM,kFAAkF,CAAC;AACnI,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,cAAc,sBAAsB,CAAC"}
package/index.js CHANGED
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.remoteGenerator = exports.hostGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.hookGenerator = exports.componentGenerator = exports.applicationGenerator = exports.reactVersion = exports.reactDomVersion = exports.assertValidStyle = exports.extendReactEslintJson = exports.extraEslintDependencies = exports.NxReactWebpackPlugin = void 0;
3
+ exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.remoteGenerator = exports.hostGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.hookGenerator = exports.componentGenerator = exports.applicationGenerator = exports.reactVersion = exports.reactDomVersion = exports.assertValidStyle = exports.extendReactEslintJson = exports.extraEslintDependencies = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const nx_react_webpack_plugin_1 = require("./plugins/nx-react-webpack-plugin/nx-react-webpack-plugin");
6
- /** @deprecated Use '@nx/react/webpack-plugin' instead, which can improve graph creation by 150-200ms per file. */
7
- exports.NxReactWebpackPlugin = nx_react_webpack_plugin_1.NxReactWebpackPlugin;
8
5
  var lint_1 = require("./src/utils/lint");
9
6
  Object.defineProperty(exports, "extraEslintDependencies", { enumerable: true, get: function () { return lint_1.extraEslintDependencies; } });
10
7
  Object.defineProperty(exports, "extendReactEslintJson", { enumerable: true, get: function () { return lint_1.extendReactEslintJson; } });
package/migrations.json CHANGED
@@ -35,6 +35,12 @@
35
35
  "version": "22.0.0-beta.0",
36
36
  "description": "Updates webpack configs using React to use the new withSvgr composable function instead of the svgr option in withReact or NxReactWebpackPlugin.",
37
37
  "factory": "./src/migrations/update-22-0-0/add-svgr-to-webpack-config"
38
+ },
39
+ "update-23-0-0-remove-nx-react-webpack-plugin-import": {
40
+ "cli": "nx",
41
+ "version": "23.0.0-beta.10",
42
+ "description": "Rewrites imports of NxReactWebpackPlugin from '@nx/react' to the sub-path '@nx/react/webpack-plugin'.",
43
+ "factory": "./src/migrations/update-23-0-0/remove-nx-react-webpack-plugin-import"
38
44
  }
39
45
  },
40
46
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "23.0.0-beta.17",
3
+ "version": "23.0.0-beta.19",
4
4
  "private": false,
5
5
  "description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -37,28 +37,28 @@
37
37
  "@svgr/webpack": "^8.0.1",
38
38
  "minimatch": "10.2.5",
39
39
  "tslib": "^2.3.0",
40
- "@nx/devkit": "23.0.0-beta.17",
41
- "@nx/js": "23.0.0-beta.17",
42
- "@nx/eslint": "23.0.0-beta.17",
43
- "@nx/web": "23.0.0-beta.17",
44
- "@nx/module-federation": "23.0.0-beta.17",
45
- "@nx/rollup": "23.0.0-beta.17",
40
+ "@nx/devkit": "23.0.0-beta.19",
41
+ "@nx/js": "23.0.0-beta.19",
42
+ "@nx/eslint": "23.0.0-beta.19",
43
+ "@nx/web": "23.0.0-beta.19",
44
+ "@nx/module-federation": "23.0.0-beta.19",
45
+ "@nx/rollup": "23.0.0-beta.19",
46
46
  "express": "^4.21.2",
47
47
  "http-proxy-middleware": "^3.0.5",
48
48
  "semver": "^7.6.3"
49
49
  },
50
50
  "devDependencies": {
51
- "@nx/cypress": "23.0.0-beta.17",
52
- "@nx/playwright": "23.0.0-beta.17",
53
- "@nx/rsbuild": "23.0.0-beta.17",
54
- "@nx/vite": "23.0.0-beta.17",
55
- "@nx/vitest": "23.0.0-beta.17",
56
- "@nx/webpack": "23.0.0-beta.17",
57
- "@nx/storybook": "23.0.0-beta.17",
58
- "nx": "23.0.0-beta.17"
51
+ "@nx/cypress": "23.0.0-beta.19",
52
+ "@nx/playwright": "23.0.0-beta.19",
53
+ "@nx/rsbuild": "23.0.0-beta.19",
54
+ "@nx/vite": "23.0.0-beta.19",
55
+ "@nx/vitest": "23.0.0-beta.19",
56
+ "@nx/webpack": "23.0.0-beta.19",
57
+ "@nx/storybook": "23.0.0-beta.19",
58
+ "nx": "23.0.0-beta.19"
59
59
  },
60
60
  "optionalDependencies": {
61
- "@nx/vite": "23.0.0-beta.17"
61
+ "@nx/vite": "23.0.0-beta.19"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nxComponentTestingPreset = nxComponentTestingPreset;
4
4
  const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
5
- const ct_helpers_1 = require("@nx/cypress/src/utils/ct-helpers");
5
+ const internal_1 = require("@nx/cypress/internal");
6
6
  const devkit_1 = require("@nx/devkit");
7
- const internal_1 = require("@nx/js/internal");
7
+ const internal_2 = require("@nx/js/internal");
8
8
  const fs_1 = require("fs");
9
9
  const path_1 = require("path");
10
10
  /**
@@ -71,10 +71,10 @@ function nxComponentTestingPreset(pathToConfig, options) {
71
71
  let webpackConfig = null;
72
72
  try {
73
73
  const graph = (0, devkit_1.readCachedProjectGraph)();
74
- const { targets: ctTargets, name: ctProjectName } = (0, ct_helpers_1.getProjectConfigByPath)(graph, pathToConfig);
74
+ const { targets: ctTargets, name: ctProjectName } = (0, internal_1.getProjectConfigByPath)(graph, pathToConfig);
75
75
  const ctTargetName = options?.ctTargetName || 'component-test';
76
76
  const ctConfigurationName = process.env.NX_CYPRESS_TARGET_CONFIGURATION;
77
- const ctExecutorContext = (0, ct_helpers_1.createExecutorContext)(graph, ctTargets, ctProjectName, ctTargetName, ctConfigurationName);
77
+ const ctExecutorContext = (0, internal_1.createExecutorContext)(graph, ctTargets, ctProjectName, ctTargetName, ctConfigurationName);
78
78
  let buildTarget = options?.buildTarget;
79
79
  if (!buildTarget) {
80
80
  const ctExecutorOptions = (0, devkit_1.readTargetOptions)({
@@ -161,13 +161,13 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
161
161
  throw new InvalidExecutorError(`The '${parsed.target}' target of the '${parsed.project}' project is not using the '@nx/webpack:webpack' or '@nx/rspack:rspack' executor. ` +
162
162
  `Please make sure to use '@nx/webpack:webpack' or '@nx/rspack:rspack' executor in that target to use Cypress Component Testing.`);
163
163
  }
164
- const context = (0, ct_helpers_1.createExecutorContext)(graph, buildableProjectConfig.targets, parsed.project, parsed.target, parsed.target);
164
+ const context = (0, internal_1.createExecutorContext)(graph, buildableProjectConfig.targets, parsed.project, parsed.target, parsed.target);
165
165
  const { normalizeOptions, } = require('@nx/webpack/src/executors/webpack/lib/normalize-options');
166
166
  const { resolveUserDefinedWebpackConfig, } = require('@nx/webpack/src/utils/webpack/resolve-user-defined-webpack-config');
167
167
  const { composePluginsSync } = require('@nx/webpack/src/utils/config');
168
168
  const { withNx } = require('@nx/webpack/src/utils/with-nx');
169
169
  const { withWeb } = require('@nx/webpack/src/utils/with-web');
170
- const options = normalizeOptions(withSchemaDefaults(parsed, context), devkit_1.workspaceRoot, buildableProjectConfig.root, (0, internal_1.getProjectSourceRoot)(buildableProjectConfig));
170
+ const options = normalizeOptions(withSchemaDefaults(parsed, context), devkit_1.workspaceRoot, buildableProjectConfig.root, (0, internal_2.getProjectSourceRoot)(buildableProjectConfig));
171
171
  let customWebpack;
172
172
  if (options.webpackConfig) {
173
173
  customWebpack = resolveUserDefinedWebpackConfig(options.webpackConfig, options.tsConfig.startsWith(context.root)
@@ -189,7 +189,7 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
189
189
  extractLicenses: false,
190
190
  root: devkit_1.workspaceRoot,
191
191
  projectRoot: ctProjectConfig.root,
192
- sourceRoot: (0, internal_1.getProjectSourceRoot)(ctProjectConfig),
192
+ sourceRoot: (0, internal_2.getProjectSourceRoot)(ctProjectConfig),
193
193
  },
194
194
  context,
195
195
  configuration: parsed.configuration,
@@ -1 +1 @@
1
- {"version":3,"file":"add-vite.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/react/src/generators/application/lib/bundlers/add-vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAoC,MAAM,YAAY,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAExD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,GAAG,EAAE,iBA8Db;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,GAAG,EAAE,iBA0Cb"}
1
+ {"version":3,"file":"add-vite.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/react/src/generators/application/lib/bundlers/add-vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAoC,MAAM,YAAY,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAExD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,GAAG,EAAE,iBAkEb;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,GAAG,EAAE,iBA8Cb"}
@@ -79,7 +79,11 @@ async function setupViteConfiguration(tree, options, tasks) {
79
79
  includeLib: false,
80
80
  includeVitest: options.unitTestRunner === 'vitest',
81
81
  inSourceTests: options.inSourceTests,
82
- rollupOptionsExternal: ["'react'", "'react-dom'", "'react/jsx-runtime'"],
82
+ rolldownOptionsExternal: [
83
+ "'react'",
84
+ "'react-dom'",
85
+ "'react/jsx-runtime'",
86
+ ],
83
87
  port: options.port,
84
88
  previewPort: options.port,
85
89
  useEsmExtension: true,
@@ -106,7 +110,11 @@ async function setupVitestConfiguration(tree, options, tasks) {
106
110
  includeLib: false,
107
111
  includeVitest: true,
108
112
  inSourceTests: options.inSourceTests,
109
- rollupOptionsExternal: ["'react'", "'react-dom'", "'react/jsx-runtime'"],
113
+ rolldownOptionsExternal: [
114
+ "'react'",
115
+ "'react-dom'",
116
+ "'react/jsx-runtime'",
117
+ ],
110
118
  imports: [
111
119
  options.compiler === 'swc'
112
120
  ? `import react from '@vitejs/plugin-react-swc'`
@@ -1,4 +1,4 @@
1
- import type { FoundTarget } from '@nx/cypress/src/utils/find-target-options';
1
+ import type { FoundTarget } from '@nx/cypress/internal';
2
2
  import { ProjectConfiguration, Tree } from '@nx/devkit';
3
3
  import type { CypressComponentConfigurationSchema } from '../schema';
4
4
  export declare function addFiles(tree: Tree, projectConfig: ProjectConfiguration, options: CypressComponentConfigurationSchema, found: FoundTarget): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"add-files.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/cypress-component-configuration/lib/add-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAIL,oBAAoB,EACpB,IAAI,EAEL,MAAM,YAAY,CAAC;AAKpB,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,WAAW,CAAC;AAErE,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,oBAAoB,EACnC,OAAO,EAAE,mCAAmC,EAC5C,KAAK,EAAE,WAAW,iBAqEnB"}
1
+ {"version":3,"file":"add-files.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/cypress-component-configuration/lib/add-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAIL,oBAAoB,EACpB,IAAI,EAEL,MAAM,YAAY,CAAC;AAKpB,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,WAAW,CAAC;AAErE,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,oBAAoB,EACnC,OAAO,EAAE,mCAAmC,EAC5C,KAAK,EAAE,WAAW,iBAqEnB"}
@@ -42,8 +42,8 @@ const component_test_1 = require("../../component-test/component-test");
42
42
  async function addFiles(tree, projectConfig, options, found) {
43
43
  // must dynamicaly import to prevent packages not using cypress from erroring out
44
44
  // when importing react
45
- const { addMountDefinition } = await Promise.resolve().then(() => __importStar(require('@nx/cypress/src/utils/config')));
46
- const { getInstalledCypressMajorVersion } = await Promise.resolve().then(() => __importStar(require('@nx/cypress/src/utils/versions')));
45
+ const { addMountDefinition } = await Promise.resolve().then(() => __importStar(require('@nx/cypress/internal')));
46
+ const { getInstalledCypressMajorVersion } = await Promise.resolve().then(() => __importStar(require('@nx/cypress/internal')));
47
47
  const installedCypressMajorVersion = getInstalledCypressMajorVersion(tree);
48
48
  // Specifically undefined to allow Remix workaround of passing an empty string
49
49
  const actualBundler = await (0, ct_utils_1.getActualBundler)(tree, options, found);
@@ -107,7 +107,7 @@ async function libraryGeneratorInternal(host, schema) {
107
107
  includeLib: true,
108
108
  includeVitest: options.unitTestRunner === 'vitest',
109
109
  inSourceTests: options.inSourceTests,
110
- rollupOptionsExternal: [
110
+ rolldownOptionsExternal: [
111
111
  "'react'",
112
112
  "'react-dom'",
113
113
  "'react/jsx-runtime'",
@@ -166,7 +166,7 @@ async function libraryGeneratorInternal(host, schema) {
166
166
  includeLib: true,
167
167
  includeVitest: true,
168
168
  inSourceTests: options.inSourceTests,
169
- rollupOptionsExternal: [
169
+ rolldownOptionsExternal: [
170
170
  "'react'",
171
171
  "'react-dom'",
172
172
  "'react/jsx-runtime'",
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function removeNxReactWebpackPluginImport(tree: Tree): Promise<void>;
3
+ //# sourceMappingURL=remove-nx-react-webpack-plugin-import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-nx-react-webpack-plugin-import.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/migrations/update-23-0-0/remove-nx-react-webpack-plugin-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAwB,MAAM,YAAY,CAAC;AA8BrE,wBAA8B,gCAAgC,CAAC,IAAI,EAAE,IAAI,iBAuHxE"}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = removeNxReactWebpackPluginImport;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
6
+ const DEPRECATED_SYMBOL = 'NxReactWebpackPlugin';
7
+ const DEPRECATED_PACKAGE = '@nx/react';
8
+ const NEW_PACKAGE = '@nx/react/webpack-plugin';
9
+ // ES module import: import { NxReactWebpackPlugin[, ...] } from '@nx/react'
10
+ const ES_IMPORT_SELECTOR = `ImportDeclaration:has(StringLiteral[value=${DEPRECATED_PACKAGE}]):has(ImportClause ImportSpecifier > Identifier[name=${DEPRECATED_SYMBOL}])`;
11
+ const IMPORT_SPECIFIERS_SELECTOR = `ImportClause ImportSpecifier`;
12
+ const TARGET_IMPORT_SPECIFIER_SELECTOR = `ImportClause ImportSpecifier > Identifier[name=${DEPRECATED_SYMBOL}]`;
13
+ const ES_MODULE_PATH_SELECTOR = `StringLiteral[value=${DEPRECATED_PACKAGE}]`;
14
+ // CJS require: const { NxReactWebpackPlugin[, ...] } = require('@nx/react')
15
+ const CJS_REQUIRE_STMT_SELECTOR = `VariableStatement:has(ObjectBindingPattern > BindingElement > Identifier[name=${DEPRECATED_SYMBOL}]):has(CallExpression:has(Identifier[name=require]) > StringLiteral[value=${DEPRECATED_PACKAGE}])`;
16
+ const CJS_BINDING_ELEMENTS_SELECTOR = `ObjectBindingPattern > BindingElement`;
17
+ const CJS_TARGET_BINDING_SELECTOR = `ObjectBindingPattern > BindingElement > Identifier[name=${DEPRECATED_SYMBOL}]`;
18
+ const CJS_REQUIRE_PATH_SELECTOR = `CallExpression:has(Identifier[name=require]) > StringLiteral[value=${DEPRECATED_PACKAGE}]`;
19
+ // Walk past whitespace from `fromIndex` to find a trailing comma. Returns the
20
+ // position AFTER the comma if found, otherwise the original index. Handles
21
+ // the `Foo , withReact` shape where the user wrote whitespace before the
22
+ // comma — `node.getEnd()` stops at the identifier and the comma sits one
23
+ // character past the whitespace.
24
+ function endAfterTrailingComma(text, fromIndex) {
25
+ let i = fromIndex;
26
+ while (i < text.length && /\s/.test(text.charAt(i)))
27
+ i++;
28
+ return text.charAt(i) === ',' ? i + 1 : fromIndex;
29
+ }
30
+ async function removeNxReactWebpackPluginImport(tree) {
31
+ (0, devkit_1.visitNotIgnoredFiles)(tree, '', (filePath) => {
32
+ if (!filePath.endsWith('.ts') &&
33
+ !filePath.endsWith('.tsx') &&
34
+ !filePath.endsWith('.js') &&
35
+ !filePath.endsWith('.jsx') &&
36
+ !filePath.endsWith('.cjs') &&
37
+ !filePath.endsWith('.mjs')) {
38
+ return;
39
+ }
40
+ let contents = tree.read(filePath, 'utf-8');
41
+ if (!contents)
42
+ return;
43
+ // Quick check: must contain the deprecated symbol and the deprecated package path
44
+ if (!contents.includes(DEPRECATED_SYMBOL) ||
45
+ (!contents.includes(`'${DEPRECATED_PACKAGE}'`) &&
46
+ !contents.includes(`"${DEPRECATED_PACKAGE}"`))) {
47
+ return;
48
+ }
49
+ let changed = false;
50
+ // Re-parse on every iteration so multiple matches in the same file work
51
+ // correctly. The multi-specifier branch prepends a new declaration which
52
+ // shifts every offset; collected AST positions go stale after one rewrite,
53
+ // so process one match at a time.
54
+ let didRewrite = true;
55
+ while (didRewrite) {
56
+ didRewrite = false;
57
+ const sourceFile = (0, tsquery_1.ast)(contents);
58
+ const importNode = (0, tsquery_1.query)(sourceFile, ES_IMPORT_SELECTOR)[0];
59
+ if (importNode) {
60
+ const specifiers = (0, tsquery_1.query)(importNode, IMPORT_SPECIFIERS_SELECTOR);
61
+ const targetIdentifier = (0, tsquery_1.query)(importNode, TARGET_IMPORT_SPECIFIER_SELECTOR)[0];
62
+ if (targetIdentifier) {
63
+ // Walk to the ImportSpecifier to cover `Foo` and `Foo as Bar`.
64
+ const targetSpec = targetIdentifier.parent;
65
+ if (specifiers.length === 1) {
66
+ const modulePathNode = (0, tsquery_1.query)(importNode, ES_MODULE_PATH_SELECTOR)[0];
67
+ if (modulePathNode) {
68
+ contents =
69
+ contents.slice(0, modulePathNode.getStart()) +
70
+ `'${NEW_PACKAGE}'` +
71
+ contents.slice(modulePathNode.getEnd());
72
+ changed = true;
73
+ didRewrite = true;
74
+ continue;
75
+ }
76
+ }
77
+ else {
78
+ // Extract target spec verbatim (preserves alias)
79
+ const end = endAfterTrailingComma(contents, targetSpec.getEnd());
80
+ contents =
81
+ `import { ${targetSpec.getText()} } from '${NEW_PACKAGE}';\n` +
82
+ contents.slice(0, targetSpec.getStart()) +
83
+ contents.slice(end);
84
+ changed = true;
85
+ didRewrite = true;
86
+ continue;
87
+ }
88
+ }
89
+ }
90
+ const stmtNode = (0, tsquery_1.query)(sourceFile, CJS_REQUIRE_STMT_SELECTOR)[0];
91
+ if (stmtNode) {
92
+ const bindingElements = (0, tsquery_1.query)(stmtNode, CJS_BINDING_ELEMENTS_SELECTOR);
93
+ const targetIdentifier = (0, tsquery_1.query)(stmtNode, CJS_TARGET_BINDING_SELECTOR)[0];
94
+ if (targetIdentifier) {
95
+ // Walk to the BindingElement to cover `Foo` and `Foo: Bar`.
96
+ const targetBinding = targetIdentifier.parent;
97
+ if (bindingElements.length === 1) {
98
+ const requirePathNode = (0, tsquery_1.query)(stmtNode, CJS_REQUIRE_PATH_SELECTOR)[0];
99
+ if (requirePathNode) {
100
+ contents =
101
+ contents.slice(0, requirePathNode.getStart()) +
102
+ `'${NEW_PACKAGE}'` +
103
+ contents.slice(requirePathNode.getEnd());
104
+ changed = true;
105
+ didRewrite = true;
106
+ continue;
107
+ }
108
+ }
109
+ else {
110
+ // Extract target binding verbatim (preserves alias)
111
+ const end = endAfterTrailingComma(contents, targetBinding.getEnd());
112
+ contents =
113
+ `const { ${targetBinding.getText()} } = require('${NEW_PACKAGE}');\n` +
114
+ contents.slice(0, targetBinding.getStart()) +
115
+ contents.slice(end);
116
+ changed = true;
117
+ didRewrite = true;
118
+ continue;
119
+ }
120
+ }
121
+ }
122
+ }
123
+ if (changed) {
124
+ tree.write(filePath, contents);
125
+ }
126
+ });
127
+ await (0, devkit_1.formatFiles)(tree);
128
+ }
@@ -1,5 +1,5 @@
1
1
  import { Tree } from '@nx/devkit';
2
- import { type FoundTarget } from '@nx/cypress/src/utils/find-target-options';
2
+ import { type FoundTarget } from '@nx/cypress/internal';
3
3
  export declare function configureCypressCT(tree: Tree, options: {
4
4
  project: string;
5
5
  buildTarget: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ct-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/react/src/utils/ct-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,IAAI,EAEL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAQ7E,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MA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C,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAC/D,KAAK,EAAE,WAAW,+BASnB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAmBjE"}
@@ -48,7 +48,7 @@ async function configureCypressCT(tree, options) {
48
48
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
49
49
  // Specifically undefined as a workaround for Remix to pass an empty string as the buildTarget
50
50
  if (options.buildTarget === undefined) {
51
- const { findBuildConfig } = await Promise.resolve().then(() => __importStar(require('@nx/cypress/src/utils/find-target-options')));
51
+ const { findBuildConfig } = await Promise.resolve().then(() => __importStar(require('@nx/cypress/internal')));
52
52
  found = await findBuildConfig(tree, {
53
53
  project: options.project,
54
54
  buildTarget: options.buildTarget,
@@ -65,7 +65,7 @@ async function configureCypressCT(tree, options) {
65
65
  throw new Error(`Cypress Component Testing is not currently supported for this project. Either 'executer' is not defined in '${target} target' of '${project} project.json' or executer present is not valid one. Valid ones are ${JSON.stringify([...options.validExecutorNames])}. Please check https://github.com/nrwl/nx/issues/21546 for more information.`);
66
66
  }
67
67
  }
68
- const { addDefaultCTConfig, getProjectCypressConfigPath } = await Promise.resolve().then(() => __importStar(require('@nx/cypress/src/utils/config')));
68
+ const { addDefaultCTConfig, getProjectCypressConfigPath } = await Promise.resolve().then(() => __importStar(require('@nx/cypress/internal')));
69
69
  const ctConfigOptions = {
70
70
  bundler: options.bundler ?? (await getActualBundler(tree, options, found)),
71
71
  };