@nx/rollup 18.3.0-beta.0 → 18.3.0-beta.2

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": "18.3.0-beta.0",
3
+ "version": "18.3.0-beta.2",
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": {
@@ -44,9 +44,9 @@
44
44
  "rollup-plugin-postcss": "^4.0.1",
45
45
  "rollup-plugin-typescript2": "0.36.0",
46
46
  "tslib": "^2.3.0",
47
- "@nx/devkit": "18.3.0-beta.0",
48
- "@nx/js": "18.3.0-beta.0",
49
- "@nrwl/rollup": "18.3.0-beta.0"
47
+ "@nx/devkit": "18.3.0-beta.2",
48
+ "@nx/js": "18.3.0-beta.2",
49
+ "@nrwl/rollup": "18.3.0-beta.2"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"
@@ -42,7 +42,7 @@ function updatePackageJson(options, packageJson) {
42
42
  fileExt: '.cjs.js',
43
43
  });
44
44
  packageJson.main = cjsExports['.'];
45
- if (!hasEsmFormat) {
45
+ if (!hasEsmFormat && !options.skipTypeField) {
46
46
  packageJson.type = 'commonjs';
47
47
  }
48
48
  if (options.generateExportsField) {
@@ -11,5 +11,5 @@ export declare function rollupExecutor(rawOptions: RollupExecutorOptions, contex
11
11
  success: boolean;
12
12
  outfile?: undefined;
13
13
  }, unknown>;
14
- export declare function createRollupOptions(options: NormalizedRollupExecutorOptions, dependencies: DependentBuildableProjectNode[], context: ExecutorContext, packageJson: PackageJson, sourceRoot: string, npmDeps: string[]): Promise<rollup.RollupOptions>;
14
+ export declare function createRollupOptions(options: NormalizedRollupExecutorOptions, dependencies: DependentBuildableProjectNode[], context: ExecutorContext, packageJson: PackageJson, sourceRoot: string, npmDeps: string[]): Promise<rollup.RollupOptions | rollup.RollupOptions[]>;
15
15
  export default rollupExecutor;
@@ -73,12 +73,15 @@ async function* rollupExecutor(rawOptions, context) {
73
73
  (0, fs_1.deleteOutputDir)(context.root, options.outputPath);
74
74
  }
75
75
  const start = process.hrtime.bigint();
76
- const bundle = await rollup.rollup(rollupOptions);
77
- const output = Array.isArray(rollupOptions.output)
78
- ? rollupOptions.output
79
- : [rollupOptions.output];
80
- for (const o of output) {
81
- await bundle.write(o);
76
+ const allRollupOptions = Array.isArray(rollupOptions)
77
+ ? rollupOptions
78
+ : [rollupOptions];
79
+ for (const opts of allRollupOptions) {
80
+ const bundle = await rollup.rollup(opts);
81
+ const output = Array.isArray(opts.output) ? opts.output : [opts.output];
82
+ for (const o of output) {
83
+ await bundle.write(o);
84
+ }
82
85
  }
83
86
  const end = process.hrtime.bigint();
84
87
  const duration = `${(Number(end - start) / 1_000_000_000).toFixed(2)}s`;
@@ -86,7 +89,8 @@ async function* rollupExecutor(rawOptions, context) {
86
89
  devkit_1.logger.info(`⚡ Done in ${duration}`);
87
90
  return { success: true, outfile };
88
91
  }
89
- catch {
92
+ catch (e) {
93
+ devkit_1.logger.error(e);
90
94
  devkit_1.logger.error(`Bundle failed: ${context.projectName}`);
91
95
  return { success: false };
92
96
  }
@@ -3,26 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rollupInitGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../../utils/versions");
6
- const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
6
+ const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
7
7
  const plugin_1 = require("../../plugins/plugin");
8
- function addPlugin(tree) {
9
- const nxJson = (0, devkit_1.readNxJson)(tree);
10
- nxJson.plugins ??= [];
11
- for (const plugin of nxJson.plugins) {
12
- if (typeof plugin === 'string'
13
- ? plugin === '@nx/rollup/plugin'
14
- : plugin.plugin === '@nx/rollup/plugin') {
15
- return;
16
- }
17
- }
18
- nxJson.plugins.push({
19
- plugin: '@nx/rollup/plugin',
20
- options: {
21
- buildTargetName: 'build',
22
- },
23
- });
24
- (0, devkit_1.updateNxJson)(tree, nxJson);
25
- }
26
8
  async function rollupInitGenerator(tree, schema) {
27
9
  let task = () => { };
28
10
  if (!schema.skipPackageJson) {
@@ -30,10 +12,9 @@ async function rollupInitGenerator(tree, schema) {
30
12
  }
31
13
  schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
32
14
  if (schema.addPlugin) {
33
- addPlugin(tree);
34
- }
35
- if (schema.updatePackageScripts) {
36
- await (0, update_package_scripts_1.updatePackageScripts)(tree, plugin_1.createNodes);
15
+ await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rollup/plugin', plugin_1.createNodes, {
16
+ buildTargetName: ['build', 'rollup:build', 'rollup-build'],
17
+ }, schema.updatePackageScripts);
37
18
  }
38
19
  if (!schema.skipFormat) {
39
20
  await (0, devkit_1.formatFiles)(tree);