fix(react-intl): named esm exports #3261
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.
v5.8.0 introduced a bug where some of the named exports such as
injectIntl
are no longer statically analyzable by cjs-module-lexer, breaking the named export for es modules.The root cause is because of a change in Typescript between versions 3.9.7 and 4.0.5 where the added
__importDefault
function call no longer matches the static analysis lexer (docs) due to the potential for side effects.There has been some back and fourth between the Typescript folks and the author of the lexer
with the tl;dr being that the lexer will not be updated since it would effectively cause module loading to work differently in different versions of node and it's better to just be consistent.
The fix here is to remove any
export { default as ...
from index.js, separating the import and export so that the export is once again statically analyzable.This is still tree shakable, so we won't pull
injectIntl
into all code using react-intl or anything like that.A reasonable test for this might look like this, though I'm not sure exactly how to work this into the build system. I'm having some issues with the bazel setup y'all have here
no such package '@npm//ts-node': npm_install failed
but I'll see if I can debug those and shoehorn this test in (or something similar).