Temporary hack to fix terser output #5461
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.
Mangled terser code is causing some problems seen in Create React App apps. This is a temporary fix that will avoid mangling the specific variable in question. Long term fix is to see if terser will provide an option to mangle properties without mangling anything else (currently not available), and/or find out what downstream build tool is causing this bug and get them to fix it.
Details:
The
initializeFirestore()
function, when mangled by terser, has two variables with the same name in different scopes (one is an import, one is aconst
in anif
block). This seems to confuse one of the tools in the Create React App production default build pipeline (Babel?). The code is converted to ES5, which makes theconst
avar
, which puts both variables sharing a name into the same scope. The build tool gets confused and does not convert the import to the correct symbol, thinking it is the same as the declaredvar
. We should try to pinpoint what step of the build this happens in and report a bug to the appropriate library.Fixes #5384