@nx/rollup 23.0.0-pr.35465.2bc2643 → 23.0.0-rc.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.
Files changed (148) hide show
  1. package/{index.d.ts → dist/index.d.ts} +0 -1
  2. package/dist/internal.d.ts +1 -0
  3. package/dist/internal.js +7 -0
  4. package/{plugin.d.ts → dist/plugin.d.ts} +0 -1
  5. package/{src → dist/src}/executors/rollup/lib/normalize.d.ts +0 -1
  6. package/{src → dist/src}/executors/rollup/lib/normalize.js +2 -2
  7. package/{src → dist/src}/executors/rollup/rollup.impl.d.ts +2 -3
  8. package/{src → dist/src}/executors/rollup/rollup.impl.js +9 -8
  9. package/{src → dist/src}/executors/rollup/schema.d.ts +0 -1
  10. package/{src → dist/src}/executors/rollup/schema.json +2 -6
  11. package/{src → dist/src}/generators/configuration/configuration.d.ts +0 -1
  12. package/{src → dist/src}/generators/configuration/configuration.js +14 -12
  13. package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.d.ts +0 -1
  14. package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.js +11 -6
  15. package/{src → dist/src}/generators/convert-to-inferred/lib/add-plugin-registrations.d.ts +0 -1
  16. package/{src → dist/src}/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.d.ts +0 -1
  17. package/{src → dist/src}/generators/convert-to-inferred/lib/normalize-path-options.d.ts +0 -1
  18. package/{src → dist/src}/generators/init/init.d.ts +0 -1
  19. package/{src → dist/src}/generators/init/init.js +10 -8
  20. package/{src → dist/src}/generators/init/schema.json +1 -1
  21. package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.d.ts +9 -0
  22. package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.js +223 -0
  23. package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.md +25 -0
  24. package/dist/src/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.d.ts +2 -0
  25. package/dist/src/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.js +125 -0
  26. package/dist/src/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.md +100 -0
  27. package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
  28. package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +202 -0
  29. package/{src → dist/src}/plugins/analyze.d.ts +0 -1
  30. package/{src → dist/src}/plugins/delete-output.d.ts +0 -1
  31. package/{src → dist/src}/plugins/nx-copy-assets.plugin.d.ts +1 -2
  32. package/{src → dist/src}/plugins/nx-copy-assets.plugin.js +2 -2
  33. package/{src → dist/src}/plugins/package-json/generate-package-json.d.ts +0 -1
  34. package/{src → dist/src}/plugins/package-json/update-package-json.d.ts +0 -1
  35. package/{src → dist/src}/plugins/plugin.d.ts +3 -4
  36. package/{src → dist/src}/plugins/plugin.js +58 -27
  37. package/{src → dist/src}/plugins/postcss/index.d.ts +0 -1
  38. package/{src → dist/src}/plugins/postcss/loaders/index.d.ts +0 -1
  39. package/{src → dist/src}/plugins/postcss/loaders/less-loader.d.ts +0 -1
  40. package/{src → dist/src}/plugins/postcss/loaders/postcss-loader.d.ts +0 -1
  41. package/{src → dist/src}/plugins/postcss/loaders/sass-loader.d.ts +0 -1
  42. package/{src → dist/src}/plugins/postcss/loaders/stylus-loader.d.ts +0 -1
  43. package/{src → dist/src}/plugins/postcss/loaders/types.d.ts +0 -1
  44. package/{src → dist/src}/plugins/postcss/options.d.ts +0 -1
  45. package/{src → dist/src}/plugins/postcss/postcss-plugin.d.ts +0 -1
  46. package/{src → dist/src}/plugins/postcss/utils/index.d.ts +0 -1
  47. package/{src → dist/src}/plugins/postcss/utils/load-module.d.ts +0 -1
  48. package/{src → dist/src}/plugins/postcss/utils/normalize-path.d.ts +0 -1
  49. package/{src → dist/src}/plugins/postcss/utils/safe-identifier.d.ts +0 -1
  50. package/{src → dist/src}/plugins/postcss/utils/style-inject.d.ts +0 -1
  51. package/{src → dist/src}/plugins/swc.d.ts +0 -1
  52. package/{src → dist/src}/plugins/with-nx/get-project-node.d.ts +0 -1
  53. package/{src → dist/src}/plugins/with-nx/normalize-options.d.ts +0 -1
  54. package/{src → dist/src}/plugins/with-nx/normalize-options.js +3 -8
  55. package/dist/src/plugins/with-nx/type-definitions.d.ts +7 -0
  56. package/dist/src/plugins/with-nx/type-definitions.js +48 -0
  57. package/{src → dist/src}/plugins/with-nx/with-nx-options.d.ts +0 -5
  58. package/{src → dist/src}/plugins/with-nx/with-nx.d.ts +1 -2
  59. package/{src → dist/src}/plugins/with-nx/with-nx.js +26 -43
  60. package/dist/src/utils/deprecation.d.ts +3 -0
  61. package/dist/src/utils/deprecation.js +19 -0
  62. package/{src → dist/src}/utils/ensure-dependencies.d.ts +0 -1
  63. package/{src → dist/src}/utils/ensure-dependencies.js +10 -10
  64. package/{src → dist/src}/utils/fs.d.ts +0 -1
  65. package/{src → dist/src}/utils/has-plugin.d.ts +0 -1
  66. package/{src → dist/src}/utils/versions.d.ts +3 -1
  67. package/dist/src/utils/versions.js +18 -0
  68. package/{with-nx.d.ts → dist/with-nx.d.ts} +0 -1
  69. package/executors.json +2 -2
  70. package/generators.json +6 -6
  71. package/migrations.json +31 -2
  72. package/package.json +66 -12
  73. package/index.d.ts.map +0 -1
  74. package/plugin.d.ts.map +0 -1
  75. package/src/executors/rollup/lib/normalize.d.ts.map +0 -1
  76. package/src/executors/rollup/rollup.impl.d.ts.map +0 -1
  77. package/src/generators/configuration/configuration.d.ts.map +0 -1
  78. package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +0 -1
  79. package/src/generators/convert-to-inferred/lib/add-plugin-registrations.d.ts.map +0 -1
  80. package/src/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.d.ts.map +0 -1
  81. package/src/generators/convert-to-inferred/lib/normalize-path-options.d.ts.map +0 -1
  82. package/src/generators/init/init.d.ts.map +0 -1
  83. package/src/plugins/analyze.d.ts.map +0 -1
  84. package/src/plugins/delete-output.d.ts.map +0 -1
  85. package/src/plugins/nx-copy-assets.plugin.d.ts.map +0 -1
  86. package/src/plugins/package-json/generate-package-json.d.ts.map +0 -1
  87. package/src/plugins/package-json/update-package-json.d.ts.map +0 -1
  88. package/src/plugins/plugin.d.ts.map +0 -1
  89. package/src/plugins/postcss/index.d.ts.map +0 -1
  90. package/src/plugins/postcss/loaders/index.d.ts.map +0 -1
  91. package/src/plugins/postcss/loaders/less-loader.d.ts.map +0 -1
  92. package/src/plugins/postcss/loaders/postcss-loader.d.ts.map +0 -1
  93. package/src/plugins/postcss/loaders/sass-loader.d.ts.map +0 -1
  94. package/src/plugins/postcss/loaders/stylus-loader.d.ts.map +0 -1
  95. package/src/plugins/postcss/loaders/types.d.ts.map +0 -1
  96. package/src/plugins/postcss/options.d.ts.map +0 -1
  97. package/src/plugins/postcss/postcss-plugin.d.ts.map +0 -1
  98. package/src/plugins/postcss/utils/index.d.ts.map +0 -1
  99. package/src/plugins/postcss/utils/load-module.d.ts.map +0 -1
  100. package/src/plugins/postcss/utils/normalize-path.d.ts.map +0 -1
  101. package/src/plugins/postcss/utils/safe-identifier.d.ts.map +0 -1
  102. package/src/plugins/postcss/utils/style-inject.d.ts.map +0 -1
  103. package/src/plugins/swc.d.ts.map +0 -1
  104. package/src/plugins/with-nx/get-project-node.d.ts.map +0 -1
  105. package/src/plugins/with-nx/normalize-options.d.ts.map +0 -1
  106. package/src/plugins/with-nx/with-nx-options.d.ts.map +0 -1
  107. package/src/plugins/with-nx/with-nx.d.ts.map +0 -1
  108. package/src/utils/ensure-dependencies.d.ts.map +0 -1
  109. package/src/utils/fs.d.ts.map +0 -1
  110. package/src/utils/has-plugin.d.ts.map +0 -1
  111. package/src/utils/versions.d.ts.map +0 -1
  112. package/src/utils/versions.js +0 -8
  113. package/with-nx.d.ts.map +0 -1
  114. /package/{LICENSE → dist/LICENSE} +0 -0
  115. /package/{index.js → dist/index.js} +0 -0
  116. /package/{plugin.js → dist/plugin.js} +0 -0
  117. /package/{src → dist/src}/generators/configuration/schema.d.ts +0 -0
  118. /package/{src → dist/src}/generators/configuration/schema.json +0 -0
  119. /package/{src → dist/src}/generators/convert-to-inferred/lib/add-plugin-registrations.js +0 -0
  120. /package/{src → dist/src}/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.js +0 -0
  121. /package/{src → dist/src}/generators/convert-to-inferred/lib/normalize-path-options.js +0 -0
  122. /package/{src → dist/src}/generators/convert-to-inferred/schema.json +0 -0
  123. /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
  124. /package/{src → dist/src}/plugins/analyze.js +0 -0
  125. /package/{src → dist/src}/plugins/delete-output.js +0 -0
  126. /package/{src → dist/src}/plugins/package-json/generate-package-json.js +0 -0
  127. /package/{src → dist/src}/plugins/package-json/update-package-json.js +0 -0
  128. /package/{src → dist/src}/plugins/postcss/index.js +0 -0
  129. /package/{src → dist/src}/plugins/postcss/loaders/index.js +0 -0
  130. /package/{src → dist/src}/plugins/postcss/loaders/less-loader.js +0 -0
  131. /package/{src → dist/src}/plugins/postcss/loaders/postcss-loader.js +0 -0
  132. /package/{src → dist/src}/plugins/postcss/loaders/sass-loader.js +0 -0
  133. /package/{src → dist/src}/plugins/postcss/loaders/stylus-loader.js +0 -0
  134. /package/{src → dist/src}/plugins/postcss/loaders/types.js +0 -0
  135. /package/{src → dist/src}/plugins/postcss/options.js +0 -0
  136. /package/{src → dist/src}/plugins/postcss/postcss-plugin.js +0 -0
  137. /package/{src → dist/src}/plugins/postcss/types/concat-with-sourcemaps.d.ts +0 -0
  138. /package/{src → dist/src}/plugins/postcss/utils/index.js +0 -0
  139. /package/{src → dist/src}/plugins/postcss/utils/load-module.js +0 -0
  140. /package/{src → dist/src}/plugins/postcss/utils/normalize-path.js +0 -0
  141. /package/{src → dist/src}/plugins/postcss/utils/safe-identifier.js +0 -0
  142. /package/{src → dist/src}/plugins/postcss/utils/style-inject.js +0 -0
  143. /package/{src → dist/src}/plugins/swc.js +0 -0
  144. /package/{src → dist/src}/plugins/with-nx/get-project-node.js +0 -0
  145. /package/{src → dist/src}/plugins/with-nx/with-nx-options.js +0 -0
  146. /package/{src → dist/src}/utils/fs.js +0 -0
  147. /package/{src → dist/src}/utils/has-plugin.js +0 -0
  148. /package/{with-nx.js → dist/with-nx.js} +0 -0
@@ -5,4 +5,3 @@ export declare const rollupProjectGenerator: typeof configurationGenerator;
5
5
  export * from './src/generators/init/init';
6
6
  export type { AssetGlobPattern, Globals, RollupExecutorOptions, } from './src/executors/rollup/schema';
7
7
  export * from './src/executors/rollup/rollup.impl';
8
- //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ export { hasPlugin } from './src/utils/has-plugin';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasPlugin = void 0;
4
+ // Curated internal API surface for other first-party Nx plugins. Prefer this
5
+ // over deep `@nx/rollup/src/*` imports — those are not part of the public API.
6
+ var has_plugin_1 = require("./src/utils/has-plugin");
7
+ Object.defineProperty(exports, "hasPlugin", { enumerable: true, get: function () { return has_plugin_1.hasPlugin; } });
@@ -1,2 +1 @@
1
1
  export { createNodes, createNodesV2, RollupPluginOptions, } from './src/plugins/plugin';
2
- //# sourceMappingURL=plugin.d.ts.map
@@ -6,4 +6,3 @@ export interface NormalizedRollupExecutorOptions extends RollupExecutorOptions {
6
6
  }
7
7
  export declare function normalizeRollupExecutorOptions(options: RollupExecutorOptions, context: ExecutorContext): NormalizedRollupExecutorOptions;
8
8
  export declare function normalizePluginPath(pluginPath: void | string, root: string): string;
9
- //# sourceMappingURL=normalize.d.ts.map
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeRollupExecutorOptions = normalizeRollupExecutorOptions;
4
4
  exports.normalizePluginPath = normalizePluginPath;
5
5
  const path_1 = require("path");
6
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
+ const internal_1 = require("@nx/js/internal");
7
7
  function normalizeRollupExecutorOptions(options, context) {
8
8
  const { root } = context;
9
- const skipTypeCheck = (0, ts_solution_setup_1.isUsingTsSolutionSetup)() ? true : options.skipTypeCheck;
9
+ const skipTypeCheck = (0, internal_1.isUsingTsSolutionSetup)() ? true : options.skipTypeCheck;
10
10
  return {
11
11
  ...options,
12
12
  rollupConfig: []
@@ -1,8 +1,7 @@
1
- import * as rollup from 'rollup';
1
+ import type * as Rollup from 'rollup';
2
2
  import { type ExecutorContext } from '@nx/devkit';
3
3
  import { RollupExecutorOptions } from './schema';
4
4
  import { NormalizedRollupExecutorOptions } from './lib/normalize';
5
5
  export declare function rollupExecutor(rawOptions: RollupExecutorOptions, context: ExecutorContext): AsyncGenerator<unknown, any, any>;
6
- export declare function createRollupOptions(options: NormalizedRollupExecutorOptions, context: ExecutorContext): Promise<rollup.RollupOptions | rollup.RollupOptions[]>;
6
+ export declare function createRollupOptions(options: NormalizedRollupExecutorOptions, context: ExecutorContext): Promise<Rollup.RollupOptions | Rollup.RollupOptions[]>;
7
7
  export default rollupExecutor;
8
- //# sourceMappingURL=rollup.impl.d.ts.map
@@ -2,24 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rollupExecutor = rollupExecutor;
4
4
  exports.createRollupOptions = createRollupOptions;
5
- const tslib_1 = require("tslib");
6
- const rollup = tslib_1.__importStar(require("rollup"));
7
5
  const path_1 = require("path");
8
6
  const devkit_1 = require("@nx/devkit");
7
+ const internal_1 = require("@nx/devkit/internal");
9
8
  const normalize_1 = require("./lib/normalize");
10
- const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
11
- const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
12
9
  const with_nx_1 = require("../../plugins/with-nx/with-nx");
13
10
  const generate_package_json_1 = require("../../plugins/package-json/generate-package-json");
14
- const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
11
+ const internal_2 = require("@nx/js/internal");
12
+ const deprecation_1 = require("../../utils/deprecation");
15
13
  async function* rollupExecutor(rawOptions, context) {
14
+ (0, deprecation_1.warnRollupExecutorDeprecation)();
15
+ // Lazy-loaded: `rollup` is an optional peer, absent at project-graph discovery time.
16
+ const rollup = require('rollup');
16
17
  process.env.NODE_ENV ??= 'production';
17
18
  const options = (0, normalize_1.normalizeRollupExecutorOptions)(rawOptions, context);
18
19
  const rollupOptions = await createRollupOptions(options, context);
19
20
  const outfile = resolveOutfile(context, options);
20
21
  if (options.watch) {
21
22
  // region Watch build
22
- return yield* (0, async_iterable_1.createAsyncIterable)(({ next }) => {
23
+ return yield* (0, internal_1.createAsyncIterable)(({ next }) => {
23
24
  const watcher = rollup.watch(rollupOptions);
24
25
  watcher.on('event', (data) => {
25
26
  if (data.code === 'START') {
@@ -79,14 +80,14 @@ async function* rollupExecutor(rawOptions, context) {
79
80
  }
80
81
  // -----------------------------------------------------------------------------
81
82
  async function createRollupOptions(options, context) {
82
- const { dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, context.targetName, context.configurationName, true);
83
+ const { dependencies } = (0, internal_2.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, context.targetName, context.configurationName, true);
83
84
  const rollupConfig = (0, with_nx_1.withNx)(options, {}, dependencies);
84
85
  // `generatePackageJson` is a plugin rather than being embedded into @nx/rollup:rollup.
85
86
  // Make sure the plugin is always present to keep the previous before of Nx < 19.4, where it was not a plugin.
86
87
  const generatePackageJsonPlugin = Array.isArray(rollupConfig.plugins)
87
88
  ? rollupConfig.plugins.find((p) => p['name'] === generate_package_json_1.pluginName)
88
89
  : null;
89
- const userDefinedRollupConfigs = options.rollupConfig.map((plugin) => (0, config_utils_1.loadConfigFile)(plugin));
90
+ const userDefinedRollupConfigs = options.rollupConfig.map((plugin) => (0, internal_1.loadConfigFile)(plugin));
90
91
  let finalConfig = rollupConfig;
91
92
  for (const _config of userDefinedRollupConfigs) {
92
93
  const config = await _config;
@@ -33,6 +33,5 @@ export interface RollupExecutorOptions {
33
33
  rollupConfig?: string | string[];
34
34
  skipTypeCheck?: boolean;
35
35
  skipTypeField?: boolean;
36
- useLegacyTypescriptPlugin?: boolean;
37
36
  watch?: boolean;
38
37
  }
@@ -5,6 +5,7 @@
5
5
  "description": "Packages a library for different web usages (ESM, CommonJS).",
6
6
  "cli": "nx",
7
7
  "type": "object",
8
+ "x-deprecated": "The `@nx/rollup:rollup` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/rollup:convert-to-inferred` to migrate to the `@nx/rollup/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
8
9
  "properties": {
9
10
  "project": {
10
11
  "type": "string",
@@ -155,11 +156,6 @@
155
156
  "sourceMap": {
156
157
  "description": "Output sourcemaps.",
157
158
  "type": "boolean"
158
- },
159
- "useLegacyTypescriptPlugin": {
160
- "type": "boolean",
161
- "description": "Use rollup-plugin-typescript2 instead of @rollup/plugin-typescript.",
162
- "default": false
163
159
  }
164
160
  },
165
161
  "required": ["tsConfig", "main", "outputPath"],
@@ -191,5 +187,5 @@
191
187
  ]
192
188
  }
193
189
  },
194
- "examplesFile": "../../docs/rollup-examples.md"
190
+ "examplesFile": "../../../docs/rollup-examples.md"
195
191
  }
@@ -2,4 +2,3 @@ import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { RollupProjectSchema } from './schema';
3
3
  export declare function configurationGenerator(tree: Tree, options: RollupProjectSchema): Promise<GeneratorCallback>;
4
4
  export default configurationGenerator;
5
- //# sourceMappingURL=configuration.d.ts.map
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configurationGenerator = configurationGenerator;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
6
6
  const js_1 = require("@nx/js");
7
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
8
- const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
9
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
+ const internal_2 = require("@nx/js/internal");
10
8
  const posix_1 = require("node:path/posix");
11
9
  const devkit_internals_1 = require("nx/src/devkit-internals");
12
10
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
13
11
  const has_plugin_1 = require("../../utils/has-plugin");
12
+ const deprecation_1 = require("../../utils/deprecation");
13
+ const versions_1 = require("../../utils/versions");
14
14
  const init_1 = require("../init/init");
15
15
  let ts;
16
16
  async function configurationGenerator(tree, options) {
17
+ (0, versions_1.assertSupportedRollupVersion)(tree);
17
18
  const tasks = [];
18
19
  const nxJson = (0, devkit_1.readNxJson)(tree);
19
20
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -23,12 +24,13 @@ async function configurationGenerator(tree, options) {
23
24
  if (!options.skipPackageJson) {
24
25
  tasks.push((0, ensure_dependencies_1.ensureDependencies)(tree, options));
25
26
  }
26
- const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
27
+ const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(tree);
27
28
  let outputConfig;
28
29
  if ((0, has_plugin_1.hasPlugin)(tree)) {
29
30
  outputConfig = createRollupConfig(tree, options, isTsSolutionSetup);
30
31
  }
31
32
  else {
33
+ (0, deprecation_1.warnRollupExecutorGenerating)();
32
34
  options.buildTarget ??= 'build';
33
35
  checkForTargetConflicts(tree, options);
34
36
  addBuildTarget(tree, options, isTsSolutionSetup);
@@ -103,7 +105,7 @@ function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
103
105
  }
104
106
  else {
105
107
  packageJson = {
106
- name: options.importPath || (0, get_import_path_1.getImportPath)(tree, options.project),
108
+ name: options.importPath || (0, internal_2.getImportPath)(tree, options.project),
107
109
  version: '0.0.1',
108
110
  };
109
111
  }
@@ -117,9 +119,7 @@ function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
117
119
  // target must exist if we don't receive an outputConfig
118
120
  const projectTarget = project.targets[options.buildTarget];
119
121
  const nxJson = (0, devkit_1.readNxJson)(tree);
120
- const mergedTarget = (0, devkit_internals_1.mergeTargetConfigurations)(projectTarget, (projectTarget.executor
121
- ? nxJson.targetDefaults?.[projectTarget.executor]
122
- : undefined) ?? nxJson.targetDefaults?.[options.buildTarget]);
122
+ const mergedTarget = (0, devkit_internals_1.mergeTargetConfigurations)(projectTarget, (0, internal_1.readTargetDefaultsForTarget)(options.buildTarget, nxJson.targetDefaults, projectTarget.executor));
123
123
  ({ main, outputPath } = mergedTarget.options);
124
124
  }
125
125
  packageJson = (0, js_1.getUpdatedPackageJsonContent)(packageJson, {
@@ -132,7 +132,7 @@ function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
132
132
  format: options.format ?? ['esm'],
133
133
  outputFileExtensionForCjs: '.cjs.js',
134
134
  outputFileExtensionForEsm: '.esm.js',
135
- developmentConditionName: (0, ts_solution_setup_1.getDefinedCustomConditionName)(tree),
135
+ developmentConditionName: (0, internal_2.getDefinedCustomConditionName)(tree),
136
136
  });
137
137
  // rollup has a specific declaration file generation not handled by the util above,
138
138
  // adjust accordingly
@@ -143,7 +143,9 @@ function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
143
143
  (0, devkit_1.writeJson)(tree, packageJsonPath, packageJson);
144
144
  }
145
145
  function addBuildTarget(tree, options, isTsSolutionSetup) {
146
- (0, target_defaults_utils_1.addBuildTargetDefaults)(tree, '@nx/rollup:rollup', options.buildTarget);
146
+ (0, internal_1.addBuildTargetDefaults)(tree, '@nx/rollup:rollup', options.buildTarget, [
147
+ internal_2.TS_SOLUTION_SETUP_TSCONFIG_INPUT,
148
+ ]);
147
149
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
148
150
  const prevBuildOptions = project.targets?.[options.buildTarget]?.options;
149
151
  options.tsConfig ??=
@@ -205,7 +207,7 @@ function updateTsConfig(tree, options) {
205
207
  throw new Error(`The '${tsconfigPath}' file doesn't exist. Provide the 'tsConfig' option with the correct path pointing to the tsconfig file to use for builds.`);
206
208
  }
207
209
  if (!ts) {
208
- ts = (0, ensure_typescript_1.ensureTypescript)();
210
+ ts = (0, internal_2.ensureTypescript)();
209
211
  }
210
212
  const parsedTsConfig = (0, js_1.readTsConfig)(tsconfigPath, {
211
213
  ...ts.sys,
@@ -5,4 +5,3 @@ interface Schema {
5
5
  }
6
6
  export declare function convertToInferred(tree: Tree, options: Schema): Promise<void>;
7
7
  export default convertToInferred;
8
- //# sourceMappingURL=convert-to-inferred.d.ts.map
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertToInferred = convertToInferred;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
6
  const extract_rollup_config_from_executor_options_1 = require("./lib/extract-rollup-config-from-executor-options");
7
7
  const add_plugin_registrations_1 = require("./lib/add-plugin-registrations");
8
- const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
8
+ const versions_1 = require("../../utils/versions");
9
9
  async function convertToInferred(tree, options) {
10
+ (0, versions_1.assertSupportedRollupVersion)(tree);
10
11
  const migratedProjects = new Map();
11
12
  let projects = (0, devkit_1.getProjects)(tree);
12
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/rollup:rollup', (_, projectName, targetName, configurationName) => {
13
+ (0, internal_1.forEachExecutorOptions)(tree, '@nx/rollup:rollup', (_, projectName, targetName, configurationName) => {
13
14
  if (options.project && projectName !== options.project)
14
15
  return;
15
16
  const project = projects.get(projectName);
@@ -19,9 +20,13 @@ async function convertToInferred(tree, options) {
19
20
  return;
20
21
  // Since targetDefaults for '@nx/rollup:rollup' will no longer apply, we want to copy them to the target options.
21
22
  const nxJson = (0, devkit_1.readNxJson)(tree);
22
- const defaults = nxJson.targetDefaults['@nx/rollup:rollup'];
23
+ const defaults = (0, internal_1.normalizeTargetDefaults)(nxJson?.targetDefaults).find((e) => e.executor === '@nx/rollup:rollup' &&
24
+ e.target === undefined &&
25
+ e.projects === undefined &&
26
+ e.plugin === undefined);
23
27
  if (defaults) {
24
- for (const [key, value] of Object.entries(defaults)) {
28
+ const { target: _t, executor: _e, projects: _p, plugin: _pl, ...rest } = defaults;
29
+ for (const [key, value] of Object.entries(rest)) {
25
30
  target[key] ??= value;
26
31
  }
27
32
  }
@@ -67,7 +72,7 @@ async function convertToInferred(tree, options) {
67
72
  migratedProjects.set(projectName, { buildTargetName: targetName });
68
73
  });
69
74
  if (migratedProjects.size === 0) {
70
- throw new executor_to_plugin_migrator_1.NoTargetsToMigrateError();
75
+ throw new internal_1.NoTargetsToMigrateError();
71
76
  }
72
77
  projects = (0, devkit_1.getProjects)(tree);
73
78
  await (0, add_plugin_registrations_1.addPluginRegistrations)(tree, migratedProjects, projects, '@nx/rollup/plugin');
@@ -1,3 +1,2 @@
1
1
  import { type ProjectConfiguration, type Tree } from '@nx/devkit';
2
2
  export declare function addPluginRegistrations<T>(tree: Tree, projectTargets: Map<string, T>, projects: Map<string, ProjectConfiguration>, pluginPath: string): Promise<void>;
3
- //# sourceMappingURL=add-plugin-registrations.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { RollupExecutorOptions } from '../../../executors/rollup/schema';
3
3
  export declare function extractRollupConfigFromExecutorOptions(tree: Tree, options: RollupExecutorOptions, configurations: Record<string, Partial<RollupExecutorOptions>>, projectRoot: string): Record<string, unknown>;
4
- //# sourceMappingURL=extract-rollup-config-from-executor-options.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import { RollupExecutorOptions } from '../../../executors/rollup/schema';
2
2
  export declare function normalizePathOptions(projectRoot: string, options: RollupExecutorOptions): void;
3
- //# sourceMappingURL=normalize-path-options.d.ts.map
@@ -2,4 +2,3 @@ import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function rollupInitGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
4
  export default rollupInitGenerator;
5
- //# sourceMappingURL=init.d.ts.map
@@ -1,26 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rollupInitGenerator = rollupInitGenerator;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const versions_1 = require("../../utils/versions");
6
- const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
7
7
  const plugin_1 = require("../../plugins/plugin");
8
8
  async function rollupInitGenerator(tree, schema) {
9
+ (0, versions_1.assertSupportedRollupVersion)(tree);
9
10
  let task = () => { };
10
11
  const nxJson = (0, devkit_1.readNxJson)(tree);
11
12
  schema.addPlugin ??=
12
13
  process.env.NX_ADD_PLUGINS !== 'false' &&
13
14
  nxJson.useInferencePlugins !== false;
14
15
  if (!schema.skipPackageJson) {
15
- const devDependencies = { '@nx/rollup': versions_1.nxVersion };
16
- if (schema.addPlugin) {
17
- // Ensure user can run Rollup CLI.
18
- devDependencies['rollup'] = versions_1.rollupVersion;
19
- }
20
- task = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions);
16
+ // Rollup is a peer dependency, so ensure it is installed for both the
17
+ // inferred-plugin (CLI) path and the executor (programmatic) path.
18
+ const devDependencies = {
19
+ '@nx/rollup': versions_1.nxVersion,
20
+ rollup: versions_1.rollupVersion,
21
+ };
22
+ task = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions ?? true);
21
23
  }
22
24
  if (schema.addPlugin) {
23
- await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rollup/plugin', plugin_1.createNodesV2, {
25
+ await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rollup/plugin', plugin_1.createNodesV2, {
24
26
  buildTargetName: ['build', 'rollup:build', 'rollup-build'],
25
27
  buildDepsTargetName: [
26
28
  'build-deps',
@@ -20,7 +20,7 @@
20
20
  "type": "boolean",
21
21
  "x-priority": "internal",
22
22
  "description": "Keep existing dependencies versions",
23
- "default": false
23
+ "default": true
24
24
  },
25
25
  "updatePackageScripts": {
26
26
  "type": "boolean",
@@ -0,0 +1,9 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function migrateCreateNodesV2ToCreateNodes(tree: Tree): Promise<void>;
3
+ /**
4
+ * Rewrites named imports and re-exports of `createNodesV2` to `createNodes`
5
+ * when they come from one of the given module specifiers. Only the named
6
+ * bindings are touched — the module specifier, the `import`/`export` keyword,
7
+ * any `type` modifier, and any default import are left untouched.
8
+ */
9
+ export declare function rewriteCreateNodesV2Imports(source: string, specifiers: ReadonlySet<string>): string;
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = migrateCreateNodesV2ToCreateNodes;
4
+ exports.rewriteCreateNodesV2Imports = rewriteCreateNodesV2Imports;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
7
+ const DEPRECATED_NAME = 'createNodesV2';
8
+ const CANONICAL_NAME = 'createNodes';
9
+ // Module specifiers from which `@nx/rollup` publicly exposes `createNodesV2`.
10
+ // A named import or re-export of `createNodesV2` from one of these is rewritten
11
+ // to the canonical `createNodes` export.
12
+ const TARGET_SPECIFIERS = new Set(['@nx/rollup/plugin']);
13
+ let ts;
14
+ async function migrateCreateNodesV2ToCreateNodes(tree) {
15
+ let touchedCount = 0;
16
+ (0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
17
+ if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
18
+ return;
19
+ }
20
+ const original = tree.read(filePath, 'utf-8');
21
+ if (!original || !original.includes(DEPRECATED_NAME)) {
22
+ return;
23
+ }
24
+ const updated = rewriteCreateNodesV2Imports(original, TARGET_SPECIFIERS);
25
+ if (updated !== original) {
26
+ tree.write(filePath, updated);
27
+ touchedCount += 1;
28
+ }
29
+ });
30
+ if (touchedCount > 0) {
31
+ devkit_1.logger.info(`Renamed \`${DEPRECATED_NAME}\` imports to \`${CANONICAL_NAME}\` in ${touchedCount} file(s).`);
32
+ }
33
+ await (0, devkit_1.formatFiles)(tree);
34
+ }
35
+ /**
36
+ * Rewrites named imports and re-exports of `createNodesV2` to `createNodes`
37
+ * when they come from one of the given module specifiers. Only the named
38
+ * bindings are touched — the module specifier, the `import`/`export` keyword,
39
+ * any `type` modifier, and any default import are left untouched.
40
+ */
41
+ function rewriteCreateNodesV2Imports(source, specifiers) {
42
+ ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
43
+ const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
44
+ /* setParentNodes */ true, ts.ScriptKind.TSX);
45
+ const changes = [];
46
+ let renameLocalUsages = false;
47
+ for (const stmt of sourceFile.statements) {
48
+ if (ts.isImportDeclaration(stmt)) {
49
+ renameLocalUsages =
50
+ collectImportRewrite(sourceFile, stmt, specifiers, changes) ||
51
+ renameLocalUsages;
52
+ }
53
+ else if (ts.isExportDeclaration(stmt)) {
54
+ collectExportRewrite(sourceFile, stmt, specifiers, changes);
55
+ }
56
+ }
57
+ // Renaming a local `createNodesV2` import binding to `createNodes` (a lone
58
+ // `{ createNodesV2 }`, or one deduped against an existing `createNodes`)
59
+ // changes the name in scope, so value references to `createNodesV2` in the
60
+ // file body must be renamed too — otherwise they dangle. Aliased imports and
61
+ // re-exports keep their local name, so they never trigger this.
62
+ if (renameLocalUsages) {
63
+ collectValueUsageRewrites(sourceFile, changes);
64
+ }
65
+ return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
66
+ }
67
+ function isTargetSpecifier(node, specifiers) {
68
+ return ts.isStringLiteral(node) && specifiers.has(node.text);
69
+ }
70
+ function collectImportRewrite(sourceFile, stmt, specifiers, changes) {
71
+ if (!isTargetSpecifier(stmt.moduleSpecifier, specifiers)) {
72
+ return false;
73
+ }
74
+ const namedBindings = stmt.importClause?.namedBindings;
75
+ // Only `import { ... }` carries renameable named bindings. `import x`,
76
+ // `import * as ns`, and side-effect imports reference the module wholesale
77
+ // and keep working through the `createNodesV2` runtime alias, so we leave
78
+ // them be. A mixed `import def, { createNodesV2 }` still has its named
79
+ // bindings rewritten below — the default binding is untouched.
80
+ if (!namedBindings || !ts.isNamedImports(namedBindings)) {
81
+ return false;
82
+ }
83
+ // The local `createNodesV2` binding only disappears when it is imported
84
+ // without an alias — a lone `{ createNodesV2 }` or one deduped against an
85
+ // existing `createNodes`. `{ createNodesV2 as x }` keeps the local `x`, so
86
+ // its in-file usages are unaffected and must not be rewritten.
87
+ const localBindingRenamed = namedBindings.elements.some((el) => el.name.text === DEPRECATED_NAME &&
88
+ (el.propertyName ?? el.name).text === DEPRECATED_NAME);
89
+ rewriteNamedBindings(sourceFile, namedBindings, changes);
90
+ return localBindingRenamed;
91
+ }
92
+ function collectExportRewrite(sourceFile, stmt, specifiers, changes) {
93
+ if (!stmt.moduleSpecifier ||
94
+ !isTargetSpecifier(stmt.moduleSpecifier, specifiers)) {
95
+ return;
96
+ }
97
+ // `export { ... } from '...'` can be rewritten; `export * from '...'` has no
98
+ // named bindings to rename.
99
+ if (!stmt.exportClause || !ts.isNamedExports(stmt.exportClause)) {
100
+ return;
101
+ }
102
+ rewriteNamedBindings(sourceFile, stmt.exportClause, changes);
103
+ }
104
+ /**
105
+ * Re-renders the `{ ... }` of a named import/export, renaming any
106
+ * `createNodesV2` specifier to `createNodes`. If renaming would collide with a
107
+ * `createNodes` that is already present (e.g. `{ createNodes, createNodesV2 }`),
108
+ * the duplicate is dropped. Returns without recording a change when the binding
109
+ * list contains no `createNodesV2`.
110
+ */
111
+ function rewriteNamedBindings(sourceFile, namedBindings, changes) {
112
+ const elements = namedBindings.elements;
113
+ const hasDeprecated = elements.some((el) => (el.propertyName ?? el.name).text === DEPRECATED_NAME);
114
+ if (!hasDeprecated) {
115
+ return;
116
+ }
117
+ const seen = new Set();
118
+ const rendered = [];
119
+ for (const el of elements) {
120
+ const text = renderSpecifier(el);
121
+ if (!seen.has(text)) {
122
+ seen.add(text);
123
+ rendered.push(text);
124
+ }
125
+ }
126
+ const start = namedBindings.getStart(sourceFile);
127
+ changes.push({
128
+ type: devkit_1.ChangeType.Delete,
129
+ start,
130
+ length: namedBindings.getEnd() - start,
131
+ }, {
132
+ type: devkit_1.ChangeType.Insert,
133
+ index: start,
134
+ text: `{ ${rendered.join(', ')} }`,
135
+ });
136
+ }
137
+ function renderSpecifier(el) {
138
+ const typePrefix = el.isTypeOnly ? 'type ' : '';
139
+ const rename = (name) => name === DEPRECATED_NAME ? CANONICAL_NAME : name;
140
+ // `{ name }` — no alias, so the local binding follows the rename.
141
+ if (!el.propertyName) {
142
+ return `${typePrefix}${rename(el.name.text)}`;
143
+ }
144
+ // `{ propertyName as name }` — only the imported (left) side is renamed; the
145
+ // local alias is preserved. A now-redundant alias such as
146
+ // `createNodesV2 as createNodes` collapses to `createNodes`.
147
+ const canonicalImported = rename(el.propertyName.text);
148
+ const localName = el.name.text;
149
+ return canonicalImported === localName
150
+ ? `${typePrefix}${localName}`
151
+ : `${typePrefix}${canonicalImported} as ${localName}`;
152
+ }
153
+ /**
154
+ * Renames value references of `createNodesV2` to `createNodes` in the file
155
+ * body. Only called once a local `createNodesV2` import binding has actually
156
+ * been renamed, so these references would otherwise dangle. Occurrences that
157
+ * are not references to that binding are skipped: the import/export
158
+ * declarations themselves, property accesses (`x.createNodesV2`), qualified
159
+ * type names, object-literal keys, and declaration names that shadow the
160
+ * import. A shorthand property (`{ createNodesV2 }`) is expanded to
161
+ * `{ createNodesV2: createNodes }` so the property key is preserved. Strings
162
+ * and comments are never `Identifier` nodes, so they are left alone.
163
+ */
164
+ function collectValueUsageRewrites(sourceFile, changes) {
165
+ const visit = (node) => {
166
+ if (ts.isIdentifier(node) &&
167
+ node.text === DEPRECATED_NAME &&
168
+ isRenamableValueUsage(node)) {
169
+ const start = node.getStart(sourceFile);
170
+ changes.push({
171
+ type: devkit_1.ChangeType.Delete,
172
+ start,
173
+ length: node.getEnd() - start,
174
+ }, {
175
+ type: devkit_1.ChangeType.Insert,
176
+ index: start,
177
+ text: ts.isShorthandPropertyAssignment(node.parent)
178
+ ? `${DEPRECATED_NAME}: ${CANONICAL_NAME}`
179
+ : CANONICAL_NAME,
180
+ });
181
+ }
182
+ node.forEachChild(visit);
183
+ };
184
+ sourceFile.forEachChild(visit);
185
+ }
186
+ /**
187
+ * Whether a `createNodesV2` identifier is a value reference to the renamed
188
+ * import binding, as opposed to a position that must be left untouched.
189
+ */
190
+ function isRenamableValueUsage(node) {
191
+ const parent = node.parent;
192
+ if (!parent) {
193
+ return false;
194
+ }
195
+ // Import/export bindings — already handled by the declaration rewrite.
196
+ if (ts.isImportSpecifier(parent) ||
197
+ ts.isExportSpecifier(parent) ||
198
+ ts.isImportClause(parent) ||
199
+ ts.isNamespaceImport(parent)) {
200
+ return false;
201
+ }
202
+ // `x.createNodesV2` / `X.createNodesV2` — a member name, not the binding.
203
+ if (ts.isPropertyAccessExpression(parent) && parent.name === node) {
204
+ return false;
205
+ }
206
+ if (ts.isQualifiedName(parent) && parent.right === node) {
207
+ return false;
208
+ }
209
+ // `{ createNodesV2: ... }` — an object-literal key, not the binding.
210
+ if (ts.isPropertyAssignment(parent) && parent.name === node) {
211
+ return false;
212
+ }
213
+ // A declaration whose name shadows the import (variable, param, etc.).
214
+ if ((ts.isVariableDeclaration(parent) ||
215
+ ts.isParameter(parent) ||
216
+ ts.isBindingElement(parent) ||
217
+ ts.isFunctionDeclaration(parent) ||
218
+ ts.isClassDeclaration(parent)) &&
219
+ parent.name === node) {
220
+ return false;
221
+ }
222
+ return true;
223
+ }
@@ -0,0 +1,25 @@
1
+ #### Rename `createNodesV2` imports to `createNodes`
2
+
3
+ `@nx/rollup` renamed its primary inferred-plugin export from `createNodesV2` to `createNodes`. The `createNodesV2` name is preserved as a deprecated alias for now, but new code should use `createNodes`.
4
+
5
+ This migration scans every `.ts`, `.tsx`, `.cts`, and `.mts` file in your workspace and rewrites named imports and re-exports of `createNodesV2` from `@nx/rollup/plugin` to `createNodes`.
6
+
7
+ #### Sample Code Changes
8
+
9
+ ##### Before
10
+
11
+ ```ts
12
+ import { createNodesV2 } from '@nx/rollup/plugin';
13
+ ```
14
+
15
+ ##### After
16
+
17
+ ```ts
18
+ import { createNodes } from '@nx/rollup/plugin';
19
+ ```
20
+
21
+ Aliases are preserved (`createNodesV2 as cn` becomes `createNodes as cn`), and if a file already imports both names (`{ createNodes, createNodesV2 }`) the redundant binding is dropped.
22
+
23
+ #### What is not rewritten
24
+
25
+ Only static `import`/`export` named bindings from `@nx/rollup/plugin` are rewritten. Namespace imports, dynamic `import(...)`, `require(...)` destructuring, and property access such as `plugin.createNodesV2` are left untouched — they keep working through the `createNodesV2` runtime alias. Update those by hand if you want to drop the deprecated name everywhere.
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;