fix: support Rollup apps by using a named export #690
Closed
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.
Hey there 👋! Great job with your library 👏. This simple PR should help clear up a couple of long-standing issues. Closes #588, closes #669 and closes #658. The bug has been discussed in length in these issues and is also mentioned in #542.
What is happening?
When using this library in an app built using Rollup, this error happens at runtime:
Issue #669 provides a great minimal repoduction.
What does this PR do?
I found both default and named exports in
src/style.js
. Even though it's in the ESM specs, this is hard for Rollup to handle.This PR fixes this by adding and using a named export for the component, so that the file exports the
JSXStyle
component as both a named and default export. Then the named export is consumed by the transpiled code produced by the Babel plugin.Currently
styled-jsx
transpiles the example to the following:The new output has a named import instead: