(inputFile)
| 11 | run(process.argv[2]); |
| 12 | |
| 13 | function run(inputFile) { |
| 14 | const input = fs.readFileSync(inputFile).toString(); |
| 15 | const table = new Table( |
| 16 | Object.assign( |
| 17 | { |
| 18 | head: [ |
| 19 | "name", |
| 20 | "output(bytes)", |
| 21 | "output gzip(bytes)", |
| 22 | "raw compression (%)", |
| 23 | "gzip win (%)", |
| 24 | "gzip % (%)", |
| 25 | "parse time Δ (ms)" |
| 26 | ] |
| 27 | }, |
| 28 | tableStyle() |
| 29 | ) |
| 30 | ); |
| 31 | |
| 32 | const baseOutput = transformSync(input, { |
| 33 | minified: true, |
| 34 | babelrc: false, |
| 35 | configFile: false, |
| 36 | compact: true, |
| 37 | comments: false |
| 38 | }).code; |
| 39 | |
| 40 | const baseGzip = zlib.gzipSync(baseOutput); |
| 41 | |
| 42 | const baseParseTime = getParseTime(baseOutput); |
| 43 | |
| 44 | const plugins = getPlugins(); |
| 45 | let current = 1; |
| 46 | |
| 47 | plugins.forEach(({ name, plugin }) => { |
| 48 | process.stdout.write(`Plugin ${current++}/${plugins.length}\r`); |
| 49 | |
| 50 | const output = transformSync(baseOutput, { |
| 51 | plugins: [plugin], |
| 52 | minified: true, |
| 53 | babelrc: false, |
| 54 | configFile: false, |
| 55 | compact: true, |
| 56 | comments: false |
| 57 | }).code; |
| 58 | |
| 59 | const gzippedOutput = zlib.gzipSync(output); |
| 60 | |
| 61 | const parseTime = getParseTime(output); |
| 62 | |
| 63 | const percentage = (1 - len(output) / len(baseOutput)) * 100; |
| 64 | const gzipWin = (1 - len(gzippedOutput) / len(baseGzip)) * 100; |
| 65 | const gzipPercentage = (1 - len(gzippedOutput) / len(output)) * 100; |
| 66 | |
| 67 | const parseTimeDiff = baseParseTime - parseTime; |
| 68 | |
| 69 | table.push([ |
| 70 | name.split("babel-plugin-")[1], |
no test coverage detected