{"id":18938204,"url":"https://github.com/wechat-miniprogram/babel-preset-miniprogram","last_synced_at":"2025-04-15T19:30:21.445Z","repository":{"id":50253635,"uuid":"316235012","full_name":"wechat-miniprogram/babel-preset-miniprogram","owner":"wechat-miniprogram","description":"微信小程序 babel 构建环境预设","archived":false,"fork":false,"pushed_at":"2025-02-07T11:44:13.000Z","size":134,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T19:21:46.926Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wechat-miniprogram.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-11-26T13:11:20.000Z","updated_at":"2025-02-24T11:00:23.000Z","dependencies_parsed_at":"2024-10-24T17:18:46.361Z","dependency_job_id":null,"html_url":"https://github.com/wechat-miniprogram/babel-preset-miniprogram","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"7b7fd30091f460abcaab14be14f510db8c7613c4"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechat-miniprogram%2Fbabel-preset-miniprogram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechat-miniprogram%2Fbabel-preset-miniprogram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechat-miniprogram%2Fbabel-preset-miniprogram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechat-miniprogram%2Fbabel-preset-miniprogram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wechat-miniprogram","download_url":"https://codeload.github.com/wechat-miniprogram/babel-preset-miniprogram/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249138484,"owners_count":21218894,"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":[],"created_at":"2024-11-08T12:13:42.736Z","updated_at":"2025-04-15T19:30:21.215Z","avatar_url":"https://github.com/wechat-miniprogram.png","language":"JavaScript","readme":"# babel-preset-miniprogram\n\n微信小程序 babel 构建环境预设\n\n## 安装\n\n```bash\nnpm install --save-dev babel-preset-miniprogram\n```\n\n## 使用\n\n```javascript\n// babel.config.js\nmodule.exports = {\n  presets: [\n    [\n      'babel-preset-miniprogram',\n      {\n        wechatLibVersion: '2.14.0', // 指定小程序最低基础库版本\n        useBuiltIns: 'usage', // 打入 Polyfill\n        modules: 'cjs', // 将代码转义为 commonjs\n      },\n    ],\n  ],\n};\n```\n\n## 配置项\n\n### `wechatLibVersion: string`\n指定构建小程序的目标最低[基础库版本](https://developers.weixin.qq.com/miniprogram/dev/framework/client-lib/version.html)，可以在 [小程序管理页](https://mp.weixin.qq.com/) 【设置】-【基本设置】-【基础库最低版本设置】中设置你的小程序最低版本\n\n其余配置项可直接使用 [`@babel/preset-env`配置项](https://babeljs.io/docs/en/babel-preset-env#options)\n\n## 实现\n\n由于小程序基础库版本会与小程序[运行环境](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/env.html)版本绑定，因此特定小程序基础库可能的运行环境是确定的。\n该预设便是利用该信息，只将运行环境必要的转义和 Polyfill 设置给 `@babel/preset-env`，从而尽可能减少编译处理和小程序代码体积。\n\n另外由于小程序基础库本身自带了一个 [Polyfill](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/js-support.html)，该预设也会避免打入不必要的 Polyfill。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechat-miniprogram%2Fbabel-preset-miniprogram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwechat-miniprogram%2Fbabel-preset-miniprogram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechat-miniprogram%2Fbabel-preset-miniprogram/lists"}