[Vite 3] CJS Bug
See original GitHub issueDescribe the bug
In some scenarios Vite seems to not be able to handle CJS dependencies.
This only happens with Vite 3.
Reproduction
https://github.com/brillout/vite-3-cjs-bug
Additional Context
vikepress
includes .ts
, .css
, and .svg
files: that’s because Node.js cannot handle import './someStyles.css'
nor import emojiUrl from './someEmoji.svg'
, which means that vikepress
cannot be externalized. That’s why vikepress
publishes its source files to npm.
Note that including source files is also a common practice in SvelteKit’s ecosystem.
System Info
System:
OS: Linux 5.10 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (2) x64 Intel(R) Celeron(R) N4020 CPU @ 1.10GHz
Memory: 509.13 MB / 2.71 GB
Container: Yes
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 18.0.0 - ~/.config/nvm/versions/node/v18.0.0/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.6.0 - ~/.config/nvm/versions/node/v18.0.0/bin/npm
Browsers:
Firefox: 97.0.1
npmPackages:
vite: ^2.8.4 => 3.0.0-beta.5
Used Package Manager
pnpm
Logs
No response
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 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.
Issue Analytics
- State:
- Created a year ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Vite 3.0 is out!
In Vite 3, all of the templates got a new theme in line with the new docs. ... During build time, @rollup/plugin-commonjs is...
Read more >Configuring Vite
Configuring Vite #. When running vite from the command line, Vite will automatically try to resolve a config file named vite.config.js inside project...
Read more >Building for Production - Vite
When it is time to deploy your app for production, simply run the vite build command. By default, it uses <root>/index.html as the...
Read more >Server-Side Rendering - Vite
The Vite playground contains example SSR setups for Vue 3 and React, ... 'text/html' }).end(html) } catch (e) { // If an error...
Read more >Configuring Vite
Using these as variable names will result in an error: ... A workaround is to use CJS build outputs until ESM has better...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in
beta.9
🎉.@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: