Skip to content

Minified Console Build #3805

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 8 commits into from
Sep 19, 2020
Merged

Minified Console Build #3805

merged 8 commits into from
Sep 19, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Sep 18, 2020

Size before: 360299 kB
Size after: 228092 kB
Down by 37%.
You are welcome.

@changeset-bot
Copy link

changeset-bot bot commented Sep 18, 2020

💥 No Changeset

Latest commit: 4808d25

Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂

If these changes should be published to npm, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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


const es2017toEs5InputOptions = {
input: tmpFile,
plugins: rollupUtil.es2017ToEs5Plugins(/* mangled= */ true),
Copy link
Member

@Feiyang1 Feiyang1 Sep 18, 2020

Choose a reason for hiding this comment

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

You didn't include tmpFile in the include array of the typescript plugin - https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/rollup.shared.js#L181, but including it didn't work either ( it seems that include doesn't like absolute paths). So I suggest creating a tmp file with .js extension in firestore/dist, which worked for me.

I'm not sure why this works. compilerOptions is supposed to be nested under tsconfigOverride instead of being at top level according to the doc and that's what we do for all other configs.

Copy link
Member

@Feiyang1 Feiyang1 Sep 18, 2020

Choose a reason for hiding this comment

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

Tree-shaking seems to work as I don't see IndexedDbOfflineComponentProvider in the es2017 output which is not mangled.

input: 'index.console.ts',
plugins
// If I set mangled to true the build breaks, but all other build pipelines
Copy link
Member

@Feiyang1 Feiyang1 Sep 18, 2020

Choose a reason for hiding this comment

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

The problem comed from the 2 interface exports - FirestoreDatabase and FirstPartyCredentialsSettings. Once they are removed, the mangling works again.

The issue seems to be that they are not included in the public externs.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think the interfaces provide any value here since console uses the js output, so they can probably be removed.

@schmidt-sebastian schmidt-sebastian changed the title WIP Mrschmidt/smallerbuild Minified Console Build Sep 18, 2020
Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian 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 all the pointers Fei. I have addressed your feedback and it seems to work now. Savings are quite astonishing.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 18, 2020

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (0986b92) Head (5559fd7) Diff
    browser 249 kB 249 kB +47 B (+0.0%)
    esm2017 196 kB 196 kB +47 B (+0.0%)
    main 483 kB 483 kB +18 B (+0.0%)
    module 246 kB 246 kB +47 B (+0.0%)
    react-native 196 kB 196 kB +47 B (+0.0%)
  • @firebase/firestore/memory

    Type Base (0986b92) Head (5559fd7) Diff
    browser 186 kB 186 kB +47 B (+0.0%)
    esm2017 147 kB 147 kB +47 B (+0.0%)
    main 356 kB 356 kB +18 B (+0.0%)
    module 184 kB 184 kB +47 B (+0.0%)
    react-native 147 kB 147 kB +47 B (+0.0%)
  • firebase

    Type Base (0986b92) Head (5559fd7) Diff
    firebase-firestore.js 287 kB 287 kB +47 B (+0.0%)
    firebase-firestore.memory.js 226 kB 226 kB +47 B (+0.0%)
    firebase.js 830 kB 830 kB +47 B (+0.0%)

Test Logs

@schmidt-sebastian
Copy link
Contributor Author

FYI Laura confirmed that this build works in the Console.

client: CredentialsProvider;
// These are external types. Prevent minification.
['type']: 'provider';
['client']: CredentialsProvider;
Copy link
Member

Choose a reason for hiding this comment

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

Does it make any difference? These are just types which won't be minified anyway.

Copy link
Member

Choose a reason for hiding this comment

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

If you are making the change to be able to do credentials['type'], it's not necessary. Typescript will allow you to do indexing as expected.

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Sep 18, 2020

Choose a reason for hiding this comment

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

This blocks the rename during the TypeScript transformation, which is probably sane to do if we want the source to also not be minified.

Copy link
Member

Choose a reason for hiding this comment

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

I see. that makes sense

...rollupUtil.es2017ToEs5Plugins(/* mangled= */ true),
uglify({
output: {
ascii_only: true // escape unicode chars
Copy link
Member

Choose a reason for hiding this comment

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

nice! Found the solution for #414

@schmidt-sebastian schmidt-sebastian merged commit bd85ee7 into master Sep 19, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/smallerbuild branch September 19, 2020 04:44
@firebase firebase locked and limited conversation to collaborators Oct 20, 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.

3 participants