Browse Source

Add a task to get runtime size (#36)

* add a task to get runtime size

* use babili instead of uglify-js

* style
add-plugins-support
Naoyuki Kanezawa 8 years ago
committed by Guillermo Rauch
parent
commit
7f4eb1e33e
  1. 40
      gulpfile.babel.js
  2. 2
      package.json
  3. 154
      yarn.lock

40
gulpfile.babel.js

@ -1,11 +1,45 @@
// Packages
import {join} from 'path'
import {gzipSync} from 'zlib'
import _ from 'babel-polyfill'
import gulp from 'gulp'
import babel from 'gulp-babel'
import {transformFile} from 'babel-core'
import size from 'human-size'
gulp.task('transpile', () =>
gulp.task('transpile', () => {
gulp.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('dist')))
.pipe(gulp.dest('dist'))
})
gulp.task('runtime-size', async () => {
const files = ['flush.js', 'memory.js', 'render.js', 'style.js']
const result = await Promise.all(files
.map(f => join(__dirname, 'src', f))
.map(transform))
const code = result.map(({code}) => code).join('')
console.log('-----------------------------------------------')
console.log('files:', files.join(', '))
console.log('minified:', size(code.length))
console.log('minified and gzipped:', size(gzipSync(code).length))
console.log('-----------------------------------------------')
function transform(file) {
return new Promise((resolve, reject) => {
transformFile(file, {
presets: ['babili']
}, (err, data) => {
if (err) {
return reject(err)
}
resolve(data)
})
})
}
})
gulp.task('watch', () => gulp.watch('src/*', ['transpile']))
gulp.task('default', ['transpile', 'watch'])

2
package.json

@ -24,12 +24,14 @@
"babel-core": "^6.18.2",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-polyfill": "^6.16.0",
"babel-preset-babili": "^0.0.9",
"babel-preset-es2015": "^6.16.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-3": "^6.16.0",
"babel-register": "^6.18.0",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"human-size": "^1.1.0",
"mz": "^2.6.0",
"react": "^15.4.1",
"xo": "^0.17.1"

154
yarn.lock

@ -372,6 +372,10 @@ babel-helper-define-map@^6.18.0, babel-helper-define-map@^6.8.0:
babel-types "^6.18.0"
lodash "^4.2.0"
babel-helper-evaluate-path@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/babel-helper-evaluate-path/-/babel-helper-evaluate-path-0.0.3.tgz#1d103ac9d4a59e5d431842212f151785f7ac547b"
babel-helper-explode-assignable-expression@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.18.0.tgz#14b8e8c2d03ad735d4b20f1840b24cd1f65239fe"
@ -389,6 +393,10 @@ babel-helper-explode-class@^6.8.0:
babel-traverse "^6.18.0"
babel-types "^6.18.0"
babel-helper-flip-expressions@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/babel-helper-flip-expressions/-/babel-helper-flip-expressions-0.0.1.tgz#c2ba1599426e7928333fd5c08eee6cdf8328c848"
babel-helper-function-name@^6.18.0, babel-helper-function-name@^6.8.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.18.0.tgz#68ec71aeba1f3e28b2a6f0730190b754a9bf30e6"
@ -413,6 +421,14 @@ babel-helper-hoist-variables@^6.18.0:
babel-runtime "^6.0.0"
babel-types "^6.18.0"
babel-helper-is-nodes-equiv@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/babel-helper-is-nodes-equiv/-/babel-helper-is-nodes-equiv-0.0.1.tgz#34e9b300b1479ddd98ec77ea0bbe9342dfe39684"
babel-helper-is-void-0@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/babel-helper-is-void-0/-/babel-helper-is-void-0-0.0.1.tgz#ed74553b883e68226ae45f989a99b02c190f105a"
babel-helper-optimise-call-expression@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.18.0.tgz#9261d0299ee1a4f08a6dd28b7b7c777348fd8f0f"
@ -438,6 +454,10 @@ babel-helper-remap-async-to-generator@^6.16.0, babel-helper-remap-async-to-gener
babel-traverse "^6.20.0"
babel-types "^6.20.0"
babel-helper-remove-or-void@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/babel-helper-remove-or-void/-/babel-helper-remove-or-void-0.0.1.tgz#f602790e465acf2dfbe84fb3dd210c43a2dd7262"
babel-helper-replace-supers@^6.18.0, babel-helper-replace-supers@^6.8.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.18.0.tgz#28ec69877be4144dbd64f4cc3a337e89f29a924e"
@ -449,6 +469,10 @@ babel-helper-replace-supers@^6.18.0, babel-helper-replace-supers@^6.8.0:
babel-traverse "^6.18.0"
babel-types "^6.18.0"
babel-helper-to-multiple-sequence-expressions@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/babel-helper-to-multiple-sequence-expressions/-/babel-helper-to-multiple-sequence-expressions-0.0.2.tgz#07d5d2e674aa62962ac9e0000b539920c301c4b9"
babel-helpers@^6.16.0:
version "6.16.0"
resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.16.0.tgz#1095ec10d99279460553e67eb3eee9973d3867e3"
@ -491,6 +515,61 @@ babel-plugin-espower@^2.3.1:
espurify "^1.6.0"
estraverse "^4.1.1"
babel-plugin-minify-constant-folding@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-constant-folding/-/babel-plugin-minify-constant-folding-0.0.3.tgz#a511e839562489811987a7a503c43c312c40138a"
dependencies:
babel-helper-evaluate-path "^0.0.3"
babel-plugin-minify-dead-code-elimination@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-dead-code-elimination/-/babel-plugin-minify-dead-code-elimination-0.1.1.tgz#1a0133fcd06c7fa477b01c193ba3213c8944ff01"
dependencies:
babel-helper-remove-or-void "^0.0.1"
lodash.some "^4.6.0"
babel-plugin-minify-flip-comparisons@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-flip-comparisons/-/babel-plugin-minify-flip-comparisons-0.0.1.tgz#679f4493a692afc705c4b79fde1dadb535c4eb08"
dependencies:
babel-helper-is-void-0 "^0.0.1"
babel-plugin-minify-guarded-expressions@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-guarded-expressions/-/babel-plugin-minify-guarded-expressions-0.0.3.tgz#6da1caa0b6abda964647377bd5e19afdbf91cae8"
dependencies:
babel-helper-flip-expressions "^0.0.1"
babel-plugin-minify-infinity@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-infinity/-/babel-plugin-minify-infinity-0.0.3.tgz#4cc99b61d12b434ce80ad675103335c589cba9a1"
babel-plugin-minify-mangle-names@^0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-mangle-names/-/babel-plugin-minify-mangle-names-0.0.5.tgz#53e4905de90a215622012cc003c3e0d5bdf18a8a"
babel-plugin-minify-numeric-literals@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-numeric-literals/-/babel-plugin-minify-numeric-literals-0.0.1.tgz#9597e6c31154d7daf3744d0bd417c144b275bd53"
babel-plugin-minify-replace@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-replace/-/babel-plugin-minify-replace-0.0.1.tgz#5d5aea7cb9899245248d1ee9ce7a2fe556a8facc"
babel-plugin-minify-simplify@^0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-simplify/-/babel-plugin-minify-simplify-0.0.5.tgz#71d1de1993a138282c679aad74060829b2b13ed2"
dependencies:
babel-helper-flip-expressions "^0.0.1"
babel-helper-is-nodes-equiv "^0.0.1"
babel-helper-to-multiple-sequence-expressions "^0.0.2"
babel-plugin-minify-type-constructors@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-type-constructors/-/babel-plugin-minify-type-constructors-0.0.2.tgz#4f9a28951e776f31ac11a29cd58cf9eef8b2e292"
dependencies:
babel-helper-is-void-0 "^0.0.1"
babel-plugin-syntax-async-functions@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
@ -751,6 +830,24 @@ babel-plugin-transform-flow-strip-types@^6.3.13:
babel-plugin-syntax-flow "^6.18.0"
babel-runtime "^6.0.0"
babel-plugin-transform-member-expression-literals@^6.8.0:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-member-expression-literals/-/babel-plugin-transform-member-expression-literals-6.8.0.tgz#718755a70492a895d8f41810afa9998bc09f57b9"
dependencies:
babel-runtime "^6.0.0"
babel-plugin-transform-merge-sibling-variables@^6.8.0:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-merge-sibling-variables/-/babel-plugin-transform-merge-sibling-variables-6.8.0.tgz#724074e4ef78b601fcf9a34165c972a1b6117e99"
dependencies:
babel-runtime "^6.0.0"
babel-plugin-transform-minify-booleans@^6.8.0:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-minify-booleans/-/babel-plugin-transform-minify-booleans-6.8.0.tgz#b1a48864a727847696b84eae36fa4d085a54b42b"
dependencies:
babel-runtime "^6.0.0"
babel-plugin-transform-object-rest-spread@^6.16.0:
version "6.20.2"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.20.2.tgz#e816c55bba77b14c16365d87e2ae48c8fd18fc2e"
@ -758,6 +855,12 @@ babel-plugin-transform-object-rest-spread@^6.16.0:
babel-plugin-syntax-object-rest-spread "^6.8.0"
babel-runtime "^6.20.0"
babel-plugin-transform-property-literals@^6.8.0:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-property-literals/-/babel-plugin-transform-property-literals-6.8.0.tgz#a65b2e6e1274d25df0f3a4c5e85bc8f1cdd9e019"
dependencies:
babel-runtime "^6.0.0"
babel-plugin-transform-react-display-name@^6.3.13:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-display-name/-/babel-plugin-transform-react-display-name-6.8.0.tgz#f7a084977383d728bdbdc2835bba0159577f660e"
@ -792,12 +895,26 @@ babel-plugin-transform-regenerator@^6.16.0:
dependencies:
regenerator-transform "0.9.8"
babel-plugin-transform-regexp-constructors@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-regexp-constructors/-/babel-plugin-transform-regexp-constructors-0.0.3.tgz#463200d8371a06f077226b967858369211b5cfe3"
babel-plugin-transform-remove-undefined@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-remove-undefined/-/babel-plugin-transform-remove-undefined-0.0.3.tgz#34baeb7bde4fc01d5235304ee891e7b6bff00432"
babel-plugin-transform-runtime@^6.15.0:
version "6.15.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.15.0.tgz#3d75b4d949ad81af157570273846fb59aeb0d57c"
dependencies:
babel-runtime "^6.9.0"
babel-plugin-transform-simplify-comparison-operators@^6.8.0:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-simplify-comparison-operators/-/babel-plugin-transform-simplify-comparison-operators-6.8.0.tgz#0183d65bfdc54c80d922a3a9b3008e25fa9d32a7"
dependencies:
babel-runtime "^6.0.0"
babel-plugin-transform-strict-mode@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.18.0.tgz#df7cf2991fe046f44163dcd110d5ca43bc652b9d"
@ -805,6 +922,12 @@ babel-plugin-transform-strict-mode@^6.18.0:
babel-runtime "^6.0.0"
babel-types "^6.18.0"
babel-plugin-transform-undefined-to-void@^6.8.0:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-undefined-to-void/-/babel-plugin-transform-undefined-to-void-6.8.0.tgz#bc5b6b4908d3b1262170e67cb3963903ddce167e"
dependencies:
babel-runtime "^6.0.0"
babel-polyfill@^6.16.0:
version "6.20.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.20.0.tgz#de4a371006139e20990aac0be367d398331204e7"
@ -813,6 +936,29 @@ babel-polyfill@^6.16.0:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"
babel-preset-babili@^0.0.9:
version "0.0.9"
resolved "https://registry.yarnpkg.com/babel-preset-babili/-/babel-preset-babili-0.0.9.tgz#699f08703ff1c84f4f6c229ffe5662c8f1861bf2"
dependencies:
babel-plugin-minify-constant-folding "^0.0.3"
babel-plugin-minify-dead-code-elimination "^0.1.1"
babel-plugin-minify-flip-comparisons "^0.0.1"
babel-plugin-minify-guarded-expressions "^0.0.3"
babel-plugin-minify-infinity "^0.0.3"
babel-plugin-minify-mangle-names "^0.0.5"
babel-plugin-minify-numeric-literals "^0.0.1"
babel-plugin-minify-replace "^0.0.1"
babel-plugin-minify-simplify "^0.0.5"
babel-plugin-minify-type-constructors "^0.0.2"
babel-plugin-transform-member-expression-literals "^6.8.0"
babel-plugin-transform-merge-sibling-variables "^6.8.0"
babel-plugin-transform-minify-booleans "^6.8.0"
babel-plugin-transform-property-literals "^6.8.0"
babel-plugin-transform-regexp-constructors "^0.0.3"
babel-plugin-transform-remove-undefined "^0.0.3"
babel-plugin-transform-simplify-comparison-operators "^6.8.0"
babel-plugin-transform-undefined-to-void "^6.8.0"
babel-preset-es2015-node4@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/babel-preset-es2015-node4/-/babel-preset-es2015-node4-2.1.0.tgz#9852f281e2332b57d49c189841ac25466a6ebe98"
@ -2293,6 +2439,10 @@ http-signature@~1.1.0:
jsprim "^1.2.2"
sshpk "^1.7.0"
human-size@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/human-size/-/human-size-1.1.0.tgz#052562be999841c037022c20259990c56ea996f9"
iconv-lite@~0.4.13:
version "0.4.15"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb"
@ -2884,6 +3034,10 @@ lodash.snakecase@^4.0.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz#39d714a35357147837aefd64b5dcbb16becd8f8d"
lodash.some@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d"
lodash.template@^3.0.0:
version "3.6.2"
resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-3.6.2.tgz#f8cdecc6169a255be9098ae8b0c53d378931d14f"

Loading…
Cancel
Save