babel-timing
Advanced tools
Comparing version 0.5.0 to 0.6.0
# Changelog | ||
## 0.6.0 | ||
### New Features | ||
- Add `--read-results` CLI option | ||
## 0.5.0 | ||
@@ -4,0 +10,0 @@ |
15
cli.js
#!/usr/bin/env node | ||
const fs = require('fs'); | ||
const program = require('commander'); | ||
const {babelTiming} = require('./src'); | ||
const {babelTiming, render} = require('./src'); | ||
const pkg = require('./package.json'); | ||
@@ -32,2 +33,4 @@ | ||
.option('--expand-packages', 'expand node_modules packages results') | ||
.option('--read-results <path>', 'render results from file at specified path') | ||
.option('--verbose', 'log warnings') | ||
.option( | ||
@@ -43,6 +46,10 @@ '--output <return|console|json>', | ||
) | ||
.option('--verbose', 'log warnings') | ||
.parse(process.argv); | ||
babelTiming( | ||
if (program.readResults) { | ||
const results = JSON.parse(fs.readFileSync(program.readResults)); | ||
return render(results, ({output, outputPath, paginationSize} = program)); | ||
} | ||
return babelTiming( | ||
program.args, | ||
@@ -56,7 +63,7 @@ ({ | ||
expandPackages, | ||
verbose, | ||
output, | ||
outputPath, | ||
paginationSize, | ||
verbose, | ||
} = program) | ||
); |
{ | ||
"name": "babel-timing", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Measure Babel compilation time", | ||
@@ -19,2 +19,3 @@ "main": "src/index.js", | ||
"test": "jest", | ||
"start": "node cli.js __fixtures__/entry.js --follow-imports", | ||
"preversion": "npm run prepublish", | ||
@@ -49,2 +50,3 @@ "version": "git add package.json", | ||
"lodash.chunk": "^4.2.0", | ||
"lodash.defaults": "^4.2.0", | ||
"lodash.mergewith": "^4.6.1", | ||
@@ -64,3 +66,3 @@ "multimatch": "^4.0.0", | ||
"husky": "^1.0.0", | ||
"jest": "^24.7.1", | ||
"jest": "^24.8.0", | ||
"lint-staged": "^7.0.0", | ||
@@ -77,2 +79,5 @@ "prettier": "^1.0.0", | ||
"__utils__" | ||
], | ||
"watchPathIgnorePatterns": [ | ||
".*\\.temp.*" | ||
] | ||
@@ -79,0 +84,0 @@ }, |
# Babel timing | ||
[![Build status][ci-badge]][ci] | ||
[![Npm version][npm-version-badge]][npm] | ||
Measure **Babel compilation time** [file by file](https://raw.githubusercontent.com/toomuchdesign/babel-timing/master/screenshot-01.png), [plugin by plugin](https://raw.githubusercontent.com/toomuchdesign/babel-timing/master/screenshot-02.png). | ||
Measure **Babel compilation time** **file by file**, **plugin by plugin**. | ||
[![asciicast](https://asciinema.org/a/GANbL8RdBHqThWzujdhqZeeNh.svg)](https://asciinema.org/a/GANbL8RdBHqThWzujdhqZeeNh) | ||
Get Babel transpilation insights when your application or your tests take ages to build. | ||
@@ -156,2 +159,9 @@ | ||
#### `--read-results` (CLI only, for Node use [`render` API][render-api]) | ||
Type: `string`<br /> | ||
Default: `undefined` | ||
Skip compilation and render existing results from file at specified path. | ||
#### `verbose` / `--verbose` | ||
@@ -295,7 +305,11 @@ | ||
- Make `followImports` more reliable | ||
- Consider versioning results JSON data shape | ||
[ci-badge]: https://travis-ci.org/toomuchdesign/babel-timing.svg?branch=master | ||
[ci]: https://travis-ci.org/toomuchdesign/babel-timing | ||
[npm]: https://www.npmjs.com/package/babel-timing | ||
[npm-version-badge]: https://img.shields.io/npm/v/babel-timing.svg | ||
[wrappluginvisitormethod-docs]: https://babeljs.io/docs/en/options#wrappluginvisitormethod | ||
[render-options]: #render-options | ||
[resultlist]: #resultList | ||
[render-api]: #renderresultlist-options |
@@ -1,2 +0,66 @@ | ||
const renderer = require('./renderer'); | ||
var differ = require('ansi-diff-stream'); | ||
const Table = require('./Table'); | ||
const {enableKeyPressEvent} = require('./utils'); | ||
function renderFileList({results, selected = 0, diff, paginationSize} = {}) { | ||
const output = new Table({ | ||
title: 'Babel timing - trasformed files', | ||
entries: results, | ||
entriesMap: [ | ||
['File', entry => entry.name], | ||
['Total time(ms)', entry => entry.totalTime.toFixed(3)], | ||
], | ||
selectable: true, | ||
selected, | ||
onSelected: selected => { | ||
diff.clear(); | ||
output.unmount(); | ||
renderPluginList({results, resultIndex: selected, diff, paginationSize}); | ||
}, | ||
onSelectedCommandInfo: 'show file detail', | ||
paginationSize, | ||
onRender: output => { | ||
diff.write(output); | ||
}, | ||
}); | ||
} | ||
function renderPluginList({results, resultIndex, diff, paginationSize} = {}) { | ||
const fileResult = results[resultIndex]; | ||
const output = new Table({ | ||
title: `Babel timing - info for file: ${fileResult.name}`, | ||
entries: fileResult.plugins, | ||
entriesMap: [ | ||
['pluginAlias', entry => entry.plugin], | ||
['time(ms)', entry => entry.time.toFixed(3)], | ||
['visits', entry => entry.visits], | ||
['time/visit(ms)', entry => entry.timePerVisit.toFixed(3)], | ||
], | ||
onEscape: () => { | ||
diff.clear(); | ||
output.unmount(); | ||
renderFileList({results, selected: resultIndex, diff, paginationSize}); | ||
}, | ||
onEscapeCommandInfo: 'back to results list', | ||
paginationSize, | ||
onRender: output => { | ||
diff.write(output); | ||
}, | ||
}); | ||
} | ||
function renderer(results = [], {paginationSize} = {}) { | ||
enableKeyPressEvent(); | ||
// Init ansi-diff-stream | ||
const diff = differ(); | ||
diff.pipe(process.stdout); | ||
renderFileList({ | ||
results, | ||
diff, | ||
paginationSize, | ||
}); | ||
} | ||
module.exports = renderer; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63771
314
16
25
767
4
+ Addedlodash.defaults@^4.2.0
+ Addedlodash.defaults@4.2.0(transitive)