Skip to content

build: ship a smaller package - #248

Merged
baseballyama merged 1 commit into
mainfrom
refine/plugin-tarball
Nov 20, 2026
Merged

baseballyama merged 1 commit into
mainfrom
refine/plugin-tarball

Conversation

@baseballyama

Copy link
Copy Markdown
Member

Stacked on #247.

Shrinks the published package from 375,434 B packed / 1,146,444 B unpacked (126 files) to 242,218 B packed / 718,843 B unpacked (86 files).

  • No source maps in dist (they were 396 KB and nothing reads them by default).
  • Only the 4 public .d.ts files ship (index, plugin, inspector, types). The other 36 were unreachable through exports.
  • The injected browser runtime is minified at build time, whitespace and comments only (no mangling): client.js 66,607 B -> 36,270 B (18,809 -> 10,330 gzip), wrapper.js 10,935 B -> 6,047 B (3,288 -> 1,679 gzip). This is what the dev server sends to every page.
  • The plugin's own Node code is no longer minified. Without source maps, this keeps its stack traces readable. It costs about 53 KB unpacked compared with mangled output.
  • Removed the bare builtin externals that nothing imports, and set the build target to node22 to match engines.

Behavior changes: the served runtime text is now minified instead of a verbatim copy of the source. The unit and reactivity test projects now run on the minified text through the same build/minify-runtime.ts (restart-data.test.ts still loads the plugin through its own Vite server and gets the unminified text). The build-time loader registers the runtime files as watch files, so pnpm dev (vite build --watch) still rebuilds when they change. A new test checks that the minified wrapper keeps every export name, and runtime-parent.test.ts now strips module syntax using the AST instead of line by line.

Copilot AI balanced review requested due to automatic review settings November 20, 2026 13:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Base automatically changed from refine/runtime-perf to main November 20, 2026 21:08
@baseballyama
baseballyama force-pushed the refine/plugin-tarball branch 2 times, most recently from a94ca98 to f1a910a Compare November 20, 2026 21:27
Drop source maps and internal .d.ts files from dist, minify the injected browser runtime (whitespace and comments only), and stop minifying the plugin's own code so stack traces stay readable. Tests now run the minified runtime text.
@baseballyama
baseballyama merged commit 1661a85 into main Nov 20, 2026
10 checks passed
@baseballyama
baseballyama deleted the refine/plugin-tarball branch November 20, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants