Permalink
Browse files

revert prepack

  • Loading branch information...
Illyism committed Jun 6, 2017
1 parent 554b96c commit e67bcf67c7461ecf581d92ccc1fb9a3c6d0e6ec4
Showing with 47 additions and 26 deletions.
  1. +10 −4 config/rollup.config.js
  2. +12 −7 lib/purifycss.es.js
  3. +12 −7 lib/purifycss.js
  4. +0 −1 package.json
  5. +2 −2 src/utils/ExtractWordsUtil.js
  6. +11 −5 src/utils/FileUtil.js
View
@@ -20,11 +20,17 @@ export default {
resolve(),
commonjs(),
babel({
exclude: "node_modules/**",
presets: [["es2015", { modules: false }]],
plugins: ["external-helpers"]
exclude: "node_modules/**",
presets: [
[
"es2015", {
"modules": false
}
]
],
"plugins": [ "external-helpers" ]
})
],
external: ["clean-css", "glob", "rework", "uglify-js", "prepack"],
external: ["clean-css", "glob", "rework", "uglifyjs"],
sourceMap: false
}
View
@@ -1,7 +1,6 @@
import CleanCss from 'clean-css';
import rework from 'rework';
import glob from 'glob';
import { prepack as prepack$1 } from 'prepack';
var domain;
@@ -663,14 +662,20 @@ var CssTreeWalker = function (_EventEmitter) {
var UglifyJS = require("uglify-js");
var fs$1 = require("fs");
var compressCode = function compressCode(code) {
var compressedCode = code;
try {
var prepackedCode = prepack$1(code).code;
compressedCode = UglifyJS.minify(prepackedCode).code;
// Try to minimize the code as much as possible, removing noise.
var ast = UglifyJS.parse(code);
ast.figure_out_scope();
var compressor = UglifyJS.Compressor({ warnings: false });
ast = ast.transform(compressor);
ast.figure_out_scope();
ast.compute_char_frequency();
ast.mangle_names({ toplevel: true });
code = ast.print_to_string().toLowerCase();
} catch (e) {
// If compression fails, assume it's not a JS file and return the full code.
}
return compressedCode.toLowerCase();
return code.toLowerCase();
};
var concatFiles = function concatFiles(files, options) {
@@ -775,7 +780,7 @@ var getAllWordsInContent = function getAllWordsInContent(content) {
html: true,
body: true
};
var words = content.split(/[^a-z-]/g);
var words = content.split(/[^a-z]/g);
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
@@ -832,7 +837,7 @@ var getAllWordsInSelector = function getAllWordsInSelector(selector) {
skipNextWord = true;
continue;
}
if (/[a-z-]/.test(letter)) {
if (/[a-z]/.test(letter)) {
word += letter;
} else {
addWord(words, word);
View
@@ -5,7 +5,6 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
var CleanCss = _interopDefault(require('clean-css'));
var rework = _interopDefault(require('rework'));
var glob = _interopDefault(require('glob'));
var prepack = require('prepack');
var domain;
@@ -667,14 +666,20 @@ var CssTreeWalker = function (_EventEmitter) {
var UglifyJS = require("uglify-js");
var fs$1 = require("fs");
var compressCode = function compressCode(code) {
var compressedCode = code;
try {
var prepackedCode = prepack.prepack(code).code;
compressedCode = UglifyJS.minify(prepackedCode).code;
// Try to minimize the code as much as possible, removing noise.
var ast = UglifyJS.parse(code);
ast.figure_out_scope();
var compressor = UglifyJS.Compressor({ warnings: false });
ast = ast.transform(compressor);
ast.figure_out_scope();
ast.compute_char_frequency();
ast.mangle_names({ toplevel: true });
code = ast.print_to_string().toLowerCase();
} catch (e) {
// If compression fails, assume it's not a JS file and return the full code.
}
return compressedCode.toLowerCase();
return code.toLowerCase();
};
var concatFiles = function concatFiles(files, options) {
@@ -779,7 +784,7 @@ var getAllWordsInContent = function getAllWordsInContent(content) {
html: true,
body: true
};
var words = content.split(/[^a-z-]/g);
var words = content.split(/[^a-z]/g);
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
@@ -836,7 +841,7 @@ var getAllWordsInSelector = function getAllWordsInSelector(selector) {
skipNextWord = true;
continue;
}
if (/[a-z-]/.test(letter)) {
if (/[a-z]/.test(letter)) {
word += letter;
} else {
addWord(words, word);
View
@@ -8,7 +8,6 @@
"dependencies": {
"clean-css": "^4.0.12",
"glob": "^7.1.1",
"prepack": "0.2.2",
"rework": "^1.0.1",
"uglify-js": "^3.0.6",
"yargs": "^8.0.1"
@@ -8,7 +8,7 @@ export const getAllWordsInContent = content => {
html: true,
body: true
}
const words = content.split(/[^a-z-]/g)
const words = content.split(/[^a-z]/g)
for (let word of words) {
used[word] = true
}
@@ -36,7 +36,7 @@ export const getAllWordsInSelector = selector => {
skipNextWord = true
continue
}
if (/[a-z-]/.test(letter)) {
if (/[a-z]/.test(letter)) {
word += letter
} else {
addWord(words, word)
View
@@ -1,17 +1,22 @@
const UglifyJS = require("uglify-js")
const fs = require("fs")
import glob from "glob"
import { prepack } from "prepack"
const compressCode = code => {
let compressedCode = code
try {
const prepackedCode = prepack(code).code
compressedCode = UglifyJS.minify(prepackedCode).code
// Try to minimize the code as much as possible, removing noise.
let ast = UglifyJS.parse(code)
ast.figure_out_scope()
let compressor = UglifyJS.Compressor({ warnings: false })
ast = ast.transform(compressor)
ast.figure_out_scope()
ast.compute_char_frequency()
ast.mangle_names({ toplevel: true })
code = ast.print_to_string().toLowerCase()
} catch (e) {
// If compression fails, assume it's not a JS file and return the full code.
}
return compressedCode.toLowerCase()
return code.toLowerCase()
}
export const concatFiles = (files, options) =>
@@ -26,6 +31,7 @@ export const concatFiles = (files, options) =>
return `${total}${code} `
}, "")
export const getFilesFromPatternArray = fileArray => {
let sourceFiles = {}
for (let string of fileArray) {

0 comments on commit e67bcf6

Please sign in to comment.