Open indeyets opened 1 year ago
Does it work in Vite 4.2? Using 4.2 and running your repro I get:
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/Users/bjorn/Work/repros/vite-3-date-fns/node_modules/date-fns/locale' is not supported resolving ES modules imported from /Users/bjorn/Work/repros/vite-3-date-fns/dist/server.js
Did you mean to import date-fns/node_modules/.pnpm/date-fns@2.29.3/node_modules/date-fns/locale/index.js?
@bluwy good point. it works in my complex app, but not here. I reproduced bad behaviour without reproducing good.
I'll see what I can do 🤔
but it looks like @btea figured out the problem anyway?
I wasn't sure if the PR was the right fix, and in any case we should fix to report the right error as before instead. But happy to look into it again if you manage to find out how it works before. FWIW I tried fiddling with ssr.external
and ssr.noExternal
in the repro but I can't repro that case where it works in 4.2 but not 4.3.
btea's PR makes the Vite4.3's resolve behavior the same as Vite4.2's, but it seems like there is another potential bug as bluwy said. Could you provide your complex app or maybe vite.config.js
? @indeyets
Hello,
I'm also working on a SSR application where the server is built using webpack. Since I've upgrade to 4.3 version I'm also getting that issue
Module not found: Error: Can't resolve 's' in '/Users/jean-bricerougeot/Documents/bulbshare-web-app-react/websites/my.bulbshare.com/dist/server/src/renderer'
@ ./dist/server/pageFiles.mjs
@ ./dist/server/importBuild.cjs 4:21-46
@ ../../node_modules/@brillout/vite-plugin-import-build/dist/autoImporter.js 2:34-110 8:37-121
@ ../../node_modules/@brillout/vite-plugin-import-build/dist/loadServerBuild/index.js 9:21-47
@ ../../node_modules/@brillout/vite-plugin-import-build/loadServerBuild.js 1:0-50
@ ../../node_modules/vite-plugin-ssr/dist/cjs/node/runtime/globalContext/loadImportBuild.js 4:26-87
@ ../../node_modules/vite-plugin-ssr/dist/cjs/node/runtime/globalContext.js 5:26-68
@ ../../node_modules/vite-plugin-ssr/dist/cjs/node/runtime/renderPage.js 10:24-50
I confirm it works correctly When I downgrade to 4.2.0
Could you provide a mini-repro? @jaybe78
@DMOAbove that looks like a different issue and an expected one. And I don't think v4.2.2 could be regressing it, but if you found it so, please create a new issue with the repro. Thanks!
An update for this issue. It was fixed at https://github.com/vitejs/vite/pull/13010 but the fix can be improved further based on the root cause, so it's left opened. Updating the labels for now.
Describe the bug
I'm importing locales from date-fns like this:
import { enGB, es, de } from "date-fns/locale";
in my code.It worked fine with vite 4.2.x, but both 4.3.0 and 4.3.1 replace the "from" part with
… from "s";
which server, once it runs, can not find, for obvious reasons.Reproduction
https://github.com/indeyets/vite-bug
Steps to reproduce
run
npm install
followed bynpm test
System Info
Used Package Manager
npm
Logs
No response
Validations