Skip to content

Conversation

@sapphi-red
Copy link
Contributor

rolldown-vite 7.2.3 has a breaking change (https://github.com/rolldown/rolldown/releases/tag/v1.0.0-beta.48) and this PR changes the code for it.
This PR also changes the deprecated optimizeDeps.rollupOptions to optimizeDeps.rolldownOptions.

The new options are only supported by rolldown-vite 7.1.19+, so users using the older version would have to upgrade rolldown-vite together.

@shahmir-oscilar
Copy link

shahmir-oscilar commented Dec 11, 2025

@davidmyersdev Could you take a look at this PR?

@sapphi-red It might be worth updating this PR to target vite 8 beta instead?

I'm currently using vite 8 beta, and things seem to work okay with this plugin, but I am getting the following warning:

3:43:52 PM [vite] warning: `esbuild` option was specified by "vite-plugin-node-polyfills" plugin. This option is deprecated, please use `oxc` instead.
`optimizeDeps.rollupOptions` / `ssr.optimizeDeps.rollupOptions` is deprecated. Use `optimizeDeps.rolldownOptions` instead. Note that this option may be set by a plugin. Set VITE_DEPRECATION_TRACE=1 to see where it is called.
Both esbuild and oxc options were set. oxc options will be used and esbuild options will be ignored. The following esbuild options were set: `{
  banner: "import __buffer_polyfill from 'vite-plugin-node-polyfills/shims/buffer'\n" +
    'globalThis.Buffer = globalThis.Buffer || __buffer_polyfill\n' +
    "import __global_polyfill from 'vite-plugin-node-polyfills/shims/global'\n" +
    'globalThis.global = globalThis.global || __global_polyfill\n' +
    "import __process_polyfill from 'vite-plugin-node-polyfills/shims/process'\n" +
    'globalThis.process = globalThis.process || __process_polyfill\n'
}`

I believe that's because

is always there

I think instead it should probably be:

        ...(isRolldownVite
          ? {}
          : {
              esbuild: {
                // In dev, the global polyfills need to be injected as a banner in order for isolated scripts (such as Vue SFCs) to have access to them.
                banner: isDev ? globalShimsBanner : undefined,
              },
            }),

since you already did the code to do the banner via a plugin for rolldown, right?

I was going to submit a PR myself for this and the transform change, but saw that you have the transform change in this PR already

see: main...shahmir-oscilar:vite-plugin-node-polyfills:main

for reference

@mtmacdonald
Copy link

This would be very helpful for unblocking my team! 🤝

@sapphi-red
Copy link
Contributor Author

I think instead it should probably be:

        ...(isRolldownVite
          ? {}
          : {
              esbuild: {
                // In dev, the global polyfills need to be injected as a banner in order for isolated scripts (such as Vue SFCs) to have access to them.
                banner: isDev ? globalShimsBanner : undefined,
              },
            }),

since you already did the code to do the banner via a plugin for rolldown, right?

To be honest, I'm not sure whether this esbuild.banner is needed, so I left it as-is. I didn't add any equivalent code for this, so I think we still need it (assuming that it is used somewhere).

@bfaulk96
Copy link

bfaulk96 commented Dec 30, 2025

To be honest, I'm not sure whether this esbuild.banner is needed, so I left it as-is. I didn't add any equivalent code for this, so I think we still need it (assuming that it is used somewhere).

According to the migration guide,
it sounds like Vite does some automatic conversion behind the scenes to support esbuild for backward-compatibility..
Specifically for banner in this case:

esbuild.banner -> custom plugin using transform hook

I wonder if this is some code that could easily be taken from the Vite repo and placed in here for handling the banner?

Also sorry @sapphi-red, perhaps my comment is ignorant, I'm somewhat just speculating. Thanks for all your hard work on Vite and related projects!

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.

4 participants