-
-
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
[esm] should not default to an explicit --conditions=development
on development
#4815
Comments
I think the problem arises because in Node production/development conditions have to be passed explicitly, resulting in three states in Node: default, development, and production. |
@JounQin @wooorm I've only noticed this issue now, I'll put this in the team board and discuss soon in the coming meetings. My two cents on this is that I don't think Vite should be removing the Another thing is that in the ESM world there's no |
Thanks! To rephrase and summarize: I am not advocating to remove this condition. I agree they are not Node-specific. I am advocating that, if Vite chooses development, it either a) has to do so because a user explicitly wants it, or b) it should expect instrumented development code to load (such as |
Vite has quite some defaults for
I think a bunch of code is fine, but Vite trips up with If Vite expects |
👍 on treating conditions as not necessarily Node-specific, but then I would recommend also trying to help maintain them. Currently they’re maintained at Node.js, and they want to share the responsibility. Perhaps Vite can help bring them to a non-Node-only place?
|
Do you mean officially document it somewhere like a spec? I think that's a good idea, though I'm probably not the person for it (yet) 😅
Vite currently shims an empty proxy module that warns about nodejs module usage for dev/prod, which likely brought up the issue in the first place. It might be as far as Vite can go at the moment to not be breaking packages. I just checked micromark and it looks like it's already using a browser-friendly assertion library though, which is great! Also I stumbled upon this discussion evanw/esbuild#1854, though I still think that it's nice Vite supports it by default as it's more than just a bundler. |
I mean being involved in nodejs/loaders#52 (or for example nodejs/node#40708, nodejs/node#40914). The reason I mention this, is that #4815 (comment) mentioned bringing this issue op to more Vite maintainers. As far as I’m aware, Node.js wants to maintain conditions together with the web (tooling) community. But the web (tooling) community is not helping (yet).
Vite currently throws errors/warnings for packages that use Node.js builtins in development. Vite could, instead of errors/warnings, solve those issues. As they were issues before, it should not break anyone, to fix already broken things?
Yeah, I mitigated this issue after a bunch of Vite users complained a lot. I would rather have it that I didn’t have to solve problems that only occur in Vite though 😉
Nice, thanks for linking it. Seems the folks there agree with me? (“Every condition requires that the package author opts into it (by defining it) and the consumer of said package declaring that they want to match the condition.”) This is exactly this issue with Vite. The dev/prod conditions are supposed to be opted-into by users. |
Sweet thanks for the links. I'll look into those.
Vite's philosophy especially with nodejs modules is that they shouldn't be handled/polyfilled by default. In most cases you don't want a polyfill in the final browser bundle as it incurs a huge payload. Webpack 5 had also took this stance, and I think having a distincition of browser/node is great too.
I think being "opt-in" has its place too for generic bundlers like rollup and esbuild, as they don't have a sense of dev and build differences (their focus is to only bundle). Vite, webpack, and WMR on the other hand aren't just bundlers, but they apply framework-ish opinions and provide sensible defaults for the end-user, so "opt-in" already turned on by default makes sense to me. |
Describe the bug
Some packages use
exports
like the following:development
entry is only intended to be used when usingnode --conditions=development example.js
, all other environment should use thedefault
entry instead.But for now,
vite
is using thedevelopment
entry onvite dev
Reproduction
remarkjs/react-markdown#632 (comment)
See also micromark/micromark#87
System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: