项目作者: jared-hughes

项目描述 :
Demin is a node CLI application for de-minifying (de-compiling) compiled AMD (?) files
高级语言: TypeScript
项目地址: git://github.com/jared-hughes/demin.git
创建时间: 2021-04-11T19:44:31Z
项目社区:https://github.com/jared-hughes/demin

开源协议:

下载


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

  1. define("module",["require","exports","tslib"],function(e,r,i){r.default=i.__assign({},{idk:!0,yo:void 0})})
  2. define("another",["require","exports","module","lib/wrapper","vendor/wrapper"],function(e,r,i,o,d){r.default=o.wrap(d.wrap(i))})

becomes

  1. /* module.js */
  2. import * as Tslib from 'tslib'
  3. var P = {
  4. idk: true,
  5. yo: undefined,
  6. }
  7. exports.default = Tslib.__assign({}, P)
  8. /* another.js */
  9. import * as Wrapper from 'lib/wrapper'
  10. import * as Wrapper1 from 'vendor/wrapper'
  11. import * as Module from 'module'
  12. exports.default = Wrapper.wrap(Wrapper1.wrap(Module))

Features

Current features:

  • change required module names from define to ES6 module import statements
  • change !0, !1, and void 0 to their typical identifiers true, false, and undefined
  • run Prettier

Currently-planned features:

  • get nearly all require calls converted to import statements
  • change exports.default = and exports.name = calls to ES6 module export default and export 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

  1. npm install -g demin

This installs demin to your $PATH, so you can call it like the example usage below.

Uninstall

  1. 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)