Skip to content
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

breaking: bump terser #52

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
module.exports = {
"extends": "eslint:recommended",
"plugins": ["jest"],
"parserOptions": {
"ecmaVersion": 6
"ecmaVersion": 2018
},
"ignorePatterns": [
"test/fixtures/input"
],
"env": {
"node": true
"node": true,
"es6": true,
"jest": true
},
"rules": {
}
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- "6"
- "10"
cache: yarn
sudo: false
11 changes: 5 additions & 6 deletions lib/summarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ const pify = require('pify');

function uglify(content) {
return new Promise((resolve, reject) => {
lifeart marked this conversation as resolved.
Show resolved Hide resolved
let uglified = Terser.minify(content);
if (uglified.error) {
reject(uglified.error);
} else {
resolve(uglified.code);
}
Terser.minify(content).then((result)=>{
resolve(result.code);
}).catch(err=>{
reject(err);
});
});
}

Expand Down
30 changes: 14 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"description": "",
"main": "lib/index.js",
"scripts": {
"test": "mocha --recursive test/**/*-test.js"
"test": "eslint . && jest"
},
"repository": {
"type": "git",
Expand All @@ -20,25 +20,23 @@
},
"homepage": "https://github.com/stefanpenner/broccoli-concat-analyser#readme",
"dependencies": {
"filesize": "^3.3.0",
"fs-extra": "^4.0.2",
"ora": "^0.3.0",
"pify": "^4.0.0",
"terser": "^3.10.11",
"walk-sync": "^0.3.1",
"workerpool": "^2.3.1",
"filesize": "^6.1.0",
"fs-extra": "^9.0.1",
"ora": "^5.1.0",
"pify": "^5.0.0",
"terser": "^5.3.1",
"walk-sync": "^2.2.0",
"workerpool": "^6.0.0",
"zlib": "^1.0.5"
},
"devDependencies": {
"chai": "^4.0.2",
"chai-as-promised": "^7.1.1",
"chai-files": "^1.4.0",
"html-validator": "^3.0.6",
"mocha": "^3.4.2",
"mocha-eslint": "^4.0.0",
"tmp": "^0.0.33"
"eslint": "^7.9.0",
"eslint-plugin-jest": "^24.0.1",
"html-validator": "^5.1.16",
"jest": "^26.4.2",
"tmp": "^0.2.1"
},
"engines": {
"node": "6.* || 8.* || >= 10.*"
"node": ">= 10.*"
}
}
5 changes: 0 additions & 5 deletions test/.eslintrc.js

This file was deleted.

94 changes: 94 additions & 0 deletions test/acceptance/__snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CLI generates expected output 1`] = `
"{
\\"outputFile\\": \\"/assets/test-app.js\\",
\\"files\\": [
{
\\"relativePath\\": \\"test-app/app.js\\",
\\"sizes\\": {
\\"raw\\": 624,
\\"uglified\\": 377,
\\"compressed\\": 120.451057165231
}
},
{
\\"relativePath\\": \\"test-app/initializers/app-version.js\\",
\\"sizes\\": {
\\"raw\\": 524,
\\"uglified\\": 313,
\\"compressed\\": 100.00313234142521
}
},
{
\\"relativePath\\": \\"test-app/initializers/container-debug-adapter.js\\",
\\"sizes\\": {
\\"raw\\": 606,
\\"uglified\\": 430,
\\"compressed\\": 137.38449490994518
}
},
{
\\"relativePath\\": \\"test-app/initializers/export-application-global.js\\",
\\"sizes\\": {
\\"raw\\": 1426,
\\"uglified\\": 686,
\\"compressed\\": 219.17619420516837
}
},
{
\\"relativePath\\": \\"test-app/resolver.js\\",
\\"sizes\\": {
\\"raw\\": 238,
\\"uglified\\": 156,
\\"compressed\\": 49.841816758026624
}
},
{
\\"relativePath\\": \\"test-app/router.js\\",
\\"sizes\\": {
\\"raw\\": 442,
\\"uglified\\": 268,
\\"compressed\\": 85.62568519968676
}
},
{
\\"relativePath\\": \\"test-app/templates/application.js\\",
\\"sizes\\": {
\\"raw\\": 406,
\\"uglified\\": 324,
\\"compressed\\": 103.51761942051684
}
}
]
}"
`;

exports[`CLI generates expected output 2`] = `
"{
\\"outputFile\\": \\"/assets/vendor.css\\",
\\"files\\": []
}"
`;

exports[`CLI generates expected output 3`] = `
"{
\\"outputFile\\": \\"/assets/test-support.css\\",
\\"files\\": [
{
\\"relativePath\\": \\"vendor/qunit/qunit.css\\",
\\"sizes\\": {
\\"raw\\": 8311,
\\"compressed\\": 2146.4629921259843
}
},
{
\\"relativePath\\": \\"vendor/ember-qunit/test-container-styles.css\\",
\\"sizes\\": {
\\"raw\\": 578,
\\"compressed\\": 149.2787401574803
}
}
]
}"
`;
19 changes: 8 additions & 11 deletions test/acceptance/cli-test.js → test/acceptance/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
'use strict';

const chai = require('chai');
const expect = chai.expect;
const tmp = require('tmp');
const chaiFiles = require('chai-files');
const file = chaiFiles.file;
const path = require('path');
const cp = require('child_process');
const fs = require('fs-extra');
const validate = require('html-validator');
const copyFixtures = require('../helpers/copy-fixtures');

const inputFixturePath = 'test/fixtures/input';
const outputFixturePath = 'test/fixtures/output';

const inputFiles = ['1-test-app.js', '3-vendor.css', '8-test-support.css'];

const originalCwd = process.cwd();
let tmpPath;
let outPath;

chai.use(chaiFiles);
function file(dir) {
return fs.readFileSync(dir, 'utf-8');
}

function run() {
let stdout = '';
Expand Down Expand Up @@ -67,20 +64,20 @@ describe('CLI', function() {
let exitCode = result.exitCode;
let stdout = result.stdout;

expect(exitCode).to.equal(0);
expect(stdout).to.contain(`visit file://${outPath}/index.html`);
expect(exitCode).toEqual(0);
expect(stdout).toContain(`visit file://${outPath}/index.html`);

// write .out.json files
inputFiles.forEach((inputFile) => {
let outputFile = `${inputFile}.out.json`;
expect(file(path.join(outPath, outputFile))).to.equal(file(path.join(outputFixturePath, outputFile)));
expect(file(path.join(outPath, outputFile))).toMatchSnapshot();
});

// copies static output files
expect(file(path.join(outPath, 'index.html'))).to.exist;
expect(file(path.join(outPath, 'index.html'))).toBeTruthy();

let data = fs.readFileSync(`${outPath}/index.html`, 'UTF8');
expect(data).to.contain('var SUMMARY = {');
expect(data).toContain('var SUMMARY = {');

return validate({
data,
Expand Down
8 changes: 0 additions & 8 deletions test/eslint-test.js

This file was deleted.

61 changes: 0 additions & 61 deletions test/fixtures/output/1-test-app.js.out.json

This file was deleted.

4 changes: 0 additions & 4 deletions test/fixtures/output/3-vendor.css.out.json

This file was deleted.

19 changes: 0 additions & 19 deletions test/fixtures/output/8-test-support.css.out.json

This file was deleted.

Loading