-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Update the gulp minified
command to use uglify-es
#8831
Conversation
gulpfile.js
Outdated
|
||
console.log(); | ||
console.log('### Minifying js files'); | ||
|
||
var UglifyJS = require('uglify-js'); | ||
var UglifyJS = require('uglify-es'); |
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 think this should be UglifyES
. If you want to avoid that, you can also choose uglifier
as a more generic name.
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.
Sure, will do.
]; | ||
var pdfFile = fs.readFileSync(MINIFIED_DIR + '/build/pdf.js').toString(); | ||
var pdfWorkerFile = | ||
fs.readFileSync(MINIFIED_DIR + '/build/pdf.worker.js').toString(); |
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 think we should use BUILD_DIR
here and in the other parts of this patch to not hardcode that and to be consistent with other places in the Gulpfile.
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 was just moving existing code around, but I suppose it wouldn't hurt to change this :-)
Edit: Actually, looking through the rest of gulpfile.js
, it seems to (almost) exclusively be used when defining other constants, so I'm now not so sure if we really ought to be using it "the other way around" here!?
Lines 46 to 58 in 7cc7260
var BASELINE_DIR = BUILD_DIR + 'baseline/'; | |
var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline/'; | |
var GENERIC_DIR = BUILD_DIR + 'generic/'; | |
var COMPONENTS_DIR = BUILD_DIR + 'components/'; | |
var SINGLE_FILE_DIR = BUILD_DIR + 'singlefile/'; | |
var MINIFIED_DIR = BUILD_DIR + 'minified/'; | |
var FIREFOX_BUILD_DIR = BUILD_DIR + 'firefox/'; | |
var CHROME_BUILD_DIR = BUILD_DIR + 'chromium/'; | |
var JSDOC_BUILD_DIR = BUILD_DIR + 'jsdoc/'; | |
var GH_PAGES_DIR = BUILD_DIR + 'gh-pages/'; | |
var SRC_DIR = 'src/'; | |
var LIB_DIR = BUILD_DIR + 'lib/'; | |
var DIST_DIR = BUILD_DIR + 'dist/'; |
By updating to uglify-es, rather than uglify-js, the minifier *itself* now supports ES6 code. This means that it's now possible to minify code built with `PDFJS_NEXT = true` set, i.e. with Babel transpilation disabled, which wasn't the case previously. Note that uglify-es is based on the API of uglify-js v3, which differs from the one that we previously used. Of particular importance is the fact that it's no longer possible to provide a path to a file for minification, but one must instead directly provide the source of the file. For more information, please see https://github.com/mishoo/UglifyJS2/tree/harmony
Works fine, thank you! |
Update the `gulp minified` command to use uglify-es
By updating to uglify-es, rather than uglify-js, the minifier itself now supports ES6 code. This means that it's now possible to minify code built with
PDFJS_NEXT = true
set, i.e. with Babel transpilation disabled, which wasn't the case previously.Note that uglify-es is based on the API of uglify-js v3, which differs from the one that we previously used.
Of particular importance is the fact that it's no longer possible to provide a path to a file for minification, but one must instead directly provide the source of the file.
For more information, please see https://github.com/mishoo/UglifyJS2/tree/harmony