@nx/rollup 20.0.8 → 20.1.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/rollup",
3
- "version": "20.0.8",
3
+ "version": "20.1.0-beta.0",
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": {
@@ -43,8 +43,8 @@
43
43
  "rollup-plugin-postcss": "^4.0.2",
44
44
  "rollup-plugin-typescript2": "^0.36.0",
45
45
  "tslib": "^2.3.0",
46
- "@nx/devkit": "20.0.8",
47
- "@nx/js": "20.0.8"
46
+ "@nx/devkit": "20.1.0-beta.0",
47
+ "@nx/js": "20.1.0-beta.0"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"
package/plugin.d.ts CHANGED
@@ -1 +1 @@
1
- export { createNodes, RollupPluginOptions } from './src/plugins/plugin';
1
+ export { createNodes, createNodesV2, RollupPluginOptions, } from './src/plugins/plugin';
package/plugin.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = void 0;
3
+ exports.createNodesV2 = exports.createNodes = void 0;
4
4
  var plugin_1 = require("./src/plugins/plugin");
5
5
  Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
6
+ Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
@@ -2,12 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configurationGenerator = configurationGenerator;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
6
+ const js_1 = require("@nx/js");
5
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");
6
9
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
- const init_1 = require("../init/init");
8
- const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
10
+ const posix_1 = require("node:path/posix");
11
+ const devkit_internals_1 = require("nx/src/devkit-internals");
9
12
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
10
13
  const has_plugin_1 = require("../../utils/has-plugin");
14
+ const init_1 = require("../init/init");
15
+ let ts;
11
16
  async function configurationGenerator(tree, options) {
12
17
  const tasks = [];
13
18
  const nxJson = (0, devkit_1.readNxJson)(tree);
@@ -18,30 +23,40 @@ async function configurationGenerator(tree, options) {
18
23
  if (!options.skipPackageJson) {
19
24
  tasks.push((0, ensure_dependencies_1.ensureDependencies)(tree, options));
20
25
  }
26
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
27
+ let outputConfig;
21
28
  if ((0, has_plugin_1.hasPlugin)(tree)) {
22
- createRollupConfig(tree, options);
29
+ outputConfig = createRollupConfig(tree, options, isTsSolutionSetup);
23
30
  }
24
31
  else {
25
32
  options.buildTarget ??= 'build';
26
33
  checkForTargetConflicts(tree, options);
27
- addBuildTarget(tree, options);
34
+ addBuildTarget(tree, options, isTsSolutionSetup);
35
+ }
36
+ updatePackageJson(tree, options, outputConfig, isTsSolutionSetup);
37
+ if (isTsSolutionSetup) {
38
+ updateTsConfig(tree, options);
28
39
  }
29
- addPackageJson(tree, options);
30
40
  if (!options.skipFormat) {
31
41
  await (0, devkit_1.formatFiles)(tree);
32
42
  }
33
43
  return (0, devkit_1.runTasksInSerial)(...tasks);
34
44
  }
35
- function createRollupConfig(tree, options) {
36
- const isUsingTsPlugin = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
45
+ function createRollupConfig(tree, options, isTsSolutionSetup) {
37
46
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
47
+ const main = options.main
48
+ ? `./${(0, posix_1.relative)(project.root, options.main)}`
49
+ : './src/index.ts';
50
+ const outputPath = isTsSolutionSetup
51
+ ? './dist'
52
+ : (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(project.root), 'dist', project.root === '.' ? project.name : project.root);
38
53
  const buildOptions = {
39
- outputPath: isUsingTsPlugin
40
- ? './dist'
41
- : (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(project.root), 'dist', project.root === '.' ? project.name : project.root),
54
+ outputPath,
42
55
  compiler: options.compiler ?? 'babel',
43
- main: options.main ?? './src/index.ts',
44
- tsConfig: options.tsConfig ?? './tsconfig.lib.json',
56
+ main,
57
+ tsConfig: options.tsConfig
58
+ ? `./${(0, posix_1.relative)(project.root, options.tsConfig)}`
59
+ : './tsconfig.lib.json',
45
60
  };
46
61
  tree.write((0, devkit_1.joinPathFragments)(project.root, 'rollup.config.js'), `const { withNx } = require('@nx/rollup/with-nx');
47
62
 
@@ -51,8 +66,10 @@ module.exports = withNx(
51
66
  outputPath: '${buildOptions.outputPath}',
52
67
  tsConfig: '${buildOptions.tsConfig}',
53
68
  compiler: '${buildOptions.compiler}',
54
- format: ${JSON.stringify(options.format ?? ['esm'])},
55
- assets: [{ input: '.', output: '.', glob:'*.md' }],
69
+ format: ${JSON.stringify(options.format ?? ['esm'])},${!isTsSolutionSetup
70
+ ? `
71
+ assets: [{ input: '.', output: '.', glob:'*.md' }],`
72
+ : ''}
56
73
  },
57
74
  {
58
75
  // Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
@@ -61,6 +78,10 @@ module.exports = withNx(
61
78
  }
62
79
  );
63
80
  `);
81
+ return {
82
+ main: (0, devkit_1.joinPathFragments)(project.root, main),
83
+ outputPath: (0, devkit_1.joinPathFragments)(project.root, outputPath),
84
+ };
64
85
  }
65
86
  function checkForTargetConflicts(tree, options) {
66
87
  if (options.skipValidation)
@@ -70,48 +91,99 @@ function checkForTargetConflicts(tree, options) {
70
91
  throw new Error(`Project "${options.project}" already has a ${options.buildTarget} target. Pass --skipValidation to ignore this error.`);
71
92
  }
72
93
  }
73
- function addPackageJson(tree, options) {
94
+ function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
74
95
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
75
- const packageJsonPath = (0, devkit_1.joinPathFragments)(project.root, 'package.json');
76
- if (!tree.exists(packageJsonPath)) {
77
- const importPath = options.importPath || (0, get_import_path_1.getImportPath)(tree, options.project);
78
- (0, devkit_1.writeJson)(tree, packageJsonPath, {
79
- name: importPath,
96
+ const packageJsonPath = (0, posix_1.join)(project.root, 'package.json');
97
+ let packageJson;
98
+ if (tree.exists(packageJsonPath)) {
99
+ if (!isTsSolutionSetup) {
100
+ return;
101
+ }
102
+ packageJson = (0, devkit_1.readJson)(tree, packageJsonPath);
103
+ }
104
+ else {
105
+ packageJson = {
106
+ name: options.importPath || (0, get_import_path_1.getImportPath)(tree, options.project),
80
107
  version: '0.0.1',
108
+ };
109
+ }
110
+ if (isTsSolutionSetup) {
111
+ let main;
112
+ let outputPath;
113
+ if (outputConfig) {
114
+ ({ main, outputPath } = outputConfig);
115
+ }
116
+ else {
117
+ // target must exist if we don't receive an outputConfig
118
+ const projectTarget = project.targets[options.buildTarget];
119
+ 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]);
123
+ ({ main, outputPath } = mergedTarget.options);
124
+ }
125
+ packageJson = (0, js_1.getUpdatedPackageJsonContent)(packageJson, {
126
+ main,
127
+ outputPath,
128
+ projectRoot: project.root,
129
+ rootDir: (0, posix_1.dirname)(main),
130
+ generateExportsField: true,
131
+ packageJsonPath,
132
+ format: options.format ?? ['esm'],
133
+ outputFileExtensionForCjs: '.cjs.js',
134
+ outputFileExtensionForEsm: '.esm.js',
81
135
  });
136
+ // rollup has a specific declaration file generation not handled by the util above,
137
+ // adjust accordingly
138
+ const typingsFile = (packageJson.module ?? packageJson.main).replace(/\.js$/, '.d.ts');
139
+ packageJson.types = typingsFile;
140
+ packageJson.exports['.'].types = typingsFile;
82
141
  }
142
+ (0, devkit_1.writeJson)(tree, packageJsonPath, packageJson);
83
143
  }
84
- function addBuildTarget(tree, options) {
144
+ function addBuildTarget(tree, options, isTsSolutionSetup) {
85
145
  (0, target_defaults_utils_1.addBuildTargetDefaults)(tree, '@nx/rollup:rollup', options.buildTarget);
86
146
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
87
147
  const prevBuildOptions = project.targets?.[options.buildTarget]?.options;
148
+ options.tsConfig ??=
149
+ prevBuildOptions?.tsConfig ??
150
+ (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.lib.json');
151
+ let outputPath = prevBuildOptions?.outputPath;
152
+ if (!outputPath) {
153
+ outputPath = isTsSolutionSetup
154
+ ? (0, devkit_1.joinPathFragments)(project.root, 'dist')
155
+ : (0, devkit_1.joinPathFragments)('dist', project.root === '.' ? project.name : project.root);
156
+ }
88
157
  const buildOptions = {
89
158
  main: options.main ??
90
159
  prevBuildOptions?.main ??
91
160
  (0, devkit_1.joinPathFragments)(project.root, 'src/index.ts'),
92
- outputPath: prevBuildOptions?.outputPath ??
93
- (0, devkit_1.joinPathFragments)('dist', project.root === '.' ? project.name : project.root),
94
- tsConfig: options.tsConfig ??
95
- prevBuildOptions?.tsConfig ??
96
- (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.lib.json'),
97
- additionalEntryPoints: prevBuildOptions?.additionalEntryPoints,
98
- generateExportsField: prevBuildOptions?.generateExportsField,
161
+ outputPath,
162
+ tsConfig: options.tsConfig,
163
+ // TODO(leo): see if we can use this when updating the package.json for the new setup
164
+ // additionalEntryPoints: prevBuildOptions?.additionalEntryPoints,
165
+ // generateExportsField: prevBuildOptions?.generateExportsField,
99
166
  compiler: options.compiler ?? 'babel',
100
167
  project: `${project.root}/package.json`,
101
168
  external: options.external,
102
- format: options.format,
169
+ format: options.format ?? isTsSolutionSetup ? ['esm'] : undefined,
103
170
  };
104
171
  if (options.rollupConfig) {
105
172
  buildOptions.rollupConfig = options.rollupConfig;
106
173
  }
107
- if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'README.md'))) {
108
- buildOptions.assets = [
109
- {
110
- glob: `${project.root}/README.md`,
111
- input: '.',
112
- output: '.',
113
- },
114
- ];
174
+ if (!isTsSolutionSetup) {
175
+ buildOptions.additionalEntryPoints =
176
+ prevBuildOptions?.additionalEntryPoints;
177
+ buildOptions.generateExportsField = prevBuildOptions?.generateExportsField;
178
+ if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'README.md'))) {
179
+ buildOptions.assets = [
180
+ {
181
+ glob: `${project.root}/README.md`,
182
+ input: '.',
183
+ output: '.',
184
+ },
185
+ ];
186
+ }
115
187
  }
116
188
  (0, devkit_1.updateProjectConfiguration)(tree, options.project, {
117
189
  ...project,
@@ -125,4 +197,27 @@ function addBuildTarget(tree, options) {
125
197
  },
126
198
  });
127
199
  }
200
+ function updateTsConfig(tree, options) {
201
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
202
+ const tsconfigPath = options.tsConfig ?? (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.lib.json');
203
+ if (!tree.exists(tsconfigPath)) {
204
+ 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.`);
205
+ }
206
+ if (!ts) {
207
+ ts = (0, ensure_typescript_1.ensureTypescript)();
208
+ }
209
+ const parsedTsConfig = (0, js_1.readTsConfig)(tsconfigPath, {
210
+ ...ts.sys,
211
+ readFile: (p) => tree.read(p, 'utf-8'),
212
+ fileExists: (p) => tree.exists(p),
213
+ });
214
+ (0, devkit_1.updateJson)(tree, tsconfigPath, (json) => {
215
+ if (parsedTsConfig.options.module === ts.ModuleKind.NodeNext) {
216
+ json.compilerOptions ??= {};
217
+ json.compilerOptions.module = 'esnext';
218
+ json.compilerOptions.moduleResolution = 'bundler';
219
+ }
220
+ return json;
221
+ });
222
+ }
128
223
  exports.default = configurationGenerator;
@@ -25,13 +25,13 @@
25
25
  },
26
26
  "main": {
27
27
  "type": "string",
28
- "description": "Path relative to the workspace root for the main entry file. Defaults to '<projectRoot>/src/main.ts'.",
28
+ "description": "Path relative to the workspace root for the main entry file. Defaults to '<projectRoot>/src/index.ts'.",
29
29
  "alias": "entryFile",
30
30
  "x-priority": "important"
31
31
  },
32
32
  "tsConfig": {
33
33
  "type": "string",
34
- "description": "Path relative to the workspace root for the tsconfig file to build with. Defaults to '<projectRoot>/tsconfig.app.json'.",
34
+ "description": "Path relative to the workspace root for the tsconfig file to build with. Defaults to '<projectRoot>/tsconfig.lib.json'.",
35
35
  "x-priority": "important"
36
36
  },
37
37
  "skipFormat": {
@@ -1,6 +1,10 @@
1
- import { type CreateDependencies, type CreateNodes } from '@nx/devkit';
1
+ import { type CreateDependencies, type CreateNodes, CreateNodesV2 } from '@nx/devkit';
2
+ /**
3
+ * @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
4
+ */
2
5
  export declare const createDependencies: CreateDependencies;
3
6
  export interface RollupPluginOptions {
4
7
  buildTargetName?: string;
5
8
  }
6
9
  export declare const createNodes: CreateNodes<RollupPluginOptions>;
10
+ export declare const createNodesV2: CreateNodesV2<RollupPluginOptions>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = exports.createDependencies = void 0;
3
+ exports.createNodesV2 = exports.createNodes = exports.createDependencies = void 0;
4
4
  const cache_directory_1 = require("nx/src/utils/cache-directory");
5
5
  const path_1 = require("path");
6
6
  const fs_1 = require("fs");
@@ -8,47 +8,64 @@ const devkit_1 = require("@nx/devkit");
8
8
  const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
9
9
  const js_1 = require("@nx/js");
10
10
  const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
11
- const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'rollup.hash');
12
- const targetsCache = readTargetsCache();
13
- function readTargetsCache() {
11
+ const file_hasher_1 = require("nx/src/hasher/file-hasher");
12
+ const pmc = (0, devkit_1.getPackageManagerCommand)();
13
+ function readTargetsCache(cachePath) {
14
14
  return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
15
15
  }
16
- function writeTargetsToCache() {
17
- const oldCache = readTargetsCache();
18
- (0, devkit_1.writeJsonFile)(cachePath, {
19
- ...oldCache,
20
- ...targetsCache,
21
- });
16
+ function writeTargetsToCache(cachePath, results) {
17
+ (0, devkit_1.writeJsonFile)(cachePath, results);
22
18
  }
19
+ /**
20
+ * @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
21
+ */
23
22
  const createDependencies = () => {
24
- writeTargetsToCache();
25
23
  return [];
26
24
  };
27
25
  exports.createDependencies = createDependencies;
26
+ const rollupConfigGlob = '**/rollup.config.{js,cjs,mjs}';
28
27
  exports.createNodes = [
29
- '**/rollup.config.{js,cjs,mjs}',
28
+ rollupConfigGlob,
30
29
  async (configFilePath, options, context) => {
31
- const projectRoot = (0, path_1.dirname)(configFilePath);
32
- const fullyQualifiedProjectRoot = (0, path_1.join)(context.workspaceRoot, projectRoot);
33
- // Do not create a project if package.json and project.json do not exist
34
- const siblingFiles = (0, fs_1.readdirSync)(fullyQualifiedProjectRoot);
35
- if (!siblingFiles.includes('package.json') &&
36
- !siblingFiles.includes('project.json')) {
37
- return {};
30
+ devkit_1.logger.warn('`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.');
31
+ return createNodesInternal(configFilePath, normalizeOptions(options), context, {});
32
+ },
33
+ ];
34
+ exports.createNodesV2 = [
35
+ rollupConfigGlob,
36
+ async (configFilePaths, options, context) => {
37
+ const normalizedOptions = normalizeOptions(options);
38
+ const optionsHash = (0, file_hasher_1.hashObject)(normalizedOptions);
39
+ const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `rollup-${optionsHash}.hash`);
40
+ const targetsCache = readTargetsCache(cachePath);
41
+ try {
42
+ return await (0, devkit_1.createNodesFromFiles)((configFile, _, context) => createNodesInternal(configFile, normalizedOptions, context, targetsCache), configFilePaths, normalizedOptions, context);
43
+ }
44
+ finally {
45
+ writeTargetsToCache(cachePath, targetsCache);
38
46
  }
39
- options = normalizeOptions(options);
40
- const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
41
- targetsCache[hash] ??= await buildRollupTarget(configFilePath, projectRoot, options, context);
42
- return {
43
- projects: {
44
- [projectRoot]: {
45
- root: projectRoot,
46
- targets: targetsCache[hash],
47
- },
48
- },
49
- };
50
47
  },
51
48
  ];
49
+ async function createNodesInternal(configFilePath, options, context, targetsCache) {
50
+ const projectRoot = (0, path_1.dirname)(configFilePath);
51
+ const fullyQualifiedProjectRoot = (0, path_1.join)(context.workspaceRoot, projectRoot);
52
+ // Do not create a project if package.json and project.json do not exist
53
+ const siblingFiles = (0, fs_1.readdirSync)(fullyQualifiedProjectRoot);
54
+ if (!siblingFiles.includes('package.json') &&
55
+ !siblingFiles.includes('project.json')) {
56
+ return {};
57
+ }
58
+ const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
59
+ targetsCache[hash] ??= await buildRollupTarget(configFilePath, projectRoot, options, context);
60
+ return {
61
+ projects: {
62
+ [projectRoot]: {
63
+ root: projectRoot,
64
+ targets: targetsCache[hash],
65
+ },
66
+ },
67
+ };
68
+ }
52
69
  async function buildRollupTarget(configFilePath, projectRoot, options, context) {
53
70
  let loadConfigFile;
54
71
  try {
@@ -83,6 +100,19 @@ async function buildRollupTarget(configFilePath, projectRoot, options, context)
83
100
  { externalDependencies: ['rollup'] },
84
101
  ],
85
102
  outputs,
103
+ metadata: {
104
+ technologies: ['rollup'],
105
+ description: 'Run Rollup',
106
+ help: {
107
+ command: `${pmc.exec} rollup --help`,
108
+ example: {
109
+ options: {
110
+ sourcemap: true,
111
+ watch: true,
112
+ },
113
+ },
114
+ },
115
+ },
86
116
  };
87
117
  return targets;
88
118
  }
@@ -113,7 +143,7 @@ function getOutputs(rollupConfigs, projectRoot) {
113
143
  return Array.from(outputs);
114
144
  }
115
145
  function normalizeOptions(options) {
116
- options ??= {};
117
- options.buildTargetName ??= 'build';
118
- return options;
146
+ return {
147
+ buildTargetName: options.buildTargetName ?? 'build',
148
+ };
119
149
  }
@@ -76,6 +76,12 @@ export interface RollupWithNxPluginOptions {
76
76
  * The path to tsconfig file.
77
77
  */
78
78
  tsConfig: string;
79
+ /**
80
+ * Whether to generate a package.json file in the output path. It's not supported when the workspace is
81
+ * set up with TypeScript Project References along with the package managers' Workspaces feature. Otherwise,
82
+ * it defaults to `true`.
83
+ */
84
+ generatePackageJson?: boolean;
79
85
  }
80
86
  export interface AssetGlobPattern {
81
87
  glob: string;
@@ -16,6 +16,7 @@ const generate_package_json_1 = require("../package-json/generate-package-json")
16
16
  const get_project_node_1 = require("./get-project-node");
17
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');
@@ -119,6 +120,18 @@ dependencies) {
119
120
  };
120
121
  }
121
122
  if (!global.NX_GRAPH_CREATION) {
123
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
124
+ if (isTsSolutionSetup) {
125
+ if (options.generatePackageJson) {
126
+ throw new Error(`Setting 'generatePackageJson: true' is not supported with the current TypeScript setup. Update the 'package.json' file at the project root as needed and unset the 'generatePackageJson' option.`);
127
+ }
128
+ if (options.generateExportsField) {
129
+ throw new Error(`Setting 'generateExportsField: true' is not supported with the current TypeScript setup. Set 'exports' field in the 'package.json' file at the project root and unset the 'generateExportsField' option.`);
130
+ }
131
+ }
132
+ else {
133
+ options.generatePackageJson ??= true;
134
+ }
122
135
  finalConfig.plugins = [
123
136
  copy({
124
137
  targets: convertCopyAssetsToRollupOptions(options.outputPath, options.assets),
@@ -173,7 +186,7 @@ dependencies) {
173
186
  }),
174
187
  commonjs(),
175
188
  (0, analyze_1.analyze)(),
176
- (0, generate_package_json_1.generatePackageJson)(options, packageJson),
189
+ options.generatePackageJson && (0, generate_package_json_1.generatePackageJson)(options, packageJson),
177
190
  ];
178
191
  if (Array.isArray(rollupConfig.plugins)) {
179
192
  finalConfig.plugins.push(...rollupConfig.plugins);