Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary hack to fix terser output #5461

Merged
merged 3 commits into from
Sep 9, 2021
Merged

Temporary hack to fix terser output #5461

merged 3 commits into from
Sep 9, 2021

Conversation

hsubox76
Copy link
Contributor

@hsubox76 hsubox76 commented Sep 8, 2021

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 a const in an if 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 the const a var, 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 declared var. We should try to pinpoint what step of the build this happens in and report a bug to the appropriate library.

Fixes #5384

@changeset-bot
Copy link

changeset-bot bot commented Sep 8, 2021

🦋 Changeset detected

Latest commit: 78fab00

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/firestore Patch
firebase Patch
@firebase/firestore-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

// bundlers (Babel?) to confuse the same variable name in different scopes.
// This can be removed if the problem in the downstream library is fixed
// or if terser's mangler provides an option to avoid mangling everything
// that isn't a property.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth adding the issue link for future reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two lists of reserved properties now (see right below - line 158). Do we know that this will work?

@google-oss-bot google-oss-bot added the doc-changes PRs that affect docs label Sep 9, 2021
@hsubox76 hsubox76 merged commit dca28a1 into master Sep 9, 2021
@hsubox76 hsubox76 deleted the ch-terser branch September 9, 2021 01:05
@google-oss-bot google-oss-bot mentioned this pull request Sep 9, 2021
@firebase firebase locked and limited conversation to collaborators Oct 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
doc-changes PRs that affect docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error in prod build for 9.0.0 firestore
5 participants