-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Exclude server endpoints from Vite's dependency optimization #9859
Labels
- P3: minor bug
An edge case that only affects very specific usage (priority)
Comments
In the future, I'd love to see a way to mark modules as server-only, like |
bluwy
added
- P3: minor bug
An edge case that only affects very specific usage (priority)
and removed
needs triage
Issue needs to be triaged
labels
Jan 29, 2024
Currently running into some issues using oslo with astro & cloudflare pages It only happens when i run pnpm build. [ERROR] Could not resolve "fs"
node_modules/.pnpm/@node-rs+argon2@1.7.0/node_modules/@node-rs/argon2/index.js:5:45:
5 │ const { existsSync, readFileSync } = require('fs')
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "path"
node_modules/.pnpm/@node-rs+argon2@1.7.0/node_modules/@node-rs/argon2/index.js:6:25:
6 │ const { join } = require('path')
╵ ~~~~~~
The package "path" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "fs"
node_modules/.pnpm/@node-rs+bcrypt@1.9.0/node_modules/@node-rs/bcrypt/binding.js:5:45:
5 │ const { existsSync, readFileSync } = require('fs')
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "path"
node_modules/.pnpm/@node-rs+bcrypt@1.9.0/node_modules/@node-rs/bcrypt/binding.js:6:25:
6 │ const { join } = require('path')
╵ ~~~~~~
The package "path" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] No loader is configured for ".node" files: node_modules/.pnpm/@node-rs+argon2-darwin-arm64@1.7.0/node_modules/@node-rs/argon2-darwin-arm64/argon2.darwin-arm64.node
node_modules/.pnpm/@node-rs+argon2@1.7.0/node_modules/@node-rs/argon2/index.js:173:36:
173 │ nativeBinding = require('@node-rs/argon2-darwin-arm64')
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] No loader is configured for ".node" files: node_modules/.pnpm/@node-rs+bcrypt-darwin-arm64@1.9.0/node_modules/@node-rs/bcrypt-darwin-arm64/bcrypt.darwin-arm64.node
node_modules/.pnpm/@node-rs+bcrypt@1.9.0/node_modules/@node-rs/bcrypt/binding.js:165:36:
165 │ nativeBinding = require('@node-rs/bcrypt-darwin-arm64')
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Could not resolve "fs"
Stack trace:
at failureErrorWithLog (/Users/julian/Desktop/DEVELOPMENT/projects/form/node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js:1651:15)
at runOnEndCallbacks (/Users/julian/Desktop/DEVELOPMENT/projects/form/node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js:1486:45)
at /Users/julian/Desktop/DEVELOPMENT/projects/form/node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js:1086:16
at handleIncomingPacket (/Users/julian/Desktop/DEVELOPMENT/projects/form/node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js:764:9)
at Socket.emit (node:events:518:28) i've already added oslo to my optimizeDeps exclude: vite: {
optimizeDeps: {
exclude: ["oslo", "@node-rs/argon2", "@node-rs/bcrypt"],
}
}, Do you know how to fix this? |
@pixelmund Open a new issue on Oslo's repo. FYI you can't use Oslo's password module in non-Node.js runtime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
With Astro's current configuration, Vite optimizes all dependencies imported in
src/**
. That causes issues when you import packages that use.node
files such as@node-rs/argon2
:We should probably exclude at least server endpoints, which we know won't be used in the client, from Vite's optimization. This should lead to better performance as well.
What's the expected result?
Server only modules won't be optimized.
Link to Minimal Reproducible Example
https://github.com/pilcrowOnPaper/astro-deps-optimization-repro
Participation
The text was updated successfully, but these errors were encountered: