Skip to content

feat(@formatjs/unplugin): universal build plugin for Vite, Webpack, Rollup, esbuild, Rspack#6096

Merged
longlho merged 1 commit intomainfrom
feat/unplugin
Mar 16, 2026
Merged

feat(@formatjs/unplugin): universal build plugin for Vite, Webpack, Rollup, esbuild, Rspack#6096
longlho merged 1 commit intomainfrom
feat/unplugin

Conversation

@longlho
Copy link
Member

@longlho longlho commented Mar 16, 2026

Summary

  • Create @formatjs/unplugin — a universal build plugin powered by unplugin that provides FormatJS AST transformations (ID generation, description removal, AST pre-parsing) across all major bundlers with a single codebase
  • @formatjs/vite-plugin becomes a thin 2-line re-export from @formatjs/unplugin/vite for backward compatibility — zero breaking changes for existing users
  • Full documentation with usage examples for Vite, Webpack, Rollup, esbuild, and Rspack

Closes UPCOMING.md item #1 (Vite Plugin Adoption: 689/week vs 276K for babel-plugin).

What changed

New: packages/unplugin/

  • transform.ts — core transform logic (moved from vite-plugin, 451 lines, unchanged)
  • index.tscreateUnplugin factory with transformInclude + transform hooks
  • vite.ts, webpack.ts, rollup.ts, esbuild.ts, rspack.ts — bundler entry points
  • package.json — exports for ., ./vite, ./webpack, ./rollup, ./esbuild, ./rspack, ./transform
  • 51 unit tests (47 transform + 4 factory)

Updated: packages/vite-plugin/

  • index.ts → 2-line re-export from @formatjs/unplugin/vite
  • transform.ts → deleted (moved to unplugin)
  • tests/ → deleted (moved to unplugin)
  • Integration tests stay and all 10 pass

Build system

  • tools/tsconfig.bzl — added ESNEXT_SKIP_LIB_CHECK_TSCONFIG (unplugin's types import from all bundlers)
  • tools/vitest.bzl — added skipLibCheck to test tsconfig for transitive type compatibility

Docs

  • New docs/src/docs/tooling/unplugin.mdx — full docs with all 5 bundler examples + migration guides
  • Updated vite-plugin.mdx — tip recommending unplugin for new projects
  • Updated bundler-plugins.mdx — added unplugin section with tabbed examples
  • Updated navigation tree

Test plan

  • bazel test //packages/unplugin:unit_test — 51 tests pass
  • bazel test //packages/unplugin:unit_test_typecheck_typecheck_test — type-check passes
  • bazel test //packages/vite-plugin/integration-tests:integration_test — 10 integration tests pass (backward compat)
  • bazel test //docs:docs_metadata_test — docs metadata up to date
  • pnpm t — 484/487 pass (3 pre-existing failures in react-intl/vue-intl sandbox resolution, confirmed on clean main)
  • All pre-commit hooks pass (format, lint, commitlint)

🤖 Generated with Claude Code

@longlho longlho force-pushed the feat/unplugin branch 2 times, most recently from 080dc04 to 1755e4d Compare March 16, 2026 01:26
…k, Rollup, esbuild, and Rspack

Implements a single unplugin-based package that provides FormatJS transform
support across all major bundlers. Includes integration tests that run real
builds with each bundler.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@longlho longlho enabled auto-merge (squash) March 16, 2026 01:33
@longlho longlho merged commit 371eadd into main Mar 16, 2026
5 checks passed
@longlho longlho deleted the feat/unplugin branch March 16, 2026 01:35
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.

1 participant