You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When importing a package in SSR that would've error-ed in node too, Vite swallows the node error, and shims the module as undefined instead, causing hard-to-debug Cannot read properties of undefined errors.
It would be good to surface the errors directly. It seems to be swallowed at
Run node test.js. See main.js to see the file that gets loaded with comments of why it's erroring.
System Info
stackblitz
Used Package Manager
pnpm
Logs
Click to expand!
Error: Cannot read properties of undefined (reading 'default')
at eval (/src/main.js:7:35)
at async ESMLoader.import (https://bluwycreateviteextra56u3yb-mer3.w-credentialless.staticblitz.com/blitz.50571018ddcbc3a25df8994336c28d766f1073a1.js:6:1209137)
at async i.loadESM (https://bluwycreateviteextra56u3yb-mer3.w-credentialless.staticblitz.com/blitz.50571018ddcbc3a25df8994336c28d766f1073a1.js:6:246622)
at async handleMainPromise (https://bluwycreateviteextra56u3yb-mer3.w-credentialless.staticblitz.com/blitz.50571018ddcbc3a25df8994336c28d766f1073a1.js:6:989144)
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Update: I realized now why the local package repro had a better error message. Because the types.js file doesn't exist, Vite was able to provide a better error message. But for astro-integration-lottie, types.js exist and Vite can resolve it, so no error message.
Describe the bug
When importing a package in SSR that would've error-ed in node too, Vite swallows the node error, and shims the module as
undefined
instead, causing hard-to-debugCannot read properties of undefined
errors.It would be good to surface the errors directly. It seems to be swallowed at
vite/packages/vite/src/node/ssr/ssrModuleLoader.ts
Line 260 in ce18eba
(Discovered through withastro/astro#6403)
Reproduction
https://stackblitz.com/edit/bluwy-create-vite-extra-56u3yb?file=src%2Fmain.js,test.js
Steps to reproduce
Run
node test.js
. Seemain.js
to see the file that gets loaded with comments of why it's erroring.System Info
Used Package Manager
pnpm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: