Skip to content
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

Bug: PassThrough is not exported by "__vite-browser-external" during build #88

Open
ii02735 opened this issue Apr 7, 2024 · 1 comment

Comments

@ii02735
Copy link

ii02735 commented Apr 7, 2024

Summary

In a project, I use the following dependency : https://www.npmjs.com/package/minify-xml

Because it is a dependency written for a pure NodeJS project, I had to use polyfills like this :

import { defineConfig } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";

export default defineConfig({
    plugins: [nodePolyfills({
        include: ['_stream_passthrough', 'util']
    })]
})

What I expect

Everything should work in dev mode, or when I build the project.

What I got

  • In dev mode, everything is working ✅
  • When I try to build the project, it fails 💥

I have the following error :

image

My setup

  • Vite v5.
  • Windows 11
  • NodeJS v20.9.0

You can find a minimal reproductible example there : https://github.com/ii02735/vite-minify-xml-bug-build

@jsudung
Copy link

jsudung commented May 31, 2024

Passthrough is imported from stream. So have you tried importing stream instead of _stream_passthrough?

Also try setting protocolImports: true, since it is importing Passthrough from node: protocol import.

I encountered the same issue and this fixed it for me.

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

No branches or pull requests

2 participants