From 5b28b9ad26b557df2cb9d4b55d0996a39f1fc538 Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Sat, 7 Nov 2020 14:38:44 +0300 Subject: [PATCH] browserify => rollup.js --- .eslintrc.yml | 1 + lib/deflate.js | 10 ++++++---- lib/inflate.js | 10 ++++++---- package.json | 9 ++++++--- rollup.config.js | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 rollup.config.js diff --git a/.eslintrc.yml b/.eslintrc.yml index 11b4d5d..5dd220c 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -12,6 +12,7 @@ globals: ignorePatterns: - coverage/ - dist/ + - rollup.config.js rules: accessor-pairs: 2 diff --git a/lib/deflate.js b/lib/deflate.js index efeb00c..07f437f 100644 --- a/lib/deflate.js +++ b/lib/deflate.js @@ -394,7 +394,9 @@ function gzip(input, options) { } -exports.Deflate = Deflate; -exports.deflate = deflate; -exports.deflateRaw = deflateRaw; -exports.gzip = gzip; +module.exports = { + Deflate: Deflate, + deflate: deflate, + deflateRaw: deflateRaw, + gzip: gzip +}; diff --git a/lib/inflate.js b/lib/inflate.js index 7535d15..21bbc5b 100644 --- a/lib/inflate.js +++ b/lib/inflate.js @@ -417,7 +417,9 @@ function inflateRaw(input, options) { **/ -exports.Inflate = Inflate; -exports.inflate = inflate; -exports.inflateRaw = inflateRaw; -exports.ungzip = inflate; +module.exports = { + Inflate: Inflate, + inflate: inflate, + inflateRaw: inflateRaw, + ungzip: inflate +}; diff --git a/package.json b/package.json index 2efe2d0..62b69a7 100644 --- a/package.json +++ b/package.json @@ -27,17 +27,20 @@ "scripts": { "lint": "eslint .", "test": "npm run lint && mocha", - "coverage": "npm run lint && nyc mocha && nyc report --reporter html" + "coverage": "npm run lint && nyc mocha && nyc report --reporter html", + "build": "rollup -c" }, "devDependencies": { - "browserify": "^16.2.3", + "@rollup/plugin-commonjs": "^16.0.0", + "@rollup/plugin-node-resolve": "^10.0.0", "buffer-from": "^1.1.1", "eslint": "^7.13.0", "mocha": "^8.2.1", "multiparty": "^4.1.3", "ndoc": "^5.0.1", "nyc": "^15.1.0", - "uglify-js": "=3.4.8" + "rollup": "^2.33.1", + "rollup-plugin-terser": "^7.0.2" }, "dependencies": {} } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..39df778 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,39 @@ +import nodeResolve from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; +import pkg from './package.json'; +import { terser } from 'rollup-plugin-terser'; + +const banner = { + banner() { + return `/*! ${pkg.name} ${pkg.version} https://github.com/${pkg.repository} @license ${pkg.license} */`; + } +} + +const plugins = [ nodeResolve(), commonjs(), banner ]; + +export default [ + { + input: 'index.js', + output: [ + { file: 'dist/pako.js', format: 'umd', name: 'pako' }, + { file: 'dist/pako.min.js', format: 'umd', name: 'pako', plugins: [ terser() ] } + ], + plugins: plugins + }, + { + input: 'lib/deflate.js', + output: [ + { file: 'dist/pako_deflate.js', format: 'umd', name: 'pako' }, + { file: 'dist/pako_deflate.min.js', format: 'umd', name: 'pako', plugins: [ terser() ] } + ], + plugins: plugins + }, + { + input: 'lib/inflate.js', + output: [ + { file: 'dist/pako_inflate.js', format: 'umd', name: 'pako' }, + { file: 'dist/pako_inflate.min.js', format: 'umd', name: 'pako', plugins: [ terser() ] } + ], + plugins: plugins + } +];