@nx/rollup 21.3.0-beta.5 → 21.3.0-canary.20250613-18155f4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/rollup",
3
- "version": "21.3.0-beta.5",
3
+ "version": "21.3.0-canary.20250613-18155f4",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Rollup contains executors and generators that support building applications using Rollup.",
6
6
  "repository": {
@@ -29,8 +29,8 @@
29
29
  "migrations": "./migrations.json"
30
30
  },
31
31
  "dependencies": {
32
- "@nx/devkit": "21.3.0-beta.5",
33
- "@nx/js": "21.3.0-beta.5",
32
+ "@nx/devkit": "21.3.0-canary.20250613-18155f4",
33
+ "@nx/js": "21.3.0-canary.20250613-18155f4",
34
34
  "@rollup/plugin-babel": "^6.0.4",
35
35
  "@rollup/plugin-commonjs": "^25.0.7",
36
36
  "@rollup/plugin-image": "^3.0.3",
@@ -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
  }
@@ -155,11 +155,6 @@
155
155
  "sourceMap": {
156
156
  "description": "Output sourcemaps.",
157
157
  "type": "boolean"
158
- },
159
- "useLegacyTypescriptPlugin": {
160
- "type": "boolean",
161
- "description": "Use rollup-plugin-typescript2 instead of @rollup/plugin-typescript.",
162
- "default": true
163
158
  }
164
159
  },
165
160
  "required": ["tsConfig", "main", "outputPath"],
@@ -80,10 +80,6 @@ export interface RollupWithNxPluginOptions {
80
80
  * The path to tsconfig file.
81
81
  */
82
82
  tsConfig: string;
83
- /**
84
- * Use rollup-plugin-typescript2 instead of @rollup/plugin-typescript.
85
- */
86
- useLegacyTypescriptPlugin?: boolean;
87
83
  /**
88
84
  * Whether to generate a package.json file in the output path. It's not supported when the workspace is
89
85
  * set up with TypeScript Project References along with the package managers' Workspaces feature. Otherwise,
@@ -1,4 +1,4 @@
1
- import { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-utils';
2
1
  import * as rollup from 'rollup';
2
+ import { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-utils';
3
3
  import { RollupWithNxPluginOptions } from './with-nx-options';
4
4
  export declare function withNx(rawOptions: RollupWithNxPluginOptions, rollupConfig?: rollup.RollupOptions, dependencies?: DependentBuildableProjectNode[]): rollup.RollupOptions;
@@ -1,21 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withNx = withNx;
4
+ const node_fs_1 = require("node:fs");
5
+ const node_path_1 = require("node:path");
6
+ const ts = require("typescript");
7
+ const plugin_babel_1 = require("@rollup/plugin-babel");
8
+ const autoprefixer = require("autoprefixer");
4
9
  const devkit_1 = require("@nx/devkit");
5
- const type_definitions_1 = require("@nx/js/src/plugins/rollup/type-definitions");
6
10
  const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
7
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
- const plugin_babel_1 = require("@rollup/plugin-babel");
9
11
  const plugin_node_resolve_1 = require("@rollup/plugin-node-resolve");
10
- const autoprefixer = require("autoprefixer");
11
- const node_fs_1 = require("node:fs");
12
- const node_path_1 = require("node:path");
12
+ const type_definitions_1 = require("@nx/js/src/plugins/rollup/type-definitions");
13
13
  const analyze_1 = require("../analyze");
14
- const delete_output_1 = require("../delete-output");
15
- const generate_package_json_1 = require("../package-json/generate-package-json");
16
14
  const swc_1 = require("../swc");
15
+ const generate_package_json_1 = require("../package-json/generate-package-json");
17
16
  const get_project_node_1 = require("./get-project-node");
17
+ const delete_output_1 = require("../delete-output");
18
18
  const normalize_options_1 = require("./normalize-options");
19
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
19
20
  // These use require because the ES import isn't correct.
20
21
  const commonjs = require('@rollup/plugin-commonjs');
21
22
  const image = require('@rollup/plugin-image');
@@ -23,18 +24,6 @@ const json = require('@rollup/plugin-json');
23
24
  const copy = require('rollup-plugin-copy');
24
25
  const postcss = require('rollup-plugin-postcss');
25
26
  const fileExtensions = ['.js', '.jsx', '.ts', '.tsx'];
26
- let ts;
27
- function ensureTypeScript() {
28
- if (!ts) {
29
- try {
30
- ts = require('typescript');
31
- }
32
- catch (e) {
33
- throw new Error('TypeScript is required for the @nx/rollup plugin. Please install it in your workspace.');
34
- }
35
- }
36
- return ts;
37
- }
38
27
  function withNx(rawOptions, rollupConfig = {},
39
28
  // Passed by @nx/rollup:rollup executor to previous behavior of remapping tsconfig paths based on buildable dependencies remains intact.
40
29
  dependencies) {
@@ -51,14 +40,12 @@ dependencies) {
51
40
  const result = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(undefined, projectGraph, devkit_1.workspaceRoot, projectNode.name, process.env.NX_TASK_TARGET_TARGET, process.env.NX_TASK_TARGET_CONFIGURATION, true);
52
41
  dependencies = result.dependencies;
53
42
  }
54
- const projectSourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(projectNode.data);
55
- const options = (0, normalize_options_1.normalizeOptions)(projectNode.data.root, projectSourceRoot, rawOptions);
43
+ const options = (0, normalize_options_1.normalizeOptions)(projectNode.data.root, projectNode.data.sourceRoot, rawOptions);
56
44
  const useBabel = options.compiler === 'babel';
57
45
  const useSwc = options.compiler === 'swc';
58
46
  const tsConfigPath = options.buildLibsFromSource || global.NX_GRAPH_CREATION
59
47
  ? (0, node_path_1.join)(devkit_1.workspaceRoot, options.tsConfig)
60
48
  : (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, devkit_1.workspaceRoot, projectRoot, dependencies);
61
- ensureTypeScript();
62
49
  const tsConfigFile = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
63
50
  const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, (0, node_path_1.dirname)(tsConfigPath));
64
51
  if (!options.format || !options.format.length) {
@@ -135,8 +122,6 @@ dependencies) {
135
122
  };
136
123
  }
137
124
  if (!global.NX_GRAPH_CREATION) {
138
- // Ensure TypeScript is available before any plugin initialization
139
- ensureTypeScript();
140
125
  const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
141
126
  if (isTsSolutionSetup) {
142
127
  if (options.generatePackageJson) {
@@ -149,50 +134,20 @@ dependencies) {
149
134
  else {
150
135
  options.generatePackageJson ??= true;
151
136
  }
152
- const compilerOptions = createTsCompilerOptions(projectRoot, tsConfig, options, dependencies);
153
- compilerOptions.outDir = Array.isArray(finalConfig.output)
154
- ? finalConfig.output[0].dir
155
- : finalConfig.output.dir;
156
137
  finalConfig.plugins = [
157
138
  copy({
158
139
  targets: convertCopyAssetsToRollupOptions(options.outputPath, options.assets),
159
140
  }),
160
141
  image(),
161
142
  json(),
162
- // TypeScript compilation and declaration generation
163
- // TODO(v22): Change default value of useLegacyTypescriptPlugin to false for Nx 22
164
- options.useLegacyTypescriptPlugin !== false
165
- ? (() => {
166
- // TODO(v23): Remove in Nx 23
167
- // Show deprecation warning
168
- devkit_1.logger.warn(`rollup-plugin-typescript2 usage is deprecated and will be removed in Nx 23. ` +
169
- `Set 'useLegacyTypescriptPlugin: false' to use the official @rollup/plugin-typescript.`);
170
- return require('rollup-plugin-typescript2')({
171
- check: !options.skipTypeCheck,
172
- tsconfig: tsConfigPath,
173
- tsconfigOverride: {
174
- compilerOptions,
175
- },
176
- });
177
- })()
178
- : (() => {
179
- // @rollup/plugin-typescript needs outDir and declarationDir to match Rollup's output directory
180
- const { outDir, declarationDir, ...tsCompilerOptions } = compilerOptions;
181
- const rollupOutputDir = Array.isArray(finalConfig.output)
182
- ? finalConfig.output[0].dir
183
- : finalConfig.output.dir;
184
- return require('@rollup/plugin-typescript')({
185
- tsconfig: tsConfigPath,
186
- compilerOptions: {
187
- ...tsCompilerOptions,
188
- outDir: rollupOutputDir,
189
- declarationDir: rollupOutputDir,
190
- },
191
- declaration: true,
192
- declarationMap: !!options.sourceMap,
193
- noEmitOnError: !options.skipTypeCheck,
194
- });
195
- })(),
143
+ // Needed to generate type definitions, even if we're using babel or swc.
144
+ require('rollup-plugin-typescript2')({
145
+ check: !options.skipTypeCheck,
146
+ tsconfig: tsConfigPath,
147
+ tsconfigOverride: {
148
+ compilerOptions: createTsCompilerOptions(projectRoot, tsConfig, options, dependencies),
149
+ },
150
+ }),
196
151
  (0, type_definitions_1.typeDefinitions)({
197
152
  projectRoot,
198
153
  }),
@@ -223,7 +178,7 @@ dependencies) {
223
178
  supportsStaticESM: true,
224
179
  isModern: true,
225
180
  },
226
- cwd: (0, node_path_1.join)(devkit_1.workspaceRoot, projectSourceRoot),
181
+ cwd: (0, node_path_1.join)(devkit_1.workspaceRoot, projectNode.data.sourceRoot ?? projectNode.data.root),
227
182
  rootMode: options.babelUpwardRootMode ? 'upward' : undefined,
228
183
  babelrc: true,
229
184
  extensions: fileExtensions,
@@ -269,7 +224,6 @@ function createTsCompilerOptions(projectRoot, config, options, dependencies) {
269
224
  declaration: true,
270
225
  paths: compilerOptionPaths,
271
226
  };
272
- ensureTypeScript();
273
227
  if (config.options.module === ts.ModuleKind.CommonJS) {
274
228
  compilerOptions['module'] = 'ESNext';
275
229
  }
@@ -287,7 +241,6 @@ function convertCopyAssetsToRollupOptions(outputPath, assets) {
287
241
  : undefined;
288
242
  }
289
243
  function readCompatibleFormats(config) {
290
- ensureTypeScript();
291
244
  switch (config.options.module) {
292
245
  case ts.ModuleKind.CommonJS:
293
246
  case ts.ModuleKind.UMD: