demin
v0.2.2
Published
De-minifier for some compiled AMD files
Downloads
2
Readme
Demin
Demin is a node CLI application for de-minifying (de-compiling) compiled AMD files. Demin does not guarantee that output code that executes identically to the source file; do not expect the code to export. The intent is to produce somewhat-readable code.
Example Transformation
define("module",["require","exports","tslib"],function(e,r,i){r.default=i.__assign({},{idk:!0,yo:void 0})})
define("another",["require","exports","module","lib/wrapper","vendor/wrapper"],function(e,r,i,o,d){r.default=o.wrap(d.wrap(i))})
becomes
/* module.js */
import * as Tslib from 'tslib'
var P = {
idk: true,
yo: undefined,
}
exports.default = Tslib.__assign({}, P)
/* another.js */
import * as Wrapper from 'lib/wrapper'
import * as Wrapper1 from 'vendor/wrapper'
import * as Module from 'module'
exports.default = Wrapper.wrap(Wrapper1.wrap(Module))
Features
Current features:
- change required module names from
define
to ES6 moduleimport
statements - change
!0
,!1
, andvoid 0
to their typical identifierstrue
,false
, andundefined
- run Prettier
Currently-planned features:
- get nearly all
require
calls converted toimport
statements - change
exports.default =
andexports.name =
calls to ES6 moduleexport default
andexport const
calls. - remove the comma operator when possible (e.g.
return a(), b(), c();
→a(); b(); return c();
) - change
*.createElement
calls to JSX syntax
Installation
npm install -g demin
This installs demin
to your $PATH
, so you can call it like the example usage below.
Uninstall
npm uninstall -g demin
Usage
Suggested usage:
demin -i file.js -o output --clean --prettier
(note: --prettier
is pretty slow if you have many output files or large files)
Minimal usage:
demin -i file.js -o output
All options:
See demin --help
for all options
(you probably don't want to mix --dry
and --quiet
because that's useless)