Skip to content

Commit dca28a1

Browse files
authored
Temporary hack to fix terser output (#5461)
1 parent 66d4a1e commit dca28a1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.changeset/spicy-moose-approve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/firestore': patch
3+
---
4+
5+
Temporary fix for a bug causing `initializeFirestore()` to not work with certain bundling pipelines.

packages/firestore/rollup.shared.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ const manglePrivatePropertiesOptions = {
145145
beautify: true
146146
},
147147
mangle: {
148+
// Temporary hack fix for an issue where mangled code causes some downstream
149+
// bundlers (Babel?) to confuse the same variable name in different scopes.
150+
// This can be removed if the problem in the downstream library is fixed
151+
// or if terser's mangler provides an option to avoid mangling everything
152+
// that isn't a property.
153+
// See issue: https://github.com/firebase/firebase-js-sdk/issues/5384
154+
reserved: ['_getProvider'],
148155
properties: {
149156
regex: /^__PRIVATE_/,
150157
// All JS Keywords are reserved. Although this should be taken cared of by
@@ -284,7 +291,12 @@ exports.es2017ToEs5Plugins = function (mangled = false) {
284291
comments: 'all',
285292
beautify: true
286293
},
287-
mangle: true
294+
// See comment above `manglePrivatePropertiesOptions`. This build did
295+
// not have the identical variable name issue but we should be
296+
// consistent.
297+
mangle: {
298+
reserved: ['_getProvider']
299+
}
288300
}),
289301
sourcemaps()
290302
];

0 commit comments

Comments
 (0)