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

Add minified ("mangled") Firestore build #2495

Merged
merged 11 commits into from
Jan 13, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Jan 7, 2020

Sending this one out for early review. Doc for more context: go/minification

This PR adds a new Firestore where most identifiers a mangled (a size saving of 9% gzipped). I don't know too much about the Rollup pipeline, so any suggestions there are more than appreciated.

The basic steps involved in this minification/mangling are:

  • Gather a list of symbols that are used in any of Firestore's external dependencies (this includes the JavaScript library, other Firebase SDKs, the Protobuf files as well as our LocalStorage and IndexedDb schema).
  • Using a Typescript Transformer, prefix all symbols that are not used in said public API with _PRIVATE
  • Use Terser's property mangling with to minify all renamed symbols.

The output of this process are a couple of new files:

  • packages/firebase/firebase-firestore.min.js
  • packages/firestore/dist/index.cjs.min.js
  • packages/firestore/dist/index.esm.min.js
  • packages/firestore/dist/index.esm2018.min.js

We discussed internally to only have a single build and make our default build use the new mangled property names. That might be coming before we release this, but we need to figure out how to run our integration test against the mangled build first.

@schmidt-sebastian schmidt-sebastian changed the title Add minified Firestore build Add minified ("mangled") Firestore build Jan 8, 2020
@Plantain
Copy link

Plantain commented Jan 9, 2020

go/minification
Can you share this doc externally?

@schmidt-sebastian
Copy link
Contributor Author

go/minification
Can you share this doc externally?

Sorry - most of our design docs (including this one) are internal only for now. I can promise that it is not all that interesting :)

"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-replace": "2.2.0",
"rollup-plugin-terser": "5.1.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless this version is important you could probably move up to terser 5.1.3 and not have 2 separate versions in yarn.lock

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to 5.1.3. Thanks!

@schmidt-sebastian schmidt-sebastian merged commit 00e77c1 into master Jan 13, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/sdkminifier branch January 13, 2020 23:00
@stefanklokgieters
Copy link

Will this also be part of the Firebase package? Did not see a version bump yet 😄

@schmidt-sebastian
Copy link
Contributor Author

This hasn't been released yet. We are working on it!

@hsubox76 hsubox76 added this to the next milestone Jan 16, 2020
@firebase firebase locked and limited conversation to collaborators Feb 13, 2020
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