0.2.2 • Published 3 years ago

jstransformer-terser v0.2.2

Weekly downloads
12
License
MIT
Repository
github
Last release
3 years ago

jstransformer-terser

Sync and Async Terser support for JSTransformers.

Minifies javascript using terser via jstransformers.

npm Package Version Package Dependencies Coveralls github GitHub Workflow Status (branch) GitHub Repo License MIT


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

License and Author

MIT © Simon Lepel

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago