{"id":19935571,"url":"https://github.com/baozouai/babel-plugin-enum-to-object","last_synced_at":"2025-05-03T12:31:24.631Z","repository":{"id":153351819,"uuid":"629009323","full_name":"baozouai/babel-plugin-enum-to-object","owner":"baozouai","description":"transform enum to const object","archived":false,"fork":false,"pushed_at":"2023-04-22T14:24:51.000Z","size":40,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T15:54:35.390Z","etag":null,"topics":["babel-plugin","enum","object","optimize","treeshaking"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/babel-plugin-enum-to-object","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baozouai.png","metadata":{"files":{"readme":"README-zh_CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-17T12:43:42.000Z","updated_at":"2024-07-02T07:53:27.000Z","dependencies_parsed_at":"2023-09-04T10:18:33.143Z","dependency_job_id":null,"html_url":"https://github.com/baozouai/babel-plugin-enum-to-object","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baozouai%2Fbabel-plugin-enum-to-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baozouai%2Fbabel-plugin-enum-to-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baozouai%2Fbabel-plugin-enum-to-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baozouai%2Fbabel-plugin-enum-to-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baozouai","download_url":"https://codeload.github.com/baozouai/babel-plugin-enum-to-object/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251981848,"owners_count":21675082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel-plugin","enum","object","optimize","treeshaking"],"created_at":"2024-11-12T23:20:41.840Z","updated_at":"2025-05-03T12:31:24.625Z","avatar_url":"https://github.com/baozouai.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cp align=\"center\"\u003e\n\u003ch1 align=\"center\"\u003ebabel-plugin-enum-to-object\u003c/h1\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![NPM version][npm-image]][npm-url] ![NPM downloads][download-image]\n\n![Test][test-badge] ![codecov][codecov-badge]\n\n\n[npm-image]: https://img.shields.io/npm/v/babel-plugin-enum-to-object.svg?style=flat-square\n[npm-url]: http://npmjs.org/package/babel-plugin-enum-to-object\n\n\n[download-image]: https://img.shields.io/npm/dm/babel-plugin-enum-to-object.svg?style=flat-square\n\n\n\n[test-badge]: https://github.com/baozouai/babel-plugin-enum-to-object/actions/workflows/ci.yml/badge.svg\n\n[codecov-badge]: https://codecov.io/github/baozouai/babel-plugin-enum-to-object/branch/master/graph/badge.svg\n\n\n\u003c/div\u003e\n\n\n中文 | [英文](./README.md)\n\n## 关于\n\n一个用来将 ts enum 转 js 对象的 babel 插件，使没使用到的 enum 能全部shaking 掉\n\neg:\n\n没加插件前：\n```ts\nenum Status {\n  PAID,\n  UN_PAID\n}\n\n// =\u003e\n\nvar Status;\n(function (Status) {\n  Status[Status.PAID = 0] = 'PAID'\n  Status[Status.UN_PAID = 1] = 'UN_PAID'\n})(Status || (Status = {}))\n```\n\n加插件后：\n```ts\nenum Status {\n  PAID,\n  UN_PAID\n}\n\n// =\u003e\n\n// 默认 reflect 是 true\nconst Status = {\n  PAID: 0,\n  0: 'PAID',\n  UN_PAID: 1,\n  1: 'UN_PAID'\n}\n//  设置 reflect 为false\nconst Status = {\n  PAID: 0,\n  UN_PAID: 1,\n}\n```\n\n\n## 📦  安装\n\n```sh\npnpm add babel-plugin-enum-to-object -D\n# or\nyarn add babel-plugin-enum-to-object -D\n# or\nnpm i babel-plugin-enum-to-object -D\n```\n\n ## 🔨 使用\n\n```js\n\n\n// babel.config.js\n\nmodule.exports = {\n\n  plugins: [\n    // 如果是生产环境，添加这一行\n    ['enum-to-object', { reflect: true or false }]\n  ],\n}\n```\n## 📄 License\n\nbabel-plugin-enum-to-object is [MIT licensed](./LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaozouai%2Fbabel-plugin-enum-to-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaozouai%2Fbabel-plugin-enum-to-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaozouai%2Fbabel-plugin-enum-to-object/lists"}