Comments (5)
A simple workaround:
Add the following script tag in the index.html
before the entry script:
<script>var module = {}</script>
It's a bug in the Rollup CommonJS plugin that doesn't fully recognize the code snippet used by moment
to detect the CommonJS environment. I'll open an issue there.
from vite-plugin-react.
This error was also reported in a SvelteKit project: sveltejs/kit#1961
The reporter provided a repo to reproduce: https://github.com/raulfdm/sveltekit-vite-ssr-error
from vite-plugin-react.
From the SvelteKit report, I notice that unified
has "type": "module"
. It declares a dependency on is-buffer
which is CJS. This seems similar to the issue of not being able to have a CJS dependency in an ESM module (vitejs/vite#3024) though the error message is different, so I'm not sure it's exactly the same
The SvelteKit project works if I update is-buffer
and extend
to distribute ESM versions. Though the author of extend
says screw ESM. He only wants to support CJS and considers this a Vite bug (justmoon/node-extend#57). So there's a whole lot of projects that will not work in Vite until this issue is fixed since that library alone is downloaded 20m times per week
It looks like unified
is not being treated as external because there is not a separate CJS and ESM entry point. Instead it has only main
with "type": "module"
. I can't add it to ssr.external
because then I get the error message Must use import to load ES Module
from vite-plugin-react.
This error was also reported in a SvelteKit project: sveltejs/kit#1961
The reporter provided a repo to reproduce: https://github.com/raulfdm/sveltekit-vite-ssr-error (note that raulfdm/sveltekit-vite-ssr-error#1 must be merged to run the project)
Just something I think it might worth mention, is that it's possible use it with skypack:
- Open https://www.skypack.dev/view/unified
- Click "Open in Codepen"
- Change the import statement from
import unified from 'https://cdn.skypack.dev/unified';
toimport {unified} from 'https://cdn.skypack.dev/unified';
- Console
console.log(unified())
I'm not sure how they do but they do
from vite-plugin-react.
Just tested with Vite@4 and react-plugin@3 the date picker work both in dev and preview
from vite-plugin-react.
Related Issues (20)
- Uncaught SyntaxError: The requested module '/node_modules/prop-types/index.js?v=cf7fa801' does not provide an export named 'default HOT 2
- HMR Invalidate when exporting custom hooks HOT 2
- Uncaught SyntaxError: The requested module '/node_modules/prop-types/index.js?v=cf7fa801' does not provide an export named 'default HOT 3
- Update plugin to the new version of Vite 5.x HOT 12
- [bug]:at the time of installing the react vite app,it is not runnit HOT 1
- Babel reformats the input file, causing source references to be wrong HOT 8
- Decorators not working with React class components HOT 2
- Vite react-admin browser dev tools freeze (100% CPU) HOT 2
- React hooks reran on every edit HOT 6
- Error when using block comments in JSX: "repeat count must be non-negative" HOT 2
- Errors in react App.tsx file HOT 2
- Having "react" in optimizeDeps.include creates problems when "react" is externalized HOT 3
- Fast refresh without babel HOT 3
- Getting syntax error on react-redux-snackbar HOT 1
- Remove usage of Vite dedupe option
- Vite on M1 pro - This localhost page can’t be found HOT 2
- [plugin:vite:esbuild] This service is no longer running HOT 3
- HMR improvements for .ts files that include jsx
- Default ESLint setup ignores JSX files if you run `npx eslint .` HOT 3
- Injecting Preamble not possible when using `renderToPipeableStream`. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite-plugin-react.