-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
Describe the bug
Vite has some resolver plugins that cause it to "externalize" some dependencies by name. Instead of giving an error at bundle/build time, the dependency is just dropped from the dependency graph.
vite/packages/vite/src/node/plugins/resolve.ts
Lines 239 to 241 in 88ded7f
// node built-ins. | |
// externalize if building for SSR, otherwise redirect to empty module | |
if (isBuiltin(id)) { |
This leaves you to get runtime errors when things run in the browser.
If Vite had errors (or even warnings) about this, the user could look for other libraries or polyfills to resolve the issue.
Reproduction
System Info
n/a.
Used Package Manager
npm
Logs
When running npm run build && npm run preview
:
Uncaught TypeError: Cannot read properties of undefined (reading 'from')
at vendor.93cea733.js:1:1014
at vendor.93cea733.js:1:1703
When running npm run dev
:
[vite] connecting...
index.js:12 Uncaught TypeError: Cannot read properties of undefined (reading 'from')
at node_modules/safe-buffer/index.js (index.js:12:12)
at __require (bs58check.js?v=f7e2e0ea:10:50)
at node_modules/hash-base/index.js (index.js:2:14)
at __require (bs58check.js?v=f7e2e0ea:10:50)
at node_modules/md5.js/index.js (index.js:3:16)
at __require (bs58check.js?v=f7e2e0ea:10:50)
at node_modules/create-hash/browser.js (browser.js:3:11)
at __require (bs58check.js?v=f7e2e0ea:10:50)
at node_modules/bs58check/index.js (index.js:3:18)
at __require (bs58check.js?v=f7e2e0ea:10:50)
client.ts:58 [vite] connected.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- 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 https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.