Closed Jairwin-L closed 1 year ago
This error was also reported in a SvelteKit project: https://github.com/sveltejs/kit/issues/1961
The reporter provided a repo to reproduce: https://github.com/raulfdm/sveltekit-vite-ssr-error
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 (https://github.com/vitejs/vite/issues/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 (https://github.com/justmoon/node-extend/pull/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
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:
import unified from 'https://cdn.skypack.dev/unified';
to import {unified} from 'https://cdn.skypack.dev/unified';
console.log(unified())
I'm not sure how they do but they do
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.
Just tested with Vite@4 and react-plugin@3 the date picker work both in dev and preview
Describe the bug
使用antd的DatePicker组件点击时候出现问题,如图:![image](https://user-images.githubusercontent.com/32570960/124380175-e60e7880-dced-11eb-96e4-0701769e7523.png)
感谢🙏: @sodatea @Shinigami92 @underfin @psaren
Reproduction
https://github.com/Jairwin-L/vite-react-ts-demo/blob/077146486dcbd2965b6773bcf170dce5aabaec51/src/pages/demo.tsx#L25
System Info
Used Package Manager
yarn
Logs
Validations