-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Use ESM for SSR builds #8150
Comments
Maybe #6812 would cover this too, but the PR is stale. |
I don't really see the point in dropping CJS support. Why not let people do what they want? |
We haven't decided to drop support for CJS in v3 yet. I think it isn't going to be possible at this point. Maybe there is an intermediate option where we keep it as deprecated with a note of intent that is going to be removed in 6 months or so, or it will be kept but not maintained. Only as a way to give people an easier migration path to Vite v3. |
Clear and concise description of the problem
Vite currently builds SSR code as CJS.
I think that is controlled here:
vite/packages/vite/rollup.config.js
Line 72 in 274c10e
Suggested solution
ESM is the future, so it would be nice to make it the default. SvelteKit, Astro, Nuxt, vite-plugin-ssr, Hydrogen, and Vitedge are all using ESM already, so it's possible we could stop supporting CJS altogether
Alternative
We could keep CJS around as an option for 3.0 and then drop it in 4.0. There are only a couple known issues and they're both being worked on. It's unclear if they'd be blockers
require()
calls of Node built-ins to import statements when emitting ESM for Node evanw/esbuild#2067)Additional context
This was originally suggested here: #8033 (comment)
Validations
The text was updated successfully, but these errors were encountered: