github.com/sam0x17/es6-minifier

A self-contained crystal shard that can minify ES6+ JavaScript.

2 stars
0 dependents
License: MIT

Nothing has been indexed for 0.1.2 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  es6-minifier:
    github: sam0x17/es6-minifier
    version: ~> 0.1.2

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.1.2. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

es6-minifier

Embeds Terser (current standard es6 minification tool in the NPM ecosystem) in a crystal shard via a cross-platform pkg-powered binary that embeds Terser in a lightweight portable nodejs environment. No nodejs required.

Usage

Just install the shard and you can minify your ES6+ Javascript as follows:

require "es6-minifier"

Es6Minifier.minify!("const  something = 3;") # => "const something=3;"

Es6Minifier.minify!(["file1.js", "file2.js"])
# file1.js and file2.js are overwritten with a minified version of their contents

If a parsing or IO error occurs, Es6Minifier.minify! will throw an error.

Right now there are no configurable options however this could be easily added by passing JSON options to minify.js and adding a bit of code on the crystal side. Pull requests welcome!

Currently supports linux, macos, and alpine. Could easily support FreeBSD and Windows with a several line change.

Installation

Just add the following to yoour shard.yml:

dependencies:
  es6-minifier:
    github: sam0x17/es6-minifier