https://github.com/simbo/jstransformer-terser
Sync and Async Terser support for JSTransformers.
https://github.com/simbo/jstransformer-terser
jstransformer minify terser
Last synced: 2 months ago
JSON representation
Sync and Async Terser support for JSTransformers.
- Host: GitHub
- URL: https://github.com/simbo/jstransformer-terser
- Owner: simbo
- License: mit
- Created: 2020-12-21T02:54:31.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-27T19:01:00.000Z (over 4 years ago)
- Last Synced: 2025-02-23T04:24:52.239Z (3 months ago)
- Topics: jstransformer, minify, terser
- Language: TypeScript
- Homepage:
- Size: 274 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jstransformer-terser
Sync and Async [Terser](https://github.com/terser/terser) support for [JSTransformers](http://github.com/jstransformers).
> Minifies javascript using terser via jstransformers.
[](https://www.npmjs.com/package/jstransformer-terser)
[](https://www.npmjs.com/package/jstransformer-terser?activeTab=dependencies)
[](https://coveralls.io/github/simbo/jstransformer-terser)
[](https://github.com/simbo/jstransformer-terser/actions?query=workflow%3ACI)
[](https://github.com/simbo/jstransformer-terser)
[](http://simbo.mit-license.org/)---
## Install
```sh
# 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](https://github.com/jstransformers/jstransformer#api) definition.```js
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
```sh
# 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](http://simbo.mit-license.org/)