-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Using @vue/devtools
, splitVendorChunkPlugin
, and having stream
transitively installed causes Vite to output import "emitter"
to the bundle
#11888
Comments
Workaround
/** eslint-env node */
import { defineConfig, splitVendorChunkPlugin } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "node:path";
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
stream: resolve(__dirname, "./node_modules/stream/index.js"),
},
},
plugins: [vue(), splitVendorChunkPlugin()],
}); |
This seems to be fixed in vite@4.3.0-beta.5: https://stackblitz.com/edit/vitejs-vite-6wetst |
@patak-dev We are still getting a lot of warnings due to trying to build the Node version in the browser build though. Something is still wrong, it should try to build the browser build and strip it out due to tree-shaking, not build the Node build and strip it out... |
@segevfiner |
Maybe that's the bit that should be changed though. @vue/devtools itself might be better off using package.json exports instead of runtime detection? |
I think so. |
Should I open an issue on @vue/devtools? |
Yes, that would be nice. |
Describe the bug
Vite includes
import "emitter"
in the outputted bundle when you have conditional usage of@vue/devtools
(That should be tree shaken out),splitVendorChunkPlugin
and the modulestream
installed transitively.Vite apparently includes chooses to include the node version of
@vue/devtools
in the bundle instead of the browser version. This then includes arequire
to thestream
module, which due to installingpino-datadog
resolved to the npmstream
module, which includes animport "emitter"
which gets included into the final bundle.It doesn't get included without
splitVendorChunkPlugin
. Or some other usages ofmanualChunks
that I wasn't able to pinpoint.Reproduction
https://stackblitz.com/edit/vitejs-vite-u6bnd2?file=src/main.ts
Steps to reproduce
npm run build
in the reproduction.import "emitter"
which will fail at runtime.System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: