-
Notifications
You must be signed in to change notification settings - Fork 934
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
Minified Console Build #3805
Conversation
💥 No ChangesetLatest 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 changesetsWhen 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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Binary Size ReportAffected SDKs
Test Logs |
FYI Laura confirmed that this build works in the Console. |
client: CredentialsProvider; | ||
// These are external types. Prevent minification. | ||
['type']: 'provider'; | ||
['client']: CredentialsProvider; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
Size before: 360299 kB
Size after: 228092 kB
Down by 37%.
You are welcome.