GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Switch to `esbuild` for bundling by Andarist · Pull Request #479 · changesets/action

Conversation

@Andarist

@Andarist Andarist commented May 11, 2025

Copy link
Copy Markdown
Member

No description provided.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Andarist
Andarist requested a review from s0 May 11, 2025 07:42
@changeset-bot

changeset-bot Bot commented May 11, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 54cdcaf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@changesets/action Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Andarist
Andarist force-pushed the tsc-on-ci branch from 9975d15 to 696b158 Compare May 11, 2025 09:01
Base automatically changed from tsc-on-ci to main May 11, 2025 09:01
Andarist added 2 commits May 11, 2025 11:02
@Andarist
Switch to esbuild for bundling
2d6682c
@Andarist
add changeset
54cdcaf
@Andarist
Andarist force-pushed the use-esbuild branch from ac8f88e to 54cdcaf Compare May 11, 2025 09:02
s0
s0 approved these changes May 11, 2025
View reviewed changes
@Andarist
Andarist merged commit cf373e4 into main May 11, 2025
@Andarist
Andarist deleted the use-esbuild branch May 11, 2025 18:55
@github-actions github-actions Bot mentioned this pull request May 11, 2025
Version Packages #480
Merged
Andarist
Andarist commented May 11, 2025
View reviewed changes
Comment thread package.json
},
"scripts": {
"build": "ncc build src/index.ts -o dist --transpile-only --minify",
"build": "esbuild src/index.ts --bundle --platform=node --target=node20 --minify --outfile=dist/index.js",

@Andarist Andarist May 11, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to use Vite but I couldn't quickly figure out the correct set of options to bundle a node script alone, without index.html etc. cc @bluwy - you might know how to do that ;p

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bluwy bluwy May 12, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best to use esbuild directly. Personally Vite isn't the best or most flexible when bundling libraries.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Andarist Andarist May 12, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This here is not quite a library - it's an executable script. I was hoping to get better tree-shaking from Vite than from esbuild

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bluwy bluwy May 12, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has the same-ish issue with setting up bundling that too. I think esbuild is pretty good for this and treeshaking, but you could use rollup to match with vite's. Vite doesn't add anything on top of rollup that improves its treeshaking though.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Andarist Andarist May 16, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I have just wanted to use Vite as a pre-configured Rollup in this case. FWIW, I ran an experiment with raw Rollup now and for gzip -c dist/index.js | wc -c I got 377840 -> 366375 improvement. That sits at 3% and given I had to put together multiple plugins manually... I think it's not quite worth it 📦

Config for reference:

import { defineConfig } from "rollup";
import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
import json from "@rollup/plugin-json";
import { transform } from "esbuild";

export default defineConfig({
  input: "src/index.ts",
  output: {
    dir: "dist",
    format: "esm",
  },
  plugins: [
    nodeResolve({
      preferBuiltins: false,
    }),
    json(),
    commonjs(),
    {
      name: "esbuild",
      async transform(code, id) {
        if (!/\.(mts|cts|ts|tsx)$/.test(id)) {
          return null;
        }
        const result = await transform(code, {
          loader: "ts",
        });
        return result.code;
      },
    },
    terser(),
  ],
});

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bluwy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@Andarist Andarist May 16, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I might have to roll with the above if I want to test out ESM output. esbuild's ESM output doesn't quite work - from what I can tell... it doesn't even quite output ESM in my case, despite --format=esm 🤷

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Andarist Andarist May 16, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I got further with Vite but it just ignores both external and minify in this config. I don't know why

import { defineConfig } from "vite";

export default defineConfig({
  build: {
    ssr: true,
    lib: {
      entry: ["src/index.ts"],
      formats: ["es"],
    },
    minify: "terser",
    rollupOptions: {
      external: (id) => id.startsWith("node:"),
    },
  },
});

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced May 15, 2025
Version Packages fehnomenal/changesets-action#2
Merged
Version Packages fehnomenal/changesets-action#4
Merged
valpinkman pushed a commit to LedgerHQ/changeset-action-ledger that referenced this pull request Aug 4, 2025
Valentin D. Pinkman
Merge remote-tracking branch 'upstream/main' into chore/merge-changes
3a72bc5
* upstream/main: (28 commits)
  Version Packages (changesets#480)
  Fixed missed `__dirname` reference (changesets#496)
  Switch to bundling with Rollup (changesets#495)
  Migrate to ESM (changesets#484)
  Fixed situations in which `cwd` was specified as a relative path and used with (default) `commitMode: git-cli` (changesets#486)
  Add LICENSE file (changesets#491)
  Fix PRs sometimes not getting reopened with `commitMode: github-api` (changesets#488)
  Removed `fs-extra` dependency (changesets#481)
  Setup Git user in `release-pr` workflow (changesets#493)
  Use proper ndoe version in `release-pr` workflow (changesets#492)
  Add `release-pr` workflow (changesets#490)
  Migrate to Vitest (changesets#483)
  Switch to `esbuild` for bundling (changesets#479)
  Import only for `semver/functions/lt` (changesets#482)
  Avoid hitting a deprecation warning when encountering errors from `@octokit/request-error` (changesets#461)
  Run typecheck on CI (changesets#478)
  Updated `@actions/*` and `@octokit/*` dependencies (changesets#477)
  Bump @babel/runtime from 7.21.5 to 7.27.1 (changesets#464)
  Version Packages (changesets#476)
  Make git add work consistently with subdirectories (changesets#473)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bluwy bluwy bluwy left review comments
+1 more reviewer
@s0 s0 s0 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Andarist @s0 @bluwy
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.