From 403371baab3eacccdee46eba8e7c415e68a43931 Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 2 May 2024 11:40:00 +0900 Subject: [PATCH 1/2] Dog fooding --- .github/workflows/ci.yml | 4 ++++ .gitignore | 1 + esbuild.mjs | 6 ++++-- tmp/.gitkeep | 0 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 tmp/.gitkeep diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9da72bc..df8e436 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,10 @@ jobs: else echo 'clean' fi + - name: Analyze esbuild bundle size + uses: exoego/esbuild-bundle-analyzer@main + with: + metafiles: "tmp/meta.json" - uses: actions/upload-artifact@v4 with: name: dist diff --git a/.gitignore b/.gitignore index a162f73..e16cd14 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules out .analyzer +tmp/meta.json # Allow-list !__tests__/__fixtures__/examples-with-base/**/.analyzer/base/bundle/bundle_analysis.json diff --git a/esbuild.mjs b/esbuild.mjs index cfa019c..4eced02 100644 --- a/esbuild.mjs +++ b/esbuild.mjs @@ -1,5 +1,5 @@ import * as esbuild from 'esbuild' -import { readFileSync } from 'node:fs' +import { readFileSync, writeFileSync } from 'node:fs' // https://github.com/evanw/esbuild/issues/1685#issuecomment-944916409 const excludeNodeModulesFromSourceMap = { @@ -18,7 +18,7 @@ const excludeNodeModulesFromSourceMap = { }, }; -await esbuild.build({ +const result = await esbuild.build({ entryPoints: [`./src/index.ts`], outfile: `dist/index.mjs`, format: 'esm', @@ -30,3 +30,5 @@ await esbuild.build({ bundle: true, plugins: [excludeNodeModulesFromSourceMap] }) + +writeFileSync(`tmp/meta.json`, JSON.stringify(result.metafile, null, 2)); diff --git a/tmp/.gitkeep b/tmp/.gitkeep new file mode 100644 index 0000000..e69de29 From e60f14517a9b0f952403817a90c1d8c69b5fdb81 Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 2 May 2024 11:42:18 +0900 Subject: [PATCH 2/2] Dog fooding --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df8e436..073f7ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,11 @@ on: paths-ignore: - '*.md' +permissions: + contents: read # for checkout repository + actions: read # for fetching base branch bundle stats + pull-requests: write # for comments + jobs: build: runs-on: ubuntu-latest