Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for writing multiple reports at once #442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

leipert
Copy link

@leipert leipert commented May 5, 2021

We are adding support for a new option called reports which accepts an
array of reports:

new BundleAnalyzerPlugin({
  analyzerMode: "static",
  reports: [
    { type: "json", filename: "my-report.json" },
    { type: "html", filename: "my-report.html" },
  ],
});

Users of the analyzerMode in json should migrate from:

new BundleAnalyzerPlugin({
  analyzerMode: "json",
  reportFilename: "my-report.json",
});

to

new BundleAnalyzerPlugin({
  analyzerMode: "static",
  reports: [{ type: "json", filename: "my-report.json" }],
});

Users of the analyzerMode with html should migrate from:

new BundleAnalyzerPlugin({
  analyzerMode: "static",
  reportFileName: "my-report.html",
});

to

new BundleAnalyzerPlugin({
  analyzerMode: "static",
  reports: [{ type: "html", filename: "my-report.html" }],
});

In order to help with the migration, these config changes will pe
printed with a logger warning, while we internally being rewritten to
the new format so that this isn't a breaking change.

We are adding support for a new option called `reports` which accepts an
array of reports:

```json
new BundleAnalyzerPlugin({
  analyzerMode: "static",
  reports: [
    { type: "json", filename: "my-report.json" },
    { type: "html", filename: "my-report.html" },
  ],
});
```

Users of the `analyzerMode` in `json` should migrate from:

```js
new BundleAnalyzerPlugin({
  analyzerMode: "json",
  reportFilename: "my-report.json",
});
```

to

```js
new BundleAnalyzerPlugin({
  analyzerMode: "static",
  reports: [{ type: "json", filename: "my-report.json" }],
});
```

Users of the `analyzerMode` with `html` should migrate from:

```js
new BundleAnalyzerPlugin({
  analyzerMode: "static",
  reportFileName: "my-report.html",
});
```

to

```js
new BundleAnalyzerPlugin({
  analyzerMode: "static",
  reports: [{ type: "html", filename: "my-report.html" }],
});
```

In order to help with the migration, these config changes will pe
printed with a logger warning, while we internally being rewritten to
the new format so that this isn't a breaking change.
@leipert
Copy link
Author

leipert commented May 5, 2021

@valscion This is code only for now, if you are satisfied with the code changes, I will update the docs.

@valscion
Copy link
Member

valscion commented May 5, 2021

I don't know if this comment by @th0r applies here: #375 (comment)

I'll let @th0r communicate here if this direction is good or not.

Hmm yeah, I think adding support for analyzerMode possibly being an array would be reasonable.

Well, I think we can do that, but it will require a change to reportFilename option to be able to return different filenames for different report types e.g. allow to make it a function (reportType) => <reportFilename> (which won't work for CLI) or an object {<reportType>: <reportFilename>}. Anyway, options becomes a mess... We definitely need to ship a new major version with completely revised API with pluggable external reporters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants