Replies: 13 comments 56 replies
-
It would be nice to add feature to disable internal transpilation of config file and let user to run through deno/node+swc/bun |
Beta Was this translation helpful? Give feedback.
-
Nx will not work with ESM, as we publish as CJS. In order to support this change we'd have to:
There is no plan for us to move Nx to ESM at this point since there is no benefit IMO. |
Beta Was this translation helpful? Give feedback.
-
My thoughts:
Overall, I think the biggest problem with this proposal is that the incentives (for users) do not justify the migration cost / negative impact of the change, at least for now. Or, we need to consider a more gentle approach of how to get there. |
Beta Was this translation helpful? Give feedback.
-
For the frameworks above, SolidStart is not ready and Playwright should be added to the list as also not ready. |
Beta Was this translation helpful? Give feedback.
-
How does that work if you use a TypeScript-based vite config like |
Beta Was this translation helpful? Give feedback.
-
I am using vite on a nest project i was able to fully migrate a jest monorepo and we are very happy with vitest, we started getting this warning and i wanna be ready for when things might stop working as all the code we have is still in cjs. when you mean change to mts do you mean only the test files? the config file too and setup and environment files? or do you mean the whole project needs to be in esm? is there a way to run the esm build of vitest but the main project stays on cjs? |
Beta Was this translation helpful? Give feedback.
-
I created new project with vite + REACT+ Typescript SWC
How do I handle it? |
Beta Was this translation helpful? Give feedback.
-
I'm currently having the same warning from the terminal "The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details." |
Beta Was this translation helpful? Give feedback.
-
Hello, giving my opinion here: We integrated Vite a couple of years ago into a practically legacy project since it has been in operation for almost 8 years, and everything is fine, but we have many boot files and just thinking about having to change the boot chain to an asynchronous mode gives me a headache ; because of course, changing all the requirements of a project to imports is unthinkable... By the way, our project is in a private repository and I think many people will be the same, it cannot be assumed that CJS is not used because the search on Github does not gives you results or because the shiny new frameworks don't use CJS. So I think I'll stay on Vite 5 for a while (with this lovely warning), until we create a new project from scratch using ESM. I understand your reasons for wanting to make ESM mandatory but I also think that backwards compatibility is important. |
Beta Was this translation helpful? Give feedback.
-
Can't you just leave us alone and let us work without infinite mostly useless changes. ESM way of importing modules in Node doesn't work with all modules, EJS way has to be used instead. This JS environment has becoming a nightmare, not because jS is not good (it is) but because those entitled to constantly reinvent the wheel without proper reason. |
Beta Was this translation helpful? Give feedback.
-
Note that the Related: aleclarson/vite-tsconfig-paths#140 |
Beta Was this translation helpful? Give feedback.
-
If I keep "type": "module" in package.json, I am not being able to work with Cypress. And removing that line yes but warning with this message appears: "The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details." Any idea to find a solution for this? Thanks |
Beta Was this translation helpful? Give feedback.
-
All product active |
Beta Was this translation helpful? Give feedback.
-
Idea
The
"vite"
package will only export ESM code:Nothing else regarding ESM and CJS is changed in this proposal. Only Vite's Node API as shown above. (Example change branch)
Motivation
Migration path
"type": "module"
topackage.json
.mjs
or.mts
extensionawait import('vite')
assert { type: 'json' }
orcreateRequire()
for reading any.json
files and define__dirname
in any files where it's usedvite-cjs
package that users can easily use in npm's"overrides"
field.Research
I've made a poll on Twitter and Mastodon to get a first-pass of what some Vite users think of this:
GitHub search of projects using
require("vite")
today: search linkSome reasons against this change collected:
import("vite")
to workaround this, CJS lacks top-level await, making this workaround tricky in cases.@playwright/experimental-ct-core
- done in chore: prefer import over require microsoft/playwright#24568.js
files without"type": "module"
). going to need those users to migrate to a valid setup, but we can do that as part of Vite 5 ([1.0] Drop CJS build and export types first laravel/vite-plugin#235)Feedback
Let us know what do you think of this change. It is still undecided if this will land in the next major version of Vite.
Beta Was this translation helpful? Give feedback.
All reactions