Skip to content

Commit

Permalink
Merge pull request #8 from twk3/initial-changes
Browse files Browse the repository at this point in the history
Initial changes to switch this over to Rollup
  • Loading branch information
twk3 committed Dec 26, 2023
2 parents 760f9a6 + 79f7ce0 commit 5d3e409
Show file tree
Hide file tree
Showing 27 changed files with 195,180 additions and 12,105 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ jobs:
- uses: actions/checkout@v4
- uses: ./
with:
current-stats-json-path: ./__tests__/__mocks__/new-stats-with-chunks.json
base-stats-json-path: ./__tests__/__mocks__/old-stats-with-chunks.json
current-stats-json-path: ./__tests__/__mocks__/new-stats-rollup.json
base-stats-json-path: ./__tests__/__mocks__/old-stats-rollup.json
github-token: ${{ secrets.GITHUB_TOKEN }}
title: With chunk and module information
- uses: actions/checkout@v4
- uses: ./
with:
current-stats-json-path: ./__tests__/__mocks__/new-stats-assets.json
base-stats-json-path: ./__tests__/__mocks__/old-stats-assets.json
current-stats-json-path: ./__tests__/__mocks__/new-stats-rollup-sample.json
base-stats-json-path: ./__tests__/__mocks__/old-stats-rollup-sample.json
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./
with:
current-stats-json-path: ./__tests__/__mocks__/old-stats-assets.json
base-stats-json-path: ./__tests__/__mocks__/new-stats-assets.json
current-stats-json-path: ./__tests__/__mocks__/old-stats-rollup-sample.json
base-stats-json-path: ./__tests__/__mocks__/new-stats-rollup-sample.json
github-token: ${{ secrets.GITHUB_TOKEN }}
title: Flipped around
- uses: ./
Expand All @@ -50,7 +50,7 @@ jobs:
title: Non existent
- uses: ./
with:
current-stats-json-path: ./__tests__/__mocks__/old-stats-assets.json
base-stats-json-path: ./__tests__/__mocks__/old-stats-assets.json
current-stats-json-path: ./__tests__/__mocks__/old-stats-rollup-sample.json
base-stats-json-path: ./__tests__/__mocks__/old-stats-rollup-sample.json
github-token: ${{ secrets.GITHUB_TOKEN }}
title: No changes
1 change: 0 additions & 1 deletion CODEOWNERS

This file was deleted.

40 changes: 16 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
# Webpack bundlesize compare action
# Rollup size compare action

An action that compares 2 webpack compilation stats files, and comments on the PR with a description of the difference
An action that compares 2 Rollup compilation stats files, and comments on the PR with a description of the difference.

This is fork of the excellent [WebPack BundleSize Compare](https://github.com/github/webpack-bundlesize-compare-action) that adapts the name-to-size map to work for the raw output provided by [Rollup Plugin Visualizer](https://github.com/btd/rollup-plugin-visualizer).

## How to use it

In your application, ensure you output the stats.json, from `BundleAnalyzerPlugin'
In your application, ensure you output the stats.json, from `Rollup Plugin Visualizer'

```js
// webpack.config.js
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer')

// optionally you can also output compressed/gzipped stats. Requires a version >=1.1.0
const CompressionPlugin = require('compression-webpack-plugin')
// rollup.config.js
// es
import { visualizer } from "rollup-plugin-visualizer";
// or
// cjs
const { visualizer } = require("rollup-plugin-visualizer");

module.exports = {
plugins: [
...plugins,
// not required
new CompressionPlugin(),

// required
new BundleAnalyzerPlugin({
// generate the stats.json file
generateStatsFile: true
})
]
}
// template must be 'raw-data' for the stats.json file to be created
visualizer({ template: 'raw-data' }),
],
};
```

Then, in your action configuration, build both the head and the branch (in any way you see fit) and pass paths to the stats.json files as inputs ot this action
Expand Down Expand Up @@ -92,7 +88,7 @@ jobs:
pull-requests: write
steps:
- uses: actions/download-artifact@v3
- uses: github/webpack-bundlesize-compare-action@v1.8.2
- uses: twk3/rollup-size-compare-action@v1.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
current-stats-json-path: ./head-stats/stats.json
Expand All @@ -109,7 +105,3 @@ This action requires the `write` permission for the [`permissions.pull-requests`
| base-stats-json-path | The path to the base stats.json file | true | string |
| github-token | The Github token | true | string |
| title | An optional addition to the title, which also helps key comments, useful if running more than 1 copy of this action | false | string |

## Example PR Comment

https://github.com/github/webpack-bundlesize-compare-action/pull/50#issuecomment-1054919780
9 changes: 0 additions & 9 deletions __tests__/__mocks__/new-hidden-stats-assets.json

This file was deleted.

90 changes: 0 additions & 90 deletions __tests__/__mocks__/new-stats-assets.json

This file was deleted.

Loading

0 comments on commit 5d3e409

Please sign in to comment.