Git Product home page Git Product logo

Comments (5)

sodatea avatar sodatea commented on June 12, 2024 2

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.

benmccann avatar benmccann commented on June 12, 2024

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.

benmccann avatar benmccann commented on June 12, 2024

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.

raulfdm avatar raulfdm commented on June 12, 2024

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:

  1. Open https://www.skypack.dev/view/unified
  2. Click "Open in Codepen"
  3. Change the import statement from import unified from 'https://cdn.skypack.dev/unified'; to import {unified} from 'https://cdn.skypack.dev/unified';
  4. Console console.log(unified())

I'm not sure how they do but they do

from vite-plugin-react.

ArnaudBarre avatar ArnaudBarre commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.