Skip to content

Commit

Permalink
Merge branch 'master' into feature/newer-typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
developit committed Jan 26, 2018
2 parents a1d926f + 2413292 commit edf2975
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
16 changes: 7 additions & 9 deletions package.json
Expand Up @@ -36,36 +36,34 @@
"author": "Jason Miller <jason@developit.ca> (http://jasonformat.com)",
"license": "MIT",
"dependencies": {
"acorn-jsx": "4.1.0",
"asyncro": "^2.0.1",
"acorn-jsx": "^4.1.1",
"asyncro": "^3.0.0",
"autoprefixer": "^7.2.5",
"babel-polyfill": "^6.26.0",
"camelcase": "^4.1.0",
"chalk": "^2.3.0",
"es6-promisify": "^5.0.0",
"exorcist": "^1.0.0",
"glob": "^7.1.2",
"gzip-size": "^4.1.0",
"pretty-bytes": "^4.0.2",
"regenerator-runtime": "^0.11.1",
"rollup": "^0.55.0",
"rollup": "^0.55.1",
"rollup-plugin-buble": "^0.18.0",
"rollup-plugin-bundle-size": "^1.0.1",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-es3": "^1.1.0",
"rollup-plugin-flow": "^1.1.1",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-plugin-nodent": "^0.1.3",
"rollup-plugin-postcss": "^1.2.6",
"rollup-plugin-nodent": "github:developit/rollup-plugin-nodent",
"rollup-plugin-postcss": "^1.2.7",
"rollup-plugin-preserve-shebang": "^0.1.6",
"rollup-plugin-sizes": "^0.4.2",
"rollup-plugin-strict-alias": "^1.0.0",
"rollup-plugin-typescript": "^0.8.1",
"rollup-plugin-uglify": "^2.0.1",
"rollup-plugin-uglify": "^3.0.0",
"sade": "^1.3.1",
"tslib": "^1.9.0",
"typescript": "^2.6.2",
"uglify-es": "^3.3.6"
"typescript": "^2.6.2"
},
"devDependencies": {
"babel-cli": "^6.26.0",
Expand Down
55 changes: 31 additions & 24 deletions src/index.js
Expand Up @@ -21,7 +21,6 @@ import typescript from 'rollup-plugin-typescript';
import flow from './lib/flow-plugin';
import camelCase from 'camelcase';

const interopRequire = m => m.default || m;
const readFile = promisify(fs.readFile);
const stat = promisify(fs.stat);
const isDir = name => stat(name).then( stats => stats.isDirectory() ).catch( () => false );
Expand Down Expand Up @@ -259,32 +258,40 @@ function createConfig(options, entry, format, writeMeta) {
// [`export default ${rollupName};`]: '',
// [`var ${rollupName} =`]: 'export default'
// }),
options.compress!==false && uglify({
output: { comments: false },
mangle: {
options.compress!==false && [
uglify({
output: { comments: false },
compress: {
keep_infinity: true,
pure_getters: true
},
warnings: true,
ecma: 5,
toplevel: format==='cjs' || format==='es',
properties: mangleOptions ? {
regex: mangleOptions.regex ? new RegExp(mangleOptions.regex) : null,
reserved: mangleOptions.reserved || []
} : false
},
nameCache
}, format==='es' ? interopRequire(require('uglify-es')).minify : undefined),
mangleOptions && {
// before hook
options() {
try {
nameCache = JSON.parse(fs.readFileSync(resolve(options.cwd, 'mangle.json'), 'utf8'));
}
catch (e) {}
},
// after hook
onwrite() {
if (writeMeta && nameCache) {
fs.writeFile(resolve(options.cwd, 'mangle.json'), JSON.stringify(nameCache, null, 2), Object);
mangle: {
properties: mangleOptions ? {
regex: mangleOptions.regex ? new RegExp(mangleOptions.regex) : null,
reserved: mangleOptions.reserved || []
} : false
},
nameCache
}),
mangleOptions && {
// before hook
options() {
try {
nameCache = JSON.parse(fs.readFileSync(resolve(options.cwd, 'mangle.json'), 'utf8'));
}
catch (e) {}
},
// after hook
onwrite() {
if (writeMeta && nameCache) {
fs.writeFile(resolve(options.cwd, 'mangle.json'), JSON.stringify(nameCache, null, 2), Object);
}
}
}
},
],
{ ongenerate({ bundle }, { code }) {
config._code = bundle._code = code;
} },
Expand Down
4 changes: 2 additions & 2 deletions src/lib/flow-plugin.js
Expand Up @@ -5,8 +5,8 @@ export default function fixedFlow(options) {
return Object.assign({}, plugin, {
transform(code, id) {
let ret = plugin.transform(code, id);
if (ret.code===code) return null;
if (ret && ret.code===code) return null;
return ret;
}
});
}
}

0 comments on commit edf2975

Please sign in to comment.