Giter Site home page Giter Site logo

Comments (4)

IgnacioNMiranda avatar IgnacioNMiranda commented on May 28, 2024 1

Thanks @jrson83! I've done some more research and this seems logical to me. Thanks for having taken a look into it!

from vite-component-library-template.

jrson83 avatar jrson83 commented on May 28, 2024 1

@IgnacioNMiranda great, if you experience any problems, please let me know.

from vite-component-library-template.

IgnacioNMiranda avatar IgnacioNMiranda commented on May 28, 2024

@jrson83 Hey! thanks for opening this and for demonstrating interest in the repo!
Could you explain a bit more why this is not needed in the bundle? Please attach any url, blog post, or news that explain it, as I was not able to find any 🙂🙏🏻

from vite-component-library-template.

jrson83 avatar jrson83 commented on May 28, 2024

@IgnacioNMiranda as I was looking for examples, how to properly bundle a react component library I found this repo. Since I was wondering, why my setup was including the jsx-runtime, I checked the dist output of your repo and it was also including the runtime.

The library package has specified react & react-dom as peerDependencies, which includes the JSX runtime. As I understand, a library bundle is meant to be consumed by another project which needs react installed as dependencies, so it solves the required peerDependencies. When the library component is consumed by the project, it receives/uses the JSX runtime from the projects dependencies. That's why there is no need to include the runtime in the component library.

"peerDependencies": {
  "react": "18.2.0",
  "react-dom": "18.2.0"
},

I found this related issue, explaining that the cause is that vite is using the automatic JSX runtime (not classic). And this stackoverflow thread, providing the same information and fix.

I added the fix, run build, then pnpm pack in the vite-component-library-template root and installed the package as local dependency inside another react project. I used import { AtButton } from 'vite-component-library-template' and run dev/build without any problems.

from vite-component-library-template.

Related Issues (11)

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.