jstransformer-terser
v0.2.2
Published
Sync and Async Terser support for JSTransformers.
Downloads
77
Readme
jstransformer-terser
Sync and Async Terser support for JSTransformers.
Minifies javascript using terser via jstransformers.
Install
# install using npm
npm install --save jstransformer-terser terser
# install using yarn
yarn add jstransformer-terser terser
API
This transformer supports render
, renderAsync
, renderFile
and renderFileAsync
.
All according to the jstransformer API definition.
var terserTransformer = require('jstransformer')(require('jstransformer-terser'));
// SYNC
const result = terserTransformer.render('function add(first, second) { return first + second; }');
console.log(result.body);
//=> 'function add(n,d){return n+d;}'
// ASYNC (Promise API)
terserTransformer
.renderAsync('function add(first, second) { return first + second; }')
.then(result => console.log(result.body));
//=> 'function add(n,d){return n+d;}'
// ASYNC (Callback API)
terserTransformer.renderAsync('function add(first, second) { return first + second; }', {}, (err, result) => {
if (err) console.error(err);
else console.log(result.body);
});
//=> 'function add(n,d){return n+d;}'
Development
Requirements: node.js >=14, yarn >=1.22
# build using tsc
yarn build
# watch and rebuild
yarn build:watch
# lint using prettier and eslint
yarn lint
# test using jest
yarn test
# watch and retest
yarn test:watch
# open coverage in default browser
yarn coverage:open
# check everything
yarn preflight