Coder Social home page Coder Social logo

Comments (3)

dnguyenfs avatar dnguyenfs commented on July 28, 2024

Everything works fine on 2.3.2, but when I update the 2.3.3, it fails on this like:

render(() => <App />, document.getElementById("root") as HTMLElement);

The error is: Unhandled Promise Rejection: ReferenceError: Can't find variable: React

I'm using:

    "vite": "3.1.2",
    "solid-js": "^1.5.5",

is there anyway to solve this?

from vite-plugin-solid.

vsviridov avatar vsviridov commented on July 28, 2024

Same issue here. With the previous version I get function calls like this:

import { createComponent as _$createComponent } from "/node_modules/.vite/deps/solid-js_web.js?v=3ad66bd1";
...
return _$createComponent(GlobalStyles, {

but with 2.3.6 I get following in the same component:

// no explicit import
...
return React.createElement(GlobalStyles_default, {

so it's clear that the JSX is being processed differently.

Another thing I noticed, is that the broken code comes from /node_modules/.vite/deps/ path, but the working code comes from /node_modules/.pnpm/.

The readme suggests playing around with bundle pre-optimization if react code is produced (https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude), but I've no idea how to do this in this case.

Update:

adding

optimizeDeps: {
  exclude: ['library-name']
}

to vite.config.ts solved this issue. library-name in this case is the name of the library where the exception was originating.

from vite-plugin-solid.

ryansolid avatar ryansolid commented on July 28, 2024

Sorry didn't follow up with this but this issue should have been fixed over month ago. I think 2.3.8 onward..If anyone is still experiencing this let me know.

from vite-plugin-solid.

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.