GitHub - openpeeps/squeezy: A dead simple JavaScript and CSS validator, bundler and minifier · GitHub
Skip to content
openpeepsPublic

Latest commit

 

History

35 Commits

Folders and files

Repository files navigation

Squeezy Logo
A dead simple JavaScript and CSS validator, bundler and minifier

nimble install squeezy / clue install squeezy --build

API reference
Github Actions Github Actions

😍 Key Features

  • High-performance minifier built with Nim lang 👑
  • Validate, Bundle and minify CSS and JavaScript assets
  • CLI with css and bundle commands (stdlib only, no dependencies)
  • Node-style resolution: bare specifiers, node_modules, package.json (exports/main/module), --external
  • Source map generation for JavaScript
  • Identifier mangling for JavaScript
  • Inline Minifier for HTML / CSS / JavaScript (fastest, no parsing, no validation)
  • Built on top of pkg/sweetsyntax & pkg/openparser/css

Examples

Check in the examples directory and the unit tests

CLI

A dead simple JavaScript and CSS validator, bundler and minifier
  (c) OpenPeeps | MIT License
  Build Version: 0.1.0

usage: squeezy <command> [args] [options]

Commands
  css <input.css> [-o output]      minify CSS, inlines @import
  bundle <entry.js> [-o output]    bundle JS, resolves imports

CSS options
  -o, --out <file>                 write to file instead of stdout
      --preserve-comments          keep comments

Bundle options
  -o, --out <file>                 write to file instead of stdout
      --minify                     minify JS output
      --mangle                     mangle JS identifiers, implies minify
      --sourcemap                  emit a source map next to output, es format only
      --format <fmt>               es, cjs, iife, umd, amd, system (default es)
      --name <name>                module name for iife and umd wrappers
      --preserve-comments          keep comments
      --external <a,b>             leave these bare imports untouched
      --node-path <dir>            extra node_modules lookup dir

  -h, --help                       show this help
  --version                        show version

aliases: minify for css, js for bundle
examples:
  squeezy css styles.css -o styles.min.css
  squeezy bundle app.js -o bundle.js --minify --mangle

Examples

# minify CSS (@import gets inlined)
squeezy css styles.css -o styles.min.css

# bundle JS, with optional minification
squeezy bundle app.js -o bundle.js --minify --mangle

# other bundle options
squeezy bundle app.js -o bundle.js --format=iife --name=MyLib --sourcemap
squeezy bundle app.js -o bundle.js --external react,react-dom --node-path ./shared
squeezy --help

Roadmap

  • Fix module graph: follow export ... from re-exports, then dynamic import() / require() (done)
  • check command wiring up the existing validator
  • CSS correctness: conditional @import, url() rebasing, then CSS source maps
  • Decide treeShake: implement (with bundle-wide mangling) or remove the flag
  • Bare-specifier / node_modules resolution (done: exports/main/module fields, scoped packages, --external, --node-path, NODE_PATH)
  • JS source maps for wrapped formats
  • CLI: html command, stdin input, --watch mode
  • Close the esbuild size gap, measured against the existing bench

Benchmarks

Comparing Squeezy vs ESBuild (on d3.js library ~ 20k lines)

  [OK] dependencies available
  [OK] build bench runner

  Output sizes:

    Original:              587043 bytes
    squeezy-inline:        420081 bytes
    squeezy-bundle:        413739 bytes
    squeezy-bundle+mangle: 360824 bytes
    esbuild:               281878 bytes
  [OK] output size comparison + save

  squeezy-inline:
    Time (mean ± σ):      13.5 ms ±   0.8 ms    [User: 10.3 ms, System: 2.1 ms]
    Range (min … max):    11.9 ms …  17.3 ms    156 runs
  squeezy-bundle:
    Time (mean ± σ):      93.7 ms ±   5.1 ms    [User: 84.0 ms, System: 7.8 ms]
    Range (min … max):    88.6 ms … 111.4 ms    31 runs
  squeezy-bundle+mangle:
    Time (mean ± σ):     102.0 ms ±   6.8 ms    [User: 91.5 ms, System: 8.7 ms]
    Range (min … max):    95.2 ms … 127.7 ms    27 runs
  esbuild:
    Time (mean ± σ):      63.9 ms ±   4.0 ms    [User: 50.8 ms, System: 14.5 ms]
    Range (min … max):    58.9 ms …  77.5 ms    39 runs
  [OK] hyperfine benchmark

❤ Contributions & Support

🎩 License

MIT license. Made by Humans from OpenPeeps.
Copyright OpenPeeps & Contributors — All rights reserved.

Releases

Packages

Contributors

Languages

Generated from openpeeps/pistachio