Skip to content

Firestore: fix source maps that incorrectly referenced back into the bundle itself #7382

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

Merged
merged 4 commits into from
Jun 22, 2023

Conversation

dconeybe
Copy link
Contributor

Some of the bundles produced by Firestore's rollup pipeline generated source maps that incorrectly linked into yet another minified, mangled JavaScript file, instead of back into the original source code. This rendered the source maps useless because there was no way to get back to the original source code.

The root problem was that the rollup pipeline is done in a two step process. Step 1 produces a minified, mangled bundle and step 2 takes that minified, mangled bundle and produces other minified, mangled bundles. Surprisingly, some of the source maps did indeed map back to the original source code (i.e. index.esm5.js.map and index.node.cjs.js) but others referenced the intermediate minified, mangled bundle (i.e. index.esm2017.js, index.cjs.js, index.node.mjs, and index.browser.esm2017.js).

The "good" source maps, it was discovered, worked correctly by using the rollup-plugin-sourcemaps plugin, which "passes through" the source maps of intermediate files. So the fix was easy: just use the rollup-plugin-sourcemaps plugin in the other bundles as well. Sure enough, that is the fix in this PR and the source maps are good again.

@dconeybe dconeybe self-assigned this Jun 22, 2023
@dconeybe dconeybe requested review from a team as code owners June 22, 2023 03:41
@changeset-bot
Copy link

changeset-bot bot commented Jun 22, 2023

🦋 Changeset detected

Latest commit: 90b3e0c

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jun 22, 2023

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jun 22, 2023

@dconeybe
Copy link
Contributor Author

@hsubox76 Posted this question to me in a different forum, and I'm moving the discussion here to keep it all together.

You said the esm5 bundles previously worked, both of them? I see the Firestore Lite rollup config already had sourcemaps() in the ESM5 config (my comment there was about why it needed to be reordered), but I don't see it in the ESM5 config for non-lite. Did it work anyway? Does it need to be added there in this PR (line 146/150 in the PR in rollup.config.js)?

Good question. The sourcemaps() is there for the esm5 bundles for the non-lite SDK... it's just tucked away. The "plugins" list for the esm5 bundle contains ...util.es2017ToEs5Plugins(/* mangled= */ true):

...util.es2017ToEs5Plugins(/* mangled= */ true),

That es2017ToEs5Plugins() function adds the sourcemaps() here:

.

Copy link
Contributor

@hsubox76 hsubox76 left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation!

@dconeybe dconeybe merged commit d86c89f into master Jun 22, 2023
@dconeybe dconeybe deleted the dconeybe/SourceMapRollupFix2 branch June 22, 2023 18:01
@google-oss-bot google-oss-bot mentioned this pull request Jul 6, 2023
@dconeybe
Copy link
Contributor Author

dconeybe commented Jul 7, 2023

This was included in the v10.0.0 release: https://firebase.google.com/support/release-notes/js#version_1000_-_july_6_2023

@firebase firebase locked and limited conversation to collaborators Jul 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants