@nx/rollup 24.0.0-beta.2 → 24.0.0-beta.3

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/index.d.ts CHANGED
@@ -4,4 +4,3 @@ export { configurationGenerator };
4
4
  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
- export * from './src/executors/rollup/rollup.impl';
package/dist/index.js CHANGED
@@ -8,4 +8,3 @@ Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get
8
8
  /** @deprecated Use `configurationGenerator` instead. */
9
9
  exports.rollupProjectGenerator = configuration_1.configurationGenerator;
10
10
  tslib_1.__exportStar(require("./src/generators/init/init"), exports);
11
- tslib_1.__exportStar(require("./src/executors/rollup/rollup.impl"), exports);
@@ -1,39 +1,23 @@
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");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const js_1 = require("@nx/js");
7
- const internal_2 = require("@nx/js/internal");
6
+ const internal_1 = require("@nx/js/internal");
8
7
  const posix_1 = require("node:path/posix");
9
8
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
10
- const has_plugin_1 = require("../../utils/has-plugin");
11
- const deprecation_1 = require("../../utils/deprecation");
12
9
  const versions_1 = require("../../utils/versions");
13
10
  const init_1 = require("../init/init");
14
11
  let ts;
15
12
  async function configurationGenerator(tree, options) {
16
13
  (0, versions_1.assertSupportedRollupVersion)(tree);
17
14
  const tasks = [];
18
- const nxJson = (0, devkit_1.readNxJson)(tree);
19
- const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
20
- nxJson.useInferencePlugins !== false;
21
- options.addPlugin ??= addPluginDefault;
22
15
  tasks.push(await (0, init_1.rollupInitGenerator)(tree, { ...options, skipFormat: true }));
23
16
  if (!options.skipPackageJson) {
24
17
  tasks.push((0, ensure_dependencies_1.ensureDependencies)(tree, options));
25
18
  }
26
- const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(tree);
27
- let outputConfig;
28
- if ((0, has_plugin_1.hasPlugin)(tree)) {
29
- outputConfig = createRollupConfig(tree, options, isTsSolutionSetup);
30
- }
31
- else {
32
- (0, deprecation_1.warnRollupExecutorGenerating)();
33
- options.buildTarget ??= 'build';
34
- checkForTargetConflicts(tree, options);
35
- addBuildTarget(tree, options, isTsSolutionSetup);
36
- }
19
+ const isTsSolutionSetup = (0, internal_1.isUsingTsSolutionSetup)(tree);
20
+ const outputConfig = createRollupConfig(tree, options, isTsSolutionSetup);
37
21
  updatePackageJson(tree, options, outputConfig, isTsSolutionSetup);
38
22
  if (isTsSolutionSetup) {
39
23
  updateTsConfig(tree, options);
@@ -84,14 +68,6 @@ module.exports = withNx(
84
68
  outputPath: (0, devkit_1.joinPathFragments)(project.root, outputPath),
85
69
  };
86
70
  }
87
- function checkForTargetConflicts(tree, options) {
88
- if (options.skipValidation)
89
- return;
90
- const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
91
- if (project.targets?.[options.buildTarget]) {
92
- throw new Error(`Project "${options.project}" already has a ${options.buildTarget} target. Pass --skipValidation to ignore this error.`);
93
- }
94
- }
95
71
  function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
96
72
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
97
73
  const packageJsonPath = (0, posix_1.join)(project.root, 'package.json');
@@ -104,23 +80,12 @@ function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
104
80
  }
105
81
  else {
106
82
  packageJson = {
107
- name: options.importPath || (0, internal_2.getImportPath)(tree, options.project),
83
+ name: options.importPath || (0, internal_1.getImportPath)(tree, options.project),
108
84
  version: '0.0.1',
109
85
  };
110
86
  }
111
87
  if (isTsSolutionSetup) {
112
- let main;
113
- let outputPath;
114
- if (outputConfig) {
115
- ({ main, outputPath } = outputConfig);
116
- }
117
- else {
118
- // target must exist if we don't receive an outputConfig
119
- const projectTarget = project.targets[options.buildTarget];
120
- const nxJson = (0, devkit_1.readNxJson)(tree);
121
- const mergedTarget = (0, internal_1.mergeTargetConfigurations)(projectTarget, (0, internal_1.readTargetDefaultsForTarget)(options.buildTarget, nxJson.targetDefaults, projectTarget.executor));
122
- ({ main, outputPath } = mergedTarget.options);
123
- }
88
+ const { main, outputPath } = outputConfig;
124
89
  packageJson = (0, js_1.getUpdatedPackageJsonContent)(packageJson, {
125
90
  main,
126
91
  outputPath,
@@ -131,7 +96,7 @@ function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
131
96
  format: options.format ?? ['esm'],
132
97
  outputFileExtensionForCjs: '.cjs.js',
133
98
  outputFileExtensionForEsm: '.esm.js',
134
- developmentConditionName: (0, internal_2.getDefinedCustomConditionName)(tree),
99
+ developmentConditionName: (0, internal_1.getDefinedCustomConditionName)(tree),
135
100
  });
136
101
  // rollup has a specific declaration file generation not handled by the util above,
137
102
  // adjust accordingly
@@ -141,64 +106,6 @@ function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
141
106
  }
142
107
  (0, devkit_1.writeJson)(tree, packageJsonPath, packageJson);
143
108
  }
144
- function addBuildTarget(tree, options, isTsSolutionSetup) {
145
- (0, internal_1.addBuildTargetDefaults)(tree, '@nx/rollup:rollup', options.buildTarget, [
146
- internal_2.TS_SOLUTION_SETUP_TSCONFIG_INPUT,
147
- ]);
148
- const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
149
- const prevBuildOptions = project.targets?.[options.buildTarget]?.options;
150
- options.tsConfig ??=
151
- prevBuildOptions?.tsConfig ??
152
- (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.lib.json');
153
- let outputPath = prevBuildOptions?.outputPath;
154
- if (!outputPath) {
155
- outputPath = isTsSolutionSetup
156
- ? (0, devkit_1.joinPathFragments)(project.root, 'dist')
157
- : (0, devkit_1.joinPathFragments)('dist', project.root === '.' ? project.name : project.root);
158
- }
159
- const buildOptions = {
160
- main: options.main ??
161
- prevBuildOptions?.main ??
162
- (0, devkit_1.joinPathFragments)(project.root, 'src/index.ts'),
163
- outputPath,
164
- tsConfig: options.tsConfig,
165
- // TODO(leo): see if we can use this when updating the package.json for the new setup
166
- // additionalEntryPoints: prevBuildOptions?.additionalEntryPoints,
167
- // generateExportsField: prevBuildOptions?.generateExportsField,
168
- compiler: options.compiler ?? 'babel',
169
- project: `${project.root}/package.json`,
170
- external: options.external,
171
- format: (options.format ?? isTsSolutionSetup) ? ['esm'] : undefined,
172
- };
173
- if (options.rollupConfig) {
174
- buildOptions.rollupConfig = options.rollupConfig;
175
- }
176
- if (!isTsSolutionSetup) {
177
- buildOptions.additionalEntryPoints =
178
- prevBuildOptions?.additionalEntryPoints;
179
- buildOptions.generateExportsField = prevBuildOptions?.generateExportsField;
180
- if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'README.md'))) {
181
- buildOptions.assets = [
182
- {
183
- glob: `${project.root}/README.md`,
184
- input: '.',
185
- output: '.',
186
- },
187
- ];
188
- }
189
- }
190
- (0, devkit_1.updateProjectConfiguration)(tree, options.project, {
191
- ...project,
192
- targets: {
193
- ...project.targets,
194
- [options.buildTarget]: {
195
- executor: '@nx/rollup:rollup',
196
- outputs: ['{options.outputPath}'],
197
- options: buildOptions,
198
- },
199
- },
200
- });
201
- }
202
109
  function updateTsConfig(tree, options) {
203
110
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
204
111
  const tsconfigPath = options.tsConfig ?? (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.lib.json');
@@ -206,9 +113,9 @@ function updateTsConfig(tree, options) {
206
113
  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.`);
207
114
  }
208
115
  if (!ts) {
209
- ts = (0, internal_2.ensureTypescript)();
116
+ ts = (0, internal_1.ensureTypescript)();
210
117
  }
211
- const parsedTsConfig = (0, js_1.readTsConfig)(tsconfigPath, (0, internal_2.createTreeParseConfigHost)(tree));
118
+ const parsedTsConfig = (0, js_1.readTsConfig)(tsconfigPath, (0, internal_1.createTreeParseConfigHost)(tree));
212
119
  (0, devkit_1.updateJson)(tree, tsconfigPath, (json) => {
213
120
  if (parsedTsConfig.options.module === ts.ModuleKind.NodeNext) {
214
121
  json.compilerOptions ??= {};
@@ -11,5 +11,4 @@ export interface RollupProjectSchema {
11
11
  rollupConfig?: string;
12
12
  buildTarget?: string;
13
13
  format?: ('cjs' | 'esm')[];
14
- addPlugin?: boolean;
15
14
  }
@@ -8,34 +8,27 @@ const plugin_1 = require("../../plugins/plugin");
8
8
  async function rollupInitGenerator(tree, schema) {
9
9
  (0, versions_1.assertSupportedRollupVersion)(tree);
10
10
  let task = () => { };
11
- const nxJson = (0, devkit_1.readNxJson)(tree);
12
- schema.addPlugin ??=
13
- process.env.NX_ADD_PLUGINS !== 'false' &&
14
- nxJson.useInferencePlugins !== false;
15
11
  if (!schema.skipPackageJson) {
16
- // Rollup is a peer dependency, so ensure it is installed for both the
17
- // inferred-plugin (CLI) path and the executor (programmatic) path.
12
+ // Rollup is a peer dependency, so ensure it is installed.
18
13
  const devDependencies = {
19
14
  '@nx/rollup': versions_1.nxVersion,
20
15
  rollup: versions_1.rollupVersion,
21
16
  };
22
17
  task = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions ?? true);
23
18
  }
24
- if (schema.addPlugin) {
25
- await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rollup/plugin', plugin_1.createNodesV2, {
26
- buildTargetName: ['build', 'rollup:build', 'rollup-build'],
27
- buildDepsTargetName: [
28
- 'build-deps',
29
- 'rollup:build-deps',
30
- 'rollup-build-deps',
31
- ],
32
- watchDepsTargetName: [
33
- 'watch-deps',
34
- 'rollup:watch-deps',
35
- 'rollup-watch-deps',
36
- ],
37
- }, schema.updatePackageScripts);
38
- }
19
+ await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rollup/plugin', plugin_1.createNodesV2, {
20
+ buildTargetName: ['build', 'rollup:build', 'rollup-build'],
21
+ buildDepsTargetName: [
22
+ 'build-deps',
23
+ 'rollup:build-deps',
24
+ 'rollup-build-deps',
25
+ ],
26
+ watchDepsTargetName: [
27
+ 'watch-deps',
28
+ 'rollup:watch-deps',
29
+ 'rollup-watch-deps',
30
+ ],
31
+ }, schema.updatePackageScripts);
39
32
  if (!schema.skipFormat) {
40
33
  await (0, devkit_1.formatFiles)(tree);
41
34
  }
@@ -3,5 +3,4 @@ export interface Schema {
3
3
  skipPackageJson?: boolean;
4
4
  keepExistingVersions?: boolean;
5
5
  updatePackageScripts?: boolean;
6
- addPlugin?: boolean;
7
6
  }
@@ -0,0 +1,12 @@
1
+ # Replace removed @nx/rollup executors with inferred tasks
2
+
3
+ Nx 24 removed `@nx/rollup:rollup` (including old `@nrwl` aliases).
4
+
5
+ Before changing anything, check for leftover work: a project target, a package.json target or a `targetDefaults` entry still uses a removed executor, or the advisory context reports a conversion error. If none applies, make no changes and stop. Treat each advisory-context item as pending work.
6
+
7
+ 1. Inspect all affected projects and workspace defaults. Repair config-loading errors first. Do not restore executor registrations or install older Nx packages.
8
+ 2. Generate native Rollup configuration preserving library formats, declaration generation, externals, assets and package metadata. Check every configuration and custom build target.
9
+ 3. Register `@nx/rollup/plugin` with options/includes that preserve custom target names and mixed inferred/explicit projects. Replace remaining removed-executor targets, including those in package.json and filtered targetDefaults. Transfer their behavior before removing obsolete defaults. Preserve configurations, dependencies, cache inputs/outputs and environment behavior. Do not silently delete unsupported options or unrelated targets. Migrate old @nrwl aliases too.
10
+ 4. Run project graph creation with the daemon and graph cache disabled (`NX_DAEMON=false NX_CACHE_PROJECT_GRAPH=false`), using the workspace package manager. Inspect resolved project targets and verify each migrated entrypoint exists and is inferred (a thin alias to an inferred target is acceptable). Resolve graph errors before completing this migration, even if task validation was skipped. Configs must load for subsequent migrations.
11
+ 5. By default run relevant real builds/tests with task cache disabled, including alternate configurations. Honor an existing preference to skip expensive task validation; otherwise offer that option when validation is slow. Skipping expensive tasks never skips conversion or the graph check. Report each skipped task as unverified. Never weaken assertions or change application behavior to make checks pass.
12
+ 6. Report converted projects, graph validation, task results and any skipped checks. Unconverted targets or a broken graph mean the migration is incomplete. Investigate task failures and distinguish missing environment prerequisites from conversion regressions; do not claim a working workspace with unresolved regressions.
@@ -0,0 +1,6 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): Promise<{
3
+ nextSteps?: string[];
4
+ agentContext?: string[];
5
+ skipAgentic?: boolean;
6
+ }>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const internal_1 = require("@nx/devkit/internal");
5
+ function update(tree) {
6
+ return (0, internal_1.migrateRemovedExecutors)(tree, ['@nx/rollup:rollup', '@nrwl/rollup:rollup'], async (tree, options) => {
7
+ const { convertToInferred } = require('../../generators/convert-to-inferred/convert-to-inferred');
8
+ return convertToInferred(tree, options);
9
+ });
10
+ }
@@ -0,0 +1,45 @@
1
+ #### Convert `@nx/rollup:rollup` targets to inferred tasks
2
+
3
+ Nx 24 removes the `@nx/rollup:rollup` executor and its `@nrwl/rollup:rollup` alias. The migration registers `@nx/rollup/plugin` in `nx.json` and converts the targets that use those executors to inferred tasks. It writes the executor options into a Rollup config file in the project root. A target with nothing left to override is removed from project configuration. When several projects share the same remaining options, those options move to a `targetDefaults` entry scoped to the plugin. `targetDefaults` entries keyed by a removed executor are removed once no target uses that executor.
4
+
5
+ The migration lists the targets the converter cannot convert safely. In agentic runs, an AI prompt finishes them and validates the project graph.
6
+
7
+ #### Sample code changes
8
+
9
+ ##### Before
10
+
11
+ ```json title="mypkg/project.json"
12
+ {
13
+ "name": "mypkg",
14
+ "targets": {
15
+ "build": {
16
+ "executor": "@nx/rollup:rollup",
17
+ "outputs": ["{options.outputPath}"],
18
+ "options": {
19
+ "main": "mypkg/src/index.ts",
20
+ "outputPath": "dist/mypkg",
21
+ "tsConfig": "mypkg/tsconfig.lib.json",
22
+ "compiler": "babel",
23
+ "format": ["esm"],
24
+ "external": [],
25
+ "assets": []
26
+ }
27
+ }
28
+ }
29
+ }
30
+ ```
31
+
32
+ ##### After
33
+
34
+ ```json title="nx.json"
35
+ {
36
+ "plugins": [
37
+ {
38
+ "plugin": "@nx/rollup/plugin",
39
+ "options": {
40
+ "buildTargetName": "build"
41
+ }
42
+ }
43
+ ]
44
+ }
45
+ ```
package/executors.json CHANGED
@@ -1,9 +1,3 @@
1
1
  {
2
- "executors": {
3
- "rollup": {
4
- "implementation": "./dist/src/executors/rollup/rollup.impl",
5
- "schema": "./dist/src/executors/rollup/schema.json",
6
- "description": "Bundle a package using Rollup."
7
- }
8
- }
2
+ "executors": {}
9
3
  }
package/migrations.json CHANGED
@@ -17,6 +17,13 @@
17
17
  "description": "Rename imports of `createNodesV2` from `@nx/rollup/plugin` to the canonical `createNodes` export.",
18
18
  "implementation": "./dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes",
19
19
  "documentation": "./dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.md"
20
+ },
21
+ "remove-deprecated-executors": {
22
+ "version": "24.0.0-beta.3",
23
+ "description": "Converts targets using the removed `@nx/rollup` executors to inferred tasks; an AI prompt finishes the targets the converter cannot convert safely and validates the project graph.",
24
+ "implementation": "./dist/src/migrations/update-24-0-0/remove-deprecated-executors",
25
+ "prompt": "./dist/src/migrations/update-24-0-0/finish-inferred-conversion.md",
26
+ "documentation": "./dist/src/migrations/update-24-0-0/remove-deprecated-executors.md"
20
27
  }
21
28
  },
22
29
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/rollup",
3
- "version": "24.0.0-beta.2",
3
+ "version": "24.0.0-beta.3",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -10,7 +10,7 @@
10
10
  "executors.json",
11
11
  "generators.json"
12
12
  ],
13
- "description": "The Nx Plugin for Rollup contains executors and generators that support building applications using Rollup.",
13
+ "description": "The Nx Plugin for Rollup infers tasks and provides generators that support building applications using Rollup.",
14
14
  "repository": {
15
15
  "type": "git",
16
16
  "url": "https://github.com/nrwl/nx.git",
@@ -77,8 +77,8 @@
77
77
  }
78
78
  },
79
79
  "dependencies": {
80
- "@nx/devkit": "24.0.0-beta.2",
81
- "@nx/js": "24.0.0-beta.2",
80
+ "@nx/devkit": "24.0.0-beta.3",
81
+ "@nx/js": "24.0.0-beta.3",
82
82
  "@phenomnomnominal/tsquery": "~6.2.0",
83
83
  "@rollup/plugin-babel": "^6.0.4",
84
84
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -103,7 +103,7 @@
103
103
  }
104
104
  },
105
105
  "devDependencies": {
106
- "nx": "24.0.0-beta.2",
106
+ "nx": "24.0.0-beta.3",
107
107
  "source-map-js": "^1.2.0"
108
108
  },
109
109
  "publishConfig": {
@@ -1,8 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import type { RollupExecutorOptions } from '../schema';
3
- export interface NormalizedRollupExecutorOptions extends RollupExecutorOptions {
4
- projectRoot: string;
5
- rollupConfig: string[];
6
- }
7
- export declare function normalizeRollupExecutorOptions(options: RollupExecutorOptions, context: ExecutorContext): NormalizedRollupExecutorOptions;
8
- export declare function normalizePluginPath(pluginPath: void | string, root: string): string;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeRollupExecutorOptions = normalizeRollupExecutorOptions;
4
- exports.normalizePluginPath = normalizePluginPath;
5
- const path_1 = require("path");
6
- const internal_1 = require("@nx/js/internal");
7
- function normalizeRollupExecutorOptions(options, context) {
8
- const { root } = context;
9
- const skipTypeCheck = (0, internal_1.isUsingTsSolutionSetup)() ? true : options.skipTypeCheck;
10
- return {
11
- ...options,
12
- rollupConfig: []
13
- .concat(options.rollupConfig)
14
- .filter(Boolean)
15
- .map((p) => normalizePluginPath(p, root)),
16
- buildLibsFromSource: options.buildLibsFromSource ?? true,
17
- projectRoot: context.projectGraph.nodes[context.projectName].data.root,
18
- skipTypeCheck: skipTypeCheck || false,
19
- };
20
- }
21
- function normalizePluginPath(pluginPath, root) {
22
- if (!pluginPath) {
23
- return '';
24
- }
25
- try {
26
- return require.resolve(pluginPath);
27
- }
28
- catch {
29
- return (0, path_1.resolve)(root, pluginPath);
30
- }
31
- }
@@ -1,7 +0,0 @@
1
- import type * as Rollup from 'rollup';
2
- import { type ExecutorContext } from '@nx/devkit';
3
- import { RollupExecutorOptions } from './schema';
4
- import { NormalizedRollupExecutorOptions } from './lib/normalize';
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[]>;
7
- export default rollupExecutor;
@@ -1,124 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rollupExecutor = rollupExecutor;
4
- exports.createRollupOptions = createRollupOptions;
5
- const path_1 = require("path");
6
- const devkit_1 = require("@nx/devkit");
7
- const internal_1 = require("@nx/devkit/internal");
8
- const normalize_1 = require("./lib/normalize");
9
- const with_nx_1 = require("../../plugins/with-nx/with-nx");
10
- const generate_package_json_1 = require("../../plugins/package-json/generate-package-json");
11
- const internal_2 = require("@nx/js/internal");
12
- const deprecation_1 = require("../../utils/deprecation");
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');
17
- process.env.NODE_ENV ??= 'production';
18
- const options = (0, normalize_1.normalizeRollupExecutorOptions)(rawOptions, context);
19
- const rollupOptions = await createRollupOptions(options, context);
20
- const outfile = resolveOutfile(context, options);
21
- if (options.watch) {
22
- // region Watch build
23
- return yield* (0, internal_1.createAsyncIterable)(({ next }) => {
24
- const watcher = rollup.watch(rollupOptions);
25
- watcher.on('event', (data) => {
26
- if (data.code === 'START') {
27
- devkit_1.logger.info(`Bundling ${context.projectName}...`);
28
- }
29
- else if (data.code === 'END') {
30
- devkit_1.logger.info('Bundle complete. Watching for file changes...');
31
- next({ success: true, outfile });
32
- }
33
- else if (data.code === 'ERROR') {
34
- devkit_1.logger.error(`Error during bundle: ${data.error.message}`);
35
- next({ success: false });
36
- }
37
- });
38
- const processExitListener = (signal) => () => {
39
- watcher.close();
40
- };
41
- process.once('SIGTERM', processExitListener);
42
- process.once('SIGINT', processExitListener);
43
- process.once('SIGQUIT', processExitListener);
44
- });
45
- // endregion
46
- }
47
- else {
48
- // region Single build
49
- try {
50
- devkit_1.logger.info(`Bundling ${context.projectName}...`);
51
- const start = process.hrtime.bigint();
52
- const allRollupOptions = Array.isArray(rollupOptions)
53
- ? rollupOptions
54
- : [rollupOptions];
55
- for (const opts of allRollupOptions) {
56
- const bundle = await rollup.rollup(opts);
57
- const output = Array.isArray(opts.output) ? opts.output : [opts.output];
58
- for (const o of output) {
59
- await bundle.write(o);
60
- }
61
- }
62
- const end = process.hrtime.bigint();
63
- const duration = `${(Number(end - start) / 1_000_000_000).toFixed(2)}s`;
64
- devkit_1.logger.info(`⚡ Done in ${duration}`);
65
- return { success: true, outfile };
66
- }
67
- catch (e) {
68
- if (e.formatted) {
69
- devkit_1.logger.info(e.formatted);
70
- }
71
- else if (e.message) {
72
- devkit_1.logger.info(e.message);
73
- }
74
- devkit_1.logger.error(e);
75
- devkit_1.logger.error(`Bundle failed: ${context.projectName}`);
76
- return { success: false };
77
- }
78
- // endregion
79
- }
80
- }
81
- // -----------------------------------------------------------------------------
82
- async function createRollupOptions(options, context) {
83
- const { dependencies } = (0, internal_2.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, context.targetName, context.configurationName, true);
84
- const rollupConfig = (0, with_nx_1.withNx)(options, {}, dependencies);
85
- // `generatePackageJson` is a plugin rather than being embedded into @nx/rollup:rollup.
86
- // Make sure the plugin is always present to keep the previous before of Nx < 19.4, where it was not a plugin.
87
- const generatePackageJsonPlugin = Array.isArray(rollupConfig.plugins)
88
- ? rollupConfig.plugins.find((p) => p['name'] === generate_package_json_1.pluginName)
89
- : null;
90
- const userDefinedRollupConfigs = options.rollupConfig.map((plugin) => (0, internal_1.loadConfigFile)(plugin));
91
- let finalConfig = rollupConfig;
92
- for (const _config of userDefinedRollupConfigs) {
93
- const config = await _config;
94
- if (typeof config === 'function') {
95
- finalConfig = config(finalConfig, options);
96
- }
97
- else {
98
- finalConfig = {
99
- ...finalConfig,
100
- ...config,
101
- plugins: [
102
- ...(Array.isArray(finalConfig.plugins) &&
103
- finalConfig.plugins?.length > 0
104
- ? finalConfig.plugins
105
- : []),
106
- ...(config.plugins?.length > 0 ? config.plugins : []),
107
- ],
108
- };
109
- }
110
- }
111
- if (generatePackageJsonPlugin &&
112
- Array.isArray(finalConfig.plugins) &&
113
- !finalConfig.plugins.some((p) => p['name'] === generate_package_json_1.pluginName)) {
114
- finalConfig.plugins.push(generatePackageJsonPlugin);
115
- }
116
- return finalConfig;
117
- }
118
- function resolveOutfile(context, options) {
119
- if (!options.format?.includes('cjs'))
120
- return undefined;
121
- const { name } = (0, path_1.parse)(options.outputFileName ?? options.main);
122
- return (0, path_1.resolve)(context.root, options.outputPath, `${name}.cjs.js`);
123
- }
124
- exports.default = rollupExecutor;
@@ -1,191 +0,0 @@
1
- {
2
- "version": 2,
3
- "outputCapture": "direct-nodejs",
4
- "title": "Web Library Rollup Target",
5
- "description": "Packages a library for different web usages (ESM, CommonJS).",
6
- "cli": "nx",
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.",
9
- "properties": {
10
- "project": {
11
- "type": "string",
12
- "description": "The path to package.json file."
13
- },
14
- "main": {
15
- "type": "string",
16
- "description": "The path to the entry file, relative to project.",
17
- "alias": "entryFile",
18
- "x-completion-type": "file",
19
- "x-completion-glob": "**/*@(.js|.ts)",
20
- "x-priority": "important"
21
- },
22
- "outputPath": {
23
- "type": "string",
24
- "description": "The output path of the generated files.",
25
- "x-completion-type": "directory",
26
- "x-priority": "important"
27
- },
28
- "outputFileName": {
29
- "type": "string",
30
- "description": "Name of the main output file. Defaults same basename as 'main' file."
31
- },
32
- "deleteOutputPath": {
33
- "type": "boolean",
34
- "description": "Delete the output path before building.",
35
- "default": true
36
- },
37
- "tsConfig": {
38
- "type": "string",
39
- "description": "The path to tsconfig file.",
40
- "x-completion-type": "file",
41
- "x-completion-glob": "tsconfig.*.json",
42
- "x-priority": "important"
43
- },
44
- "allowJs": {
45
- "type": "boolean",
46
- "description": "Allow JavaScript files to be compiled.",
47
- "default": false
48
- },
49
- "format": {
50
- "type": "array",
51
- "description": "List of module formats to output. Defaults to matching format from tsconfig (e.g. CJS for CommonJS, and ESM otherwise).",
52
- "alias": "f",
53
- "items": {
54
- "type": "string",
55
- "enum": ["esm", "cjs"]
56
- }
57
- },
58
- "external": {
59
- "type": "array",
60
- "description": "A list of external modules that will not be bundled (`react`, `react-dom`, etc.). Can also be set to `all` (bundle nothing) or `none` (bundle everything).",
61
- "oneOf": [
62
- {
63
- "type": "string",
64
- "enum": ["all", "none"]
65
- },
66
- {
67
- "type": "array",
68
- "items": {
69
- "type": "string"
70
- }
71
- }
72
- ]
73
- },
74
- "watch": {
75
- "type": "boolean",
76
- "description": "Enable re-building when files change.",
77
- "default": false
78
- },
79
- "rollupConfig": {
80
- "oneOf": [
81
- {
82
- "type": "array",
83
- "items": {
84
- "type": "string",
85
- "x-completion-type": "file",
86
- "x-completion-glob": "rollup?(*)@(.js|.ts)"
87
- }
88
- },
89
- {
90
- "type": "string",
91
- "x-completion-type": "file",
92
- "x-completion-glob": "rollup?(*)@(.js|.ts)"
93
- }
94
- ],
95
- "description": "Path to a function which takes a rollup config and returns an updated rollup config."
96
- },
97
- "extractCss": {
98
- "type": ["boolean", "string"],
99
- "description": "CSS files will be extracted to the output folder. Alternatively custom filename can be provided (e.g. styles.css)",
100
- "default": true
101
- },
102
- "assets": {
103
- "type": "array",
104
- "description": "List of static assets.",
105
- "default": [],
106
- "items": {
107
- "$ref": "#/definitions/assetPattern"
108
- }
109
- },
110
- "compiler": {
111
- "type": "string",
112
- "enum": ["babel", "swc", "tsc"],
113
- "default": "babel",
114
- "description": "Which compiler to use."
115
- },
116
- "babelUpwardRootMode": {
117
- "type": "boolean",
118
- "description": "Whether to set rootmode to upward. See https://babeljs.io/docs/en/options#rootmode",
119
- "default": false
120
- },
121
- "javascriptEnabled": {
122
- "type": "boolean",
123
- "description": "Sets `javascriptEnabled` option for less loader",
124
- "default": false
125
- },
126
- "generateExportsField": {
127
- "type": "boolean",
128
- "alias": "exports",
129
- "description": "Update the output package.json file's 'exports' field. This field is used by Node and bundles.",
130
- "default": false,
131
- "x-priority": "important"
132
- },
133
- "additionalEntryPoints": {
134
- "type": "array",
135
- "description": "Additional entry-points to add to exports field in the package.json file.",
136
- "items": {
137
- "type": "string"
138
- },
139
- "x-priority": "important"
140
- },
141
- "buildLibsFromSource": {
142
- "type": "boolean",
143
- "description": "Read buildable libraries from source instead of building them separately.",
144
- "default": true
145
- },
146
- "skipTypeCheck": {
147
- "type": "boolean",
148
- "description": "Whether to skip TypeScript type checking.",
149
- "default": false
150
- },
151
- "skipTypeField": {
152
- "type": "boolean",
153
- "description": "Prevents 'type' field from being added to compiled package.json file. Use this if you are having an issue with this field.",
154
- "default": false
155
- },
156
- "sourceMap": {
157
- "description": "Output sourcemaps.",
158
- "type": "boolean"
159
- }
160
- },
161
- "required": ["tsConfig", "main", "outputPath"],
162
- "definitions": {
163
- "assetPattern": {
164
- "oneOf": [
165
- {
166
- "type": "object",
167
- "properties": {
168
- "glob": {
169
- "type": "string",
170
- "description": "The pattern to match."
171
- },
172
- "input": {
173
- "type": "string",
174
- "description": "The input directory path in which to apply `glob`. Defaults to the project root."
175
- },
176
- "output": {
177
- "type": "string",
178
- "description": "Relative path within the output folder."
179
- }
180
- },
181
- "additionalProperties": false,
182
- "required": ["glob", "input", "output"]
183
- },
184
- {
185
- "type": "string"
186
- }
187
- ]
188
- }
189
- },
190
- "examplesFile": "../../../docs/rollup-examples.md"
191
- }
@@ -1,3 +0,0 @@
1
- export declare const ROLLUP_EXECUTOR_DEPRECATION_MESSAGE = "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 targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
2
- export declare function warnRollupExecutorDeprecation(): void;
3
- export declare function warnRollupExecutorGenerating(): void;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ROLLUP_EXECUTOR_DEPRECATION_MESSAGE = void 0;
4
- exports.warnRollupExecutorDeprecation = warnRollupExecutorDeprecation;
5
- exports.warnRollupExecutorGenerating = warnRollupExecutorGenerating;
6
- const devkit_1 = require("@nx/devkit");
7
- // TODO(v24): Remove the @nx/rollup:rollup executor. The inferred plugin
8
- // (@nx/rollup/plugin) and the convert-to-inferred generator stay supported.
9
- exports.ROLLUP_EXECUTOR_DEPRECATION_MESSAGE = '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 targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
10
- function warnRollupExecutorDeprecation() {
11
- devkit_1.logger.warn(exports.ROLLUP_EXECUTOR_DEPRECATION_MESSAGE);
12
- }
13
- // Fired when the @nx/rollup:configuration generator is about to generate a
14
- // target that uses the deprecated executor — i.e. when @nx/rollup/plugin
15
- // isn't registered in nx.json. Surfaces the deprecation at generation time
16
- // rather than only when the user later runs the generated target.
17
- function warnRollupExecutorGenerating() {
18
- devkit_1.logger.warn('Generating a target that uses the deprecated `@nx/rollup:rollup` executor. The executor will be removed in Nx v24. Run `nx g @nx/rollup:convert-to-inferred` next to migrate this target to the `@nx/rollup/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.');
19
- }