@nx/rollup 21.3.0-canary.20250627-07233f0 → 21.3.0-canary.20250701-bfdf892

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-canary.20250627-07233f0",
3
+ "version": "21.3.0-canary.20250701-bfdf892",
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-canary.20250627-07233f0",
33
- "@nx/js": "21.3.0-canary.20250627-07233f0",
32
+ "@nx/devkit": "21.3.0-canary.20250701-bfdf892",
33
+ "@nx/js": "21.3.0-canary.20250701-bfdf892",
34
34
  "@rollup/plugin-babel": "^6.0.4",
35
35
  "@rollup/plugin-commonjs": "^25.0.7",
36
36
  "@rollup/plugin-image": "^3.0.3",
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withNx = withNx;
4
4
  const node_fs_1 = require("node:fs");
5
5
  const node_path_1 = require("node:path");
6
- const ts = require("typescript");
7
6
  const plugin_babel_1 = require("@rollup/plugin-babel");
8
7
  const autoprefixer = require("autoprefixer");
9
8
  const devkit_1 = require("@nx/devkit");
@@ -24,6 +23,18 @@ const json = require('@rollup/plugin-json');
24
23
  const copy = require('rollup-plugin-copy');
25
24
  const postcss = require('rollup-plugin-postcss');
26
25
  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
+ }
27
38
  function withNx(rawOptions, rollupConfig = {},
28
39
  // Passed by @nx/rollup:rollup executor to previous behavior of remapping tsconfig paths based on buildable dependencies remains intact.
29
40
  dependencies) {
@@ -46,6 +57,7 @@ dependencies) {
46
57
  const tsConfigPath = options.buildLibsFromSource || global.NX_GRAPH_CREATION
47
58
  ? (0, node_path_1.join)(devkit_1.workspaceRoot, options.tsConfig)
48
59
  : (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, devkit_1.workspaceRoot, projectRoot, dependencies);
60
+ ensureTypeScript();
49
61
  const tsConfigFile = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
50
62
  const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, (0, node_path_1.dirname)(tsConfigPath));
51
63
  if (!options.format || !options.format.length) {
@@ -122,6 +134,8 @@ dependencies) {
122
134
  };
123
135
  }
124
136
  if (!global.NX_GRAPH_CREATION) {
137
+ // Ensure TypeScript is available before any plugin initialization
138
+ ensureTypeScript();
125
139
  const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
126
140
  if (isTsSolutionSetup) {
127
141
  if (options.generatePackageJson) {
@@ -160,13 +174,24 @@ dependencies) {
160
174
  },
161
175
  });
162
176
  })()
163
- : require('@rollup/plugin-typescript')({
164
- tsconfig: tsConfigPath,
165
- compilerOptions,
166
- declaration: true,
167
- declarationMap: !!options.sourceMap,
168
- noEmitOnError: !options.skipTypeCheck,
169
- }),
177
+ : (() => {
178
+ // @rollup/plugin-typescript needs outDir and declarationDir to match Rollup's output directory
179
+ const { outDir, declarationDir, ...tsCompilerOptions } = compilerOptions;
180
+ const rollupOutputDir = Array.isArray(finalConfig.output)
181
+ ? finalConfig.output[0].dir
182
+ : finalConfig.output.dir;
183
+ return require('@rollup/plugin-typescript')({
184
+ tsconfig: tsConfigPath,
185
+ compilerOptions: {
186
+ ...tsCompilerOptions,
187
+ outDir: rollupOutputDir,
188
+ declarationDir: rollupOutputDir,
189
+ },
190
+ declaration: true,
191
+ declarationMap: !!options.sourceMap,
192
+ noEmitOnError: !options.skipTypeCheck,
193
+ });
194
+ })(),
170
195
  (0, type_definitions_1.typeDefinitions)({
171
196
  projectRoot,
172
197
  }),
@@ -243,6 +268,7 @@ function createTsCompilerOptions(projectRoot, config, options, dependencies) {
243
268
  declaration: true,
244
269
  paths: compilerOptionPaths,
245
270
  };
271
+ ensureTypeScript();
246
272
  if (config.options.module === ts.ModuleKind.CommonJS) {
247
273
  compilerOptions['module'] = 'ESNext';
248
274
  }
@@ -260,6 +286,7 @@ function convertCopyAssetsToRollupOptions(outputPath, assets) {
260
286
  : undefined;
261
287
  }
262
288
  function readCompatibleFormats(config) {
289
+ ensureTypeScript();
263
290
  switch (config.options.module) {
264
291
  case ts.ModuleKind.CommonJS:
265
292
  case ts.ModuleKind.UMD: