-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
[Vite 3] CJS Bug #8880
Comments
This bug also happens with |
Is vikepress a CJS dependency? If that is the case, in SSR it needs to be optimized and then you can't use vite features in it. I think that the only way to have a CJS dependency that needs vite features is to set |
VikePress is ESM. It is vite-plugin-ssr which is CJS; I think the problem here is that Vite doesn't externalize vite-plugin-ssr but it should. |
So vite-plugin-ssr is CJS, but it is a pure lib without using Vite features, no? |
Yes that's my analysis as well. |
I am having a similar issue where packages, even when defined in |
Packages that are marked as |
Makes sense. The package is not a |
You can try to place it in |
Thanks, I didn't know about |
@stefanvanherwijnen we're thinking about waiting until Vite 4 to enable ssr and build deps optimization so we can release v3 sooner. If you want to test, this PR may be what ends up reaching stable: |
Fixed in |
Describe the bug
In some scenarios Vite seems to not be able to handle CJS dependencies.
This only happens with Vite 3.
Reproduction
https:/brillout/vite-3-cjs-bug
Additional Context
vikepress
includes.ts
,.css
, and.svg
files: that's because Node.js cannot handleimport './someStyles.css'
norimport emojiUrl from './someEmoji.svg'
, which means thatvikepress
cannot be externalized. That's whyvikepress
publishes its source files to npm.Note that including source files is also a common practice in SvelteKit's ecosystem.
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: