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

Detail out how to generate meta file #29

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Analyzes each PR's impact on esbuild bundle size

## Usage

### Basic
### GitHub Action setup

```yaml
permissions:
Expand Down Expand Up @@ -36,8 +36,22 @@ jobs:
metafiles: "out/meta.json"
```
As of esbuild v0.20.0, you need to [write
***meta file*** yourself after build](https://esbuild.github.io/api/#metafile), something like this:
### esbuild setup
You need to [write ***meta file*** yourself after build](https://esbuild.github.io/api/#metafile).
If you use esbuild CLI, your build script in package.json should have `--metafile=out/meta.json` or such, something like this:

```json5
{
"scripts": {
"build": "esbuild ./src/lambda.ts --bundle --metafile=out/meta.json ......."
},
// ...
}
```

If you use esbuild API, something like this:

```javascript
// esbuild.mjs
Expand All @@ -54,9 +68,9 @@ let result = await esbuild.build({
fs.writeFileSync('dist/meta.json', JSON.stringify(result.metafile))
```

In this case, the `metafiles` input should be `"dist/meta.json"`.
For both cases, the `metafiles` input for GitHub Action will be `"dist/meta.json"`.

If you have multiple meta files, you can specify them like this `"dist/meta1.json,dist/meta2.json"`.
If you have multiple meta files, you can specify them like this `"dist/meta1.json,dist/meta2.json"` or `"dist/meta*.json`.

## Permissions

Expand Down