Skip to content

fix(vite-plugin): set rollupOptions.platform: "neutral" on rolldown-vite #9891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hi-ogawa
Copy link

@hi-ogawa hi-ogawa commented Jul 8, 2025

Fixes vitejs/rolldown-vite#248

The issue is reported on rolldown-vite repository vitejs/rolldown-vite#248. Rolldown has esbuild-like platform option to control the default behavior such as require polyfill. Rolldown-vite server build uses platform: "node" by default and it causes an issue with cloudflare plugin due to node:module appearing in resolveId, which gets externalized and not being tree-shaken (cf. #9609). By setting platform: "neutral", it avoids cloudflare plugin to see resolveId("node:module") and fixes the issue (though tree-shaking issue still exists when nodejs_compat is not enabled).

There's also new optimizeDeps.rollupOptions.platform, but rolldown-vite automatically copies it from optimizeDeps.esbuildOptions.platform, so it's not necessary to be changed yet.

I manually tested the local build with my reproduction.


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because:
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because:

Copy link

changeset-bot bot commented Jul 8, 2025

⚠️ No Changeset found

Latest commit: 6fbc5ec

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@hi-ogawa hi-ogawa marked this pull request as ready for review July 8, 2025 23:50
@hi-ogawa hi-ogawa requested review from a team as code owners July 8, 2025 23:50
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.

@cloudflare/vite-plugin without node compat breaks due to "node:module" imported from "rolldown:runtime"
1 participant