Closed pwolfert closed 5 months ago
Thanks @pwolfert !
Thank you, @gpbl!
FYI this is also the correct fix if only react/jsx-runtime
would exist. Otherwise library consumers would need to use the React version that was used when publishing this library. Either you declare React as a peer dependency, or inline all its packages. Externalizing some entrypoints while declaring others as peer dependencies only worked incidentally.
@eps1lon, maybe I'm not understanding, but it looks like react
is a peer dependency of this library, which should mean that react/jsx-runtime
should exist, right? Or are you saying it does exist, and so therefore this is the correct fix?
Or are you saying it does exist, and so therefore this is the correct fix?
This. Previously you were inlining react/jsx-runtime
. Either you inline all entrypoints or none. Just inlining a few (here: just the JSX entrypoint), is bad.
Okay cool 😅
Description
When the new jsx transform was introduced, a copy of the JSX runtime started getting included in the
index.esm.js
bundle. Including this copy meant that we could no longer swap out that module when building our own downstream Preact project. In effect, it broke Preact support.To fix this, I've updated the
rollup
config to treatreact/jsx-runtime
as an external dependency. By externalizing the JSX runtime in this project, it 1) reduces the library bundle size by 32% and 2) allows downstream projects to use whatever JSX runtime they want.Type of Change
Could possibly be considered a breaking change, but I don't know the landscape of dependent projects well enough to know if that's true.
Checklist
Before submitting your pull request, please make sure the following is done:
Linked Issues
If this PR addresses any existing issues, please link them here. Example:
Fixes #123
Test Plan
You can test that it removes the runtime by searching for the
jsxDEV
function indist/index.esm.js
before and after the change. You can also see that the file size changed from144KB
to97KB
.I can also create a branch in my downstream project for testing upon request.