Set interop to 'auto' for cjs build #5741
Merged
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.
Something with regards to this changed in 7.3.0 release, and as a result
commonjs artifacts don't seem to use (or even have)
_interopDefaultLegacy
when needed.
One way this manifests is that using
<Textarea autosize />
in nodeenvironment (for instance a remix.run app) crashes with
This is due to
react-textarea-autosize
that
Textarea
uses under the hood always exports itself asAnd current commonjs of Textarea looking like
...we end up getting
{ default: Component }
passed toReact.createElement
and boom.Setting
interop: 'auto'
changes the behaviour to follow the way TypeScript handles these, and
the compiled code with it looks like:
And now
<Textarea autosize />
doesn't crash anymore.Note that this is only a proposal, I'm happy with any fix as long as autosized
textareas work in commonjs setup. Besides, I'm not entirely sure whether
there are any unintended side-effects of this change (or what originally
in 7.3.0 release caused this problem).