Package: crimp
crimpA JavaScript minifier command-line utility written fully in Python; usescalmjs.parseas the underlying library.Introductioncrimpserves as the front-end tocalmjs.parse.Both these libraries had their origin inslimit, a package that
provided a Python based solution for handling JavaScript code, which is
often used for situations where the usage of commonly used minifiers,
which are typically written in Node.js, is impractical from a pure
Python environment.  However,slimithad not been maintained for a
number of years.  As of 2017, with many issues that impacted the
correctness of the generated code remain outstanding,calmjs.parsewas
forked fromslimit, andcrimpwas created as a front end for the
former.InstallationThe following command may be executed to source the latest stable
version ofcrimpwheel from PyPI for installation into the current
Python environment.$pipinstallcrimpUsageAscrimpis a package that offers a command of the same name,
executing the command after installation with the--helpflag will
reveal the options that are available.$ crimp --help
usage: crimp [input_file [input_file ...]] [-h] [-O <output_path>] [-m] [-p]
             [-s [<sourcemap_path>]] [--version] [-o] [--drop-semi]
             [--indent-width n] [--encoding <codec>]

positional arguments:
  input_file            path(s) to input file(s)

optional arguments:
  -h, --help            show this help message and exit
  -O <output_path>, --output-path <output_path>
                        output file path
  -m, --mangle          enable all basic mangling options
  -p, --pretty-print    use pretty printer (omit for minify printer)
  -s [<sourcemap_path>], --source-map [<sourcemap_path>]
                        enable source map; filename defaults to
                        <output_path>.map, if identical to <output_path> it
                        will be written inline as a data url
  --version             show version information
  --indent-width n      indentation width for pretty printer
  --encoding <codec>    the encoding for file-based I/O; stdio relies on
                        system locale

basic mangling options:
  -o, --obfuscate       obfuscate (mangle) names
  --drop-semi           drop unneeded semicolons (minify printer only)Typically, the program will be invoked with a single or multiple input
files (if they are to be combined into a single file), and optionally
with the-mflag to denote that it is safe to have all the mangle
options enabled.Please note that all input filesmustbe listed before the flags, as
this forced grouping of all input files result in a less ambiguous
listing of files, given that there are flags for specifying target
output files, which will be overwritten without prompt.Standard pretty/minified printingTo minify some file:$ crimp project.js -O project.min.jsTo minify some file with just variable name obfuscation:$ crimp project.js -m -O project.min.jsPretty printing the minified file back onto stdout:$ crimp project.min.js -pReading input from stdin and writing out to a file.  Note that if a
SIGINT (typically Ctrl-C or Ctrl-Break), the output file will not be
opened for writing.$ crimp -O demo.jsSource map generationFor source map generation, enable the-sflag.$ crimp project.js -O project.min.js -sThe above will write out the source map file asproject.min.js.map,
and the reference to that (thesourceMappingURL) will also be
appended to the output file as a comment.  To specify a specific
location, pass the name as a parameter.$ crimp project.js -O project.min.js -s project.min.mapInline source maps (where thesourceMappingURLis the data URL of
the base64 encoding of the JSON serialization of the source map) are
supported; these can be produced by supplying the argument with the same
name used for the output file, like so:$ crimp project.js -O project.min.js -s project.min.jsTroubleshootingParsing a moderately sized file takes 10x as much time as uglifyjsThis is due to the implementation done bycalmjs.parseas a set of
generator functions that produce very minimum output, and that the
standard Python implementation has a very high overhead performance cost
for function calls.  The advantage with that approach is that maximum
flexibility can be achieved (due to the ease of which unparsing
workflows can be set up), while the drawback is obvious.ContributeIssue Tracker:https://github.com/calmjs/crimp/issuesSource Code:https://github.com/calmjs/crimpLegalThecrimppackage is copyright (c) 2017 Auckland Bioengineering
Institute, University of Auckland.  Thecrimppackage is licensed
under the MIT license (specifically, the Expat License).Changelog1.0.1 - 2018-08-11Bumping minimum version ofcalmjs.parseto1.1.1, which
includes fixes to:Line continuation in JavaScript sources should no longer break
source map line counting.  [calmjs.parse#16]Will no longer parse certain incorrectly unterminated statements as
valid JavaScript.  [calmjs.parse#18]Obfuscated minifier should no longer truncate certain closing braces
as the internal accounting is corrected.  [calmjs.parse#19]1.0.0 - 2017-09-26Initial release.