Skip to content

Commit

Permalink
use babel instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Feb 23, 2017
1 parent 79c9c1f commit 7162d8c
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 37 deletions.
38 changes: 9 additions & 29 deletions lighthouse-extension/gulpfile.js
Expand Up @@ -12,8 +12,7 @@ const chromeManifest = require('gulp-chrome-manifest');
const debug = require('gulp-debug');
const eslint = require('gulp-eslint');
const livereload = require('gulp-livereload');
const uglifyJsHarmony = require('uglify-js-harmony');
const uglify = require('gulp-uglify/minifier');
const babel = require('babel-core');
const tap = require('gulp-tap');
const zip = require('gulp-zip');
const LighthouseRunner = require('../lighthouse-core/runner');
Expand All @@ -29,15 +28,6 @@ const computedArtifacts = fs.readdirSync(
.filter(f => /\.js$/.test(f))
.map(f => '../lighthouse-core/gather/computed/' + f.replace(/\.js$/, ''));

/**
* Removes inlined license comments from file.
* @param {string} fileContent File content as a string.
* @return {string} modified file str
*/
// function stripInlineLicenseComments(fileContent) {
// return fileContent.replace(/(<!--|\/\*\*)[\s\S]*?\d{4} Google Inc[\s\S]*?(-->|\*\/)/g, '');
// }

gulp.task('extras', () => {
return gulp.src([
'app/*.*',
Expand Down Expand Up @@ -164,28 +154,18 @@ gulp.task('browserify', cb => {

gulp.task('compilejs', () => {
const opts = {
mangle: false, // Preserve array notation property access. Needed for artifact name lookups.
warnings: true,
compress: { // turn off a bunch stuff so we don't create unexpected errors.
unused: false,
properties: false,
dead_code: false,
side_effects: false
}
compact: true, // Do not include superfluous whitespace characters and line terminators.
retainLines: true, // Keep things on the same line (looks wonky but helps with stacktraces)
comments: false, // Don't output comments
shouldPrintComment: _ => false, // Don't include @license or @preserve comments either
};

return gulp.src(['dist/scripts/lighthouse-background.js'])
.pipe(uglify(opts, uglifyJsHarmony).on('error', err => {
gutil.log(gutil.colors.red('[Error]'), err.toString());
// eslint-disable-next-line no-invalid-this
this.emit('end');
.pipe(tap(file => {
const minified = babel.transform(file.contents.toString(), opts).code;
file.contents = new Buffer(minified);
return file;
}))
// TODO: strip out headers. This was causing errors, but we should do it.
// .pipe(tap(file => {
// const content = file.contents.toString();
// file.contents = new Buffer(stripInlineLicenseComments(content));
// return file;
// }))
.pipe(gulp.dest('dist/scripts'));
});

Expand Down
4 changes: 1 addition & 3 deletions lighthouse-extension/package.json
Expand Up @@ -18,12 +18,10 @@
"gulp-eslint": "^3.0.1",
"gulp-livereload": "^3.8.1",
"gulp-tap": "^0.1.3",
"gulp-uglify": "^2.0.1",
"gulp-util": "^3.0.7",
"gulp-zip": "^3.2.0",
"package-json-versionify": "^1.0.4",
"run-sequence": "^1.1.5",
"through2": "^2.0.1",
"uglify-js-harmony": "^2.7.5"
"through2": "^2.0.1"
}
}
188 changes: 183 additions & 5 deletions lighthouse-extension/yarn.lock
Expand Up @@ -156,14 +156,120 @@ async@~0.2.6:
version "0.2.10"
resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1"

babel-code-frame@^6.16.0:
babel-code-frame@^6.16.0, babel-code-frame@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4"
dependencies:
chalk "^1.1.0"
esutils "^2.0.2"
js-tokens "^3.0.0"

babel-core@^6.0.2, babel-core@^6.23.0:
version "6.23.1"
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.23.1.tgz#c143cb621bb2f621710c220c5d579d15b8a442df"
dependencies:
babel-code-frame "^6.22.0"
babel-generator "^6.23.0"
babel-helpers "^6.23.0"
babel-messages "^6.23.0"
babel-register "^6.23.0"
babel-runtime "^6.22.0"
babel-template "^6.23.0"
babel-traverse "^6.23.1"
babel-types "^6.23.0"
babylon "^6.11.0"
convert-source-map "^1.1.0"
debug "^2.1.1"
json5 "^0.5.0"
lodash "^4.2.0"
minimatch "^3.0.2"
path-is-absolute "^1.0.0"
private "^0.1.6"
slash "^1.0.0"
source-map "^0.5.0"

babel-generator@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.23.0.tgz#6b8edab956ef3116f79d8c84c5a3c05f32a74bc5"
dependencies:
babel-messages "^6.23.0"
babel-runtime "^6.22.0"
babel-types "^6.23.0"
detect-indent "^4.0.0"
jsesc "^1.3.0"
lodash "^4.2.0"
source-map "^0.5.0"
trim-right "^1.0.1"

babel-helpers@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.23.0.tgz#4f8f2e092d0b6a8808a4bde79c27f1e2ecf0d992"
dependencies:
babel-runtime "^6.22.0"
babel-template "^6.23.0"

babel-messages@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e"
dependencies:
babel-runtime "^6.22.0"

babel-register@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.23.0.tgz#c9aa3d4cca94b51da34826c4a0f9e08145d74ff3"
dependencies:
babel-core "^6.23.0"
babel-runtime "^6.22.0"
core-js "^2.4.0"
home-or-tmp "^2.0.0"
lodash "^4.2.0"
mkdirp "^0.5.1"
source-map-support "^0.4.2"

babel-runtime@^6.22.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b"
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"

babel-template@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.23.0.tgz#04d4f270adbb3aa704a8143ae26faa529238e638"
dependencies:
babel-runtime "^6.22.0"
babel-traverse "^6.23.0"
babel-types "^6.23.0"
babylon "^6.11.0"
lodash "^4.2.0"

babel-traverse@^6.23.0, babel-traverse@^6.23.1:
version "6.23.1"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.23.1.tgz#d3cb59010ecd06a97d81310065f966b699e14f48"
dependencies:
babel-code-frame "^6.22.0"
babel-messages "^6.23.0"
babel-runtime "^6.22.0"
babel-types "^6.23.0"
babylon "^6.15.0"
debug "^2.2.0"
globals "^9.0.0"
invariant "^2.2.0"
lodash "^4.2.0"

babel-types@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.23.0.tgz#bb17179d7538bad38cd0c9e115d340f77e7e9acf"
dependencies:
babel-runtime "^6.22.0"
esutils "^2.0.2"
lodash "^4.2.0"
to-fast-properties "^1.0.1"

babylon@^6.11.0, babylon@^6.15.0:
version "6.15.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e"

balanced-match@^0.4.1:
version "0.4.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
Expand Down Expand Up @@ -549,10 +655,14 @@ content-type@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.2.tgz#b7d113aee7a8dd27bd21133c4dc2529df1721eed"

convert-source-map@~1.1.0:
convert-source-map@^1.1.0, convert-source-map@~1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860"

core-js@^2.4.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e"

core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
Expand Down Expand Up @@ -1239,7 +1349,7 @@ global-prefix@^0.1.4:
is-windows "^0.2.0"
which "^1.2.12"

globals@^9.14.0:
globals@^9.0.0, globals@^9.14.0:
version "9.16.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-9.16.0.tgz#63e903658171ec2d9f51b1d31de5e2b8dc01fb80"

Expand Down Expand Up @@ -1282,6 +1392,17 @@ graceful-fs@~1.2.0:
version "1.2.3"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364"

gulp-babel@^6.1.2:
version "6.1.2"
resolved "https://registry.yarnpkg.com/gulp-babel/-/gulp-babel-6.1.2.tgz#7c0176e4ba3f244c60588a0c4b320a45d1adefce"
dependencies:
babel-core "^6.0.2"
gulp-util "^3.0.0"
object-assign "^4.0.1"
replace-ext "0.0.1"
through2 "^2.0.0"
vinyl-sourcemaps-apply "^0.2.0"

gulp-chrome-manifest@0.0.13:
version "0.0.13"
resolved "https://registry.yarnpkg.com/gulp-chrome-manifest/-/gulp-chrome-manifest-0.0.13.tgz#f16655e70406e431d24decd6162d75545c876ab2"
Expand Down Expand Up @@ -1427,6 +1548,13 @@ hash.js@^1.0.0:
dependencies:
inherits "^2.0.1"

home-or-tmp@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"
dependencies:
os-homedir "^1.0.0"
os-tmpdir "^1.0.1"

homedir-polyfill@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz#4c2bbc8a758998feebf5ed68580f76d46768b4bc"
Expand Down Expand Up @@ -1542,6 +1670,12 @@ interpret@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c"

invariant@^2.2.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360"
dependencies:
loose-envify "^1.0.0"

irregular-plurals@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-1.2.0.tgz#38f299834ba8c00c30be9c554e137269752ff3ac"
Expand Down Expand Up @@ -1717,6 +1851,10 @@ js-yaml@^3.5.1:
argparse "^1.0.7"
esprima "^3.1.1"

jsesc@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b"

json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af"
Expand All @@ -1729,6 +1867,10 @@ json-stable-stringify@~0.0.0:
dependencies:
jsonify "~0.0.0"

json5@^0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"

jsonify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
Expand Down Expand Up @@ -1938,7 +2080,7 @@ lodash.templatesettings@^3.0.0:
lodash._reinterpolate "^3.0.0"
lodash.escape "^3.0.0"

lodash@^4.0.0, lodash@^4.13.1, lodash@^4.3.0:
lodash@^4.0.0, lodash@^4.13.1, lodash@^4.2.0, lodash@^4.3.0:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"

Expand All @@ -1950,6 +2092,12 @@ longest@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"

loose-envify@^1.0.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
dependencies:
js-tokens "^3.0.0"

loud-rejection@^1.0.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f"
Expand Down Expand Up @@ -2235,6 +2383,10 @@ os-homedir@^1.0.0, os-homedir@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"

os-tmpdir@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"

package-json-versionify@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/package-json-versionify/-/package-json-versionify-1.0.4.tgz#5860587a944873a6b7e6d26e8e51ffb22315bf17"
Expand Down Expand Up @@ -2384,6 +2536,10 @@ pretty-hrtime@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1"

private@^0.1.6:
version "0.1.7"
resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1"

process-nextick-args@~1.0.6:
version "1.0.7"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3"
Expand Down Expand Up @@ -2547,6 +2703,10 @@ redent@^1.0.0:
indent-string "^2.1.0"
strip-indent "^1.0.1"

regenerator-runtime@^0.10.0:
version "0.10.3"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.3.tgz#8c4367a904b51ea62a908ac310bf99ff90a82a3e"

regex-cache@^0.4.2:
version "0.4.3"
resolved "http://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145"
Expand Down Expand Up @@ -2688,6 +2848,10 @@ signal-exit@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"

slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"

slice-ansi@0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35"
Expand All @@ -2698,7 +2862,13 @@ sort-json@^1.2.0:
dependencies:
detect-indent "^4.0.0"

"source-map@>= 0.1.2", source-map@^0.5.1, source-map@~0.5.1, source-map@~0.5.3:
source-map-support@^0.4.2:
version "0.4.11"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.11.tgz#647f939978b38535909530885303daf23279f322"
dependencies:
source-map "^0.5.3"

"source-map@>= 0.1.2", source-map@^0.5.0, source-map@^0.5.1, source-map@^0.5.3, source-map@~0.5.1, source-map@~0.5.3:
version "0.5.6"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"

Expand Down Expand Up @@ -2954,10 +3124,18 @@ to-arraybuffer@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43"

to-fast-properties@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320"

trim-newlines@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"

trim-right@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"

tryit@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb"
Expand Down

0 comments on commit 7162d8c

Please sign in to comment.