Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fang/terser

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fang/terser

Compress Javascript files using Terser.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

fang-starter-plugin

Compress Javascript files using Terser.

Summary

  • About
  • Features
  • Requirements
  • Installation
  • Examples
  • Changelog

About

I created this plugin to be able to compress Javascript files. Terser is the most popular and currently maintained Javascript compression tool, and I wanted fang to have an official plugin for it.

Features

Requirements

Having @fang/core installed on version 0.*.

Installation

  • Using NPM: npm install --save-dev @fang/terser
  • Using Yarn: yarn add --dev @fang/terser

Examples

1. Compress a Javascript file

This example assumes you have a example/code.js file containing your code, and you want to output a compressed code in example/dist/js/code.js.

// script.js
const { run } = require("@fang/core");
const save = require("@fang/save");
const terser = require("@fang/terser");

const js = {
  name: "Javascript",
  input: "example/code.js",
  tasks: [
    terser(),
    save({
      folder: "example/dist/js",
    }),
  ],
};

const main = async () => await run([js]);

main();

Run your script, and you should see something like this in the console.

$ node script.js
fang: start
8 CPUs core(s)
1 tasks to run
Javascript: start
Javascript: 30.604ms
fang: 183.533ms

2. Customize how Terser compress your file

This examples assumes you havbe a example/code.js file containing your code, and your want to output a compressed code in example/dist/js/code.js.

// script.js
const { run } = require("@fang/core");
const save = require("@fang/save");
const terser = require("../lib");

const js = {
  name: "Javascript",
  input: "example/code.js",
  tasks: [
    terser({
      compress: {
        passes: 5,
        unsafe: true,
        pure_getters: true,
      },
      toplevel: true,
    }),
    save({
      folder: "example/dist/js",
    }),
  ],
};

const main = async () => await run([js]);

main();

Run node script.js, and you should see something like this in your console.

$ node script.js
fang: start
8 CPUs core(s)
1 tasks to run
Javascript: start
Javascript: 37.211ms
fang: 168.672ms

Keywords

FAQs

Package last updated on 18 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc