-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
ssr: resolve also .cjs
and .mjs
file extensions
#4452
Comments
Currently vite uses
According to nodejs' doc, It is not possible to require() files that have the .mjs extension. Attempting to do so will throw an error.So we can only include the .cjs file extension here.
|
I'm fine if |
Here I found a TODO note left by Evan You @ivanhofer vite/packages/vite/src/node/ssr/ssrExternal.ts Lines 11 to 14 in fb406ce
|
@ygj6 thanks for taking a deeper look 😊 |
Describe the bug
vite
does not resolve.cjs
extensions inssr
mode. I got it working by adding'.cjs'
tossrExtensions
insidesrc/node/utils.ts
.I'm not sure why the extension is missing. Maybe
vite
should also include the.mjs
file extension.The issue blocks users to add typesafe-i18n to their
vite
projects. That library exports only.cjs
and.mjs
files to support bothCommonJS
andESM
projects.Reproduction
https://github.com/ivanhofer/typesafe-i18n-vite-ssr
run
npm run dev
and go tohttp://localhost:3000
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: