-
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
Merged
Merged
Minified Console Build #3805
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a10ee8c
Fix Firestore Console build
schmidt-sebastian b66d623
WIP
schmidt-sebastian be2671d
WIP
schmidt-sebastian 2f21579
WIP
schmidt-sebastian 65b9d42
Merge
schmidt-sebastian 3787f44
Minified Console build
schmidt-sebastian b33da3f
Bundle WebChannel
schmidt-sebastian 4808d25
Don't mangle getAuthHeaderValueForFirstParty
schmidt-sebastian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,40 +20,50 @@ | |
* This file creates a build target for it. | ||
*/ | ||
const rollup = require('rollup'); | ||
const typescriptPlugin = require('rollup-plugin-typescript2'); | ||
const typescript = require('typescript'); | ||
const json = require('rollup-plugin-json'); | ||
const alias = require('@rollup/plugin-alias'); | ||
const resolve = require('rollup-plugin-node-resolve'); | ||
const { uglify } = require('rollup-plugin-uglify'); | ||
const fs = require('fs'); | ||
const util = require('util'); | ||
const fs_writeFile = util.promisify(fs.writeFile); | ||
|
||
const rollupUtil = require('../rollup.shared'); | ||
|
||
const plugins = [ | ||
alias(rollupUtil.generateAliasConfig('browser')), | ||
resolve(), | ||
typescriptPlugin({ | ||
typescript | ||
}), | ||
json(), | ||
uglify({ | ||
output: { | ||
ascii_only: true // escape unicode chars | ||
} | ||
}) | ||
]; | ||
|
||
const EXPORTNAME = '__firestore_exports__'; | ||
|
||
const inputOptions = { | ||
const esm2017OutputFile = 'dist/standalone.esm2017.js'; | ||
const esm5OutputFile = 'dist/standalone.js'; | ||
|
||
const es2017InputOptions = { | ||
input: 'index.console.ts', | ||
plugins | ||
plugins: rollupUtil.es2017Plugins('browser', /* mangled= */ true), | ||
external: rollupUtil.resolveBrowserExterns, | ||
treeshake: { | ||
moduleSideEffects: false | ||
} | ||
}; | ||
|
||
const es2017OutputOptions = { | ||
file: esm2017OutputFile, | ||
format: 'es' | ||
}; | ||
const outputOptions = { | ||
file: 'dist/standalone.js', | ||
|
||
const es2017toEs5InputOptions = { | ||
input: esm2017OutputFile, | ||
plugins: [ | ||
...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 commentThe reason will be displayed to describe this comment to others. Learn more. nice! Found the solution for #414 |
||
} | ||
}) | ||
], | ||
external: rollupUtil.resolveBrowserExterns, | ||
treeshake: { | ||
moduleSideEffects: false | ||
} | ||
}; | ||
|
||
const es2017toEs5OutputOptions = { | ||
file: esm5OutputFile, | ||
name: EXPORTNAME, | ||
format: 'iife' | ||
}; | ||
|
@@ -65,17 +75,18 @@ exports = eval(`; | |
const POSTFIX = ` + '${EXPORTNAME};');`; | ||
|
||
async function build() { | ||
// create a bundle | ||
const bundle = await rollup.rollup(inputOptions); | ||
// Create an ES2017 bundle | ||
const es2017Bundle = await rollup.rollup(es2017InputOptions); | ||
await es2017Bundle.write(es2017OutputOptions); | ||
|
||
// generate code | ||
// Transpile down to ES5 | ||
const es5Bundle = await rollup.rollup(es2017toEs5InputOptions); | ||
const { | ||
output: [{ code }] | ||
} = await bundle.generate(outputOptions); | ||
} = await es5Bundle.generate(es2017toEs5OutputOptions); | ||
|
||
const output = `${PREFIX}${JSON.stringify(String(code))}${POSTFIX}`; | ||
|
||
await fs_writeFile(outputOptions.file, output, 'utf-8'); | ||
await fs_writeFile(es2017toEs5OutputOptions.file, output, 'utf-8'); | ||
} | ||
|
||
build(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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