GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||
GeezerVison is showing github.com — Switch to `esbuild` for bundling by Andarist · Pull Request #479 · changesets/action Conversation
|
There was an error while loading. Please reload this page.
🦋 Changeset detectedLatest commit: 54cdcaf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| }, | ||
| "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", |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
* 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) ...
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.