build: Fix Preact support by externalizing JSX runtime #2076
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.