Skip to content

Conversation

@timfish
Copy link
Collaborator

@timfish timfish commented Jan 29, 2026

I had this stashed and thought I may as well open a PR so this code doesn't die on my laptop!

Should we do this?

Personally I think we should migrate away from unplugin because:

  • We don't really use Unplugin as it was intended anyway and already have custom code per bundler
  • We only need three bundler plugin "formats" to support all bundlers. Rollup, webpack and esbuild
  • We are limited by Unplugins decisions over Node/bundler version support. v3 drops cjs/Node v18/webpack v4 (feat!: drop node 18 support, drop CJS build unjs/unplugin#558)

This PR drops using Unplugin for Rollup and instead just exports a single Rollup plugin that handles everything. For Vite we can just re-export the Rollup plugin with an additional wrapper.

Downsides?

If we add support for hook filters (#749), we would actually want the transforms to be contained in their own plugins because they would each need different regex filters for the best performance.

@github-actions
Copy link

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (telemetry) Add bundler-major-version tag to webpack by chargome in #857

Other

  • PoC: Rollup Plugin without Unplugin by timfish in #858

🤖 This preview updates automatically when you update the PR.


const ms = new MagicString(code, { filename: chunk.fileName });

const match = code.match(COMMENT_USE_STRICT_REGEX)?.[0];

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings starting with '//' and with many repetitions of '*///'.
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