-
-
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
SSR import in development can't resolve default import #5706
Labels
Milestone
Comments
patak-dev
added
p3-downstream-blocker
Blocking the downstream ecosystem to work properly (priority)
and removed
pending triage
labels
Nov 19, 2021
@cyco130 How about this? let defaultExport = mod;
const visited = new WeakMap()
while ("default" in defaultExport && defaultExport.__esModule) {
if (visited.has(defaultExport)) {
break
}
visited.set(defaultExport, true);
defaultExport = defaultExport.default;
} |
@brillout Much better. I did run into a pathological module that broke mine today. |
brillout
added a commit
to brillout/vite
that referenced
this issue
Dec 1, 2021
9 tasks
brillout
added a commit
to brillout/vite
that referenced
this issue
Dec 2, 2021
brillout
added a commit
to brillout/vite
that referenced
this issue
Dec 2, 2021
brillout
added a commit
to brillout/vite
that referenced
this issue
Dec 2, 2021
patak-dev
pushed a commit
that referenced
this issue
Dec 2, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Describe the bug
For some packages, when one does
import whatever from "whatever"
, the default export ends up inwhatever.default
instead ofwhatever
as expected. This only happens in 2.7.0 beta (2.6 is fine), in development mode of SSR. Everything works in the production build and in development in the browser.Reproduction
This repo illustrates the issue with
styled-components
: https://github.com/cyco130/vite-issue-ssr-default-importnpm install
npm run dev
The problem is caused by
src/App.jsx
wherestyled-component
doesn't work in dev SSR mode when correctly imported but it does work when one accessesimported.default
.The issue appears to be caused by the
proxyESM
function inssrModuleLoader.ts
not following thexxx.default
chain as many times asstyle-component
's build system expects. The following change seems to solve the issue but might be too heavy-handed:System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: