reduce-enum-webpack-plugin
v1.0.0
Published
将ts enum 转 js 的产物减少一半,e[e['xxx']=0]='xxx'] => e['xxx']=0,e[e.xxx=0]='xxx' => e.xxx=0
Downloads
7
Maintainers
Readme
English | 中文
About
A Webpack Plugin to reduce ts enum to js artifacts
eg:
before add plugin:
enum Status {
PAID,
UN_PAID
}
// =>
var Status;
(function (Status) {
Status[Status.PAID = 0] = 'PAID'
Status[Status.UN_PAID = 1] = 'UN_PAID'
})(Status || (Status = {}))
after add plugin:
enum Status {
PAID,
UN_PAID
}
// =>
var Status = {
PAID: 0,
UN_PAID: 1
}
`ts
📦 Install
pnpm add reduce-enum-webpack-plugin -D
# or
yarn add reduce-enum-webpack-plugin -D
# or
npm i reduce-enum-webpack-plugin -D
🔨 Usage
const RuduceEnumWebpackPlugin = require('reduce-enum-webpack-plugin').default
// webpack.config.js
module.exports = {
plugins: [
isProduction && new RuduceEnumWebpackPlugin()
],
}
📄 License
reduce-enum-webpack-plugin is MIT licensed.