{"id":13671364,"url":"https://github.com/lin-xi/babel-plugin-import-fix","last_synced_at":"2025-06-17T10:41:13.150Z","repository":{"id":71694832,"uuid":"99097995","full_name":"lin-xi/babel-plugin-import-fix","owner":"lin-xi","description":"alter import module to certain module file path for smaller bundle and better performance ","archived":false,"fork":false,"pushed_at":"2018-01-06T06:28:26.000Z","size":37,"stargazers_count":37,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-22T09:19:52.751Z","etag":null,"topics":["babel-plugin","babelrc","tree-shaking"],"latest_commit_sha":null,"homepage":"","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/lin-xi.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}},"created_at":"2017-08-02T09:25:44.000Z","updated_at":"2022-09-05T07:57:42.000Z","dependencies_parsed_at":"2023-04-12T16:47:46.463Z","dependency_job_id":null,"html_url":"https://github.com/lin-xi/babel-plugin-import-fix","commit_stats":{"total_commits":39,"total_committers":3,"mean_commits":13.0,"dds":0.2564102564102564,"last_synced_commit":"18018002637a7bcb7acbe4301dc82bfa541b4296"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lin-xi/babel-plugin-import-fix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lin-xi%2Fbabel-plugin-import-fix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lin-xi%2Fbabel-plugin-import-fix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lin-xi%2Fbabel-plugin-import-fix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lin-xi%2Fbabel-plugin-import-fix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lin-xi","download_url":"https://codeload.github.com/lin-xi/babel-plugin-import-fix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lin-xi%2Fbabel-plugin-import-fix/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260342398,"owners_count":22994810,"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","babelrc","tree-shaking"],"created_at":"2024-08-02T09:01:07.562Z","updated_at":"2025-06-17T10:41:08.122Z","avatar_url":"https://github.com/lin-xi.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# babel-plugin-import-fix\n\n[![Build Status](https://travis-ci.org/lin-xi/babel-plugin-import-fix.svg?branch=master)](https://travis-ci.org/lin-xi/babel-plugin-import-fix)\n[![Coverage Status](https://coveralls.io/repos/github/lin-xi/babel-plugin-import-fix/badge.svg?branch=master)](https://coveralls.io/github/lin-xi/babel-plugin-import-fix?branch=master)\n[![npm package](https://img.shields.io/npm/v/babel-plugin-import-fix.svg)](https://www.npmjs.org/package/babel-plugin-import-fix)\n[![NPM downloads](http://img.shields.io/npm/dm/babel-plugin-import-fix.svg)](https://npmjs.org/package/babel-plugin-import-fix)\n\n\n\nalter import module to certain module file path for smaller bundle file and better performance\n\n主要功能是修改import，缩小import的范围，减少bundle文件大小，提升性能\n\n-------\n\n```javascript\nimport {Button} from 'antd';\n```\n\nafter fix:\n\n```javascript\nimport {Button} from 'antd/lib/button';\nimport 'antd/lib/button/style'\n```\nthese fixies are made on ast.\nbundle file size decrease from 1.5Mb to 286Kb.\n\n-------\n\n## how to use\n\n```bash\nnpm install babel-plugin-import-fix -D\n```\n\nconfig it in your .babelrc\n\n在.babelrc里进行配置\n\n.babelrc\n```javascript\n{\n  \"presets\": [\n    [\"es2015\", { \"modules\": false }], \"react\"\n  ],\n  \"plugins\": [\"import-fix\"]\n}\n```\n\n-------\n\n## supported framework\n\n| framework | status  |\n| :------------ |:---------------:|\n| xcui         |✅        |\n| antd         |✅        |\n| elementUI    |✅        |\n| material-ui  |✅        |\n| d3           |✅        |\n-------\n\nmore library will be supported increasingly\n\n默认直接支持这些库，不需要配置，会不断增加支持的类型\n\n## extend usage:\n\nyou can overwrite the config or add new config like this:\n\n扩展支持的库，如果没有css，可以不写cssPath，或设置为空\n\n.babelrc\n```javascript\n{\n  \"presets\": [\n    [\"es2015\", { \"modules\": false }], \"react\"\n  ],\n  \"plugins\": [[\"import-fix\", [\n    {\n      'libraryName': 'xcui',\n      'libraryPath': 'xcui/lib/${name}.js',\n      'namePolicy': 'dash',\n      'cssPath': ['xcui/lib/css/common.css', 'xcui/lib/css/${name}.css']\n    },\n    {\n      'libraryName': 'antd',\n      'libraryPath': 'antd/lib/${name}/index.js',\n      'namePolicy': 'dash',\n      'cssPath': 'antd/lib/${name}/style/index.css'\n    }\n  ]]]\n}\n```\n\ncssPath can be a string or an array or an empty string, if you hava multiple css files to import, use an array.\nyou may igonre cssPath if you don't need.\n\ncssPath可以是字符或数组\n\n\n-------\n\n## name policy\n\nthree policy are supported\n\nnamePolicy选项\n\n+ dash, date-picker\n+ camel, DatePicker\n+ underline, date_picker\n\n-------\n\n## default config:\n\n默认配置\n\n```javascript\n[\n  {\n    'libraryName': 'antd',\n    'libraryPath': 'antd/lib/${name}/index.js',\n    'namePolicy': 'dash',\n    'cssPath': 'antd/lib/${name}/style/index.css'\n  },\n  {\n    'libraryName': 'material-ui',\n    'libraryPath': 'material-ui/${name}/index.js',\n    'namePolicy': 'camel',\n    'cssPath': ''\n  },\n  {\n    'libraryName': 'xcui',\n    'libraryPath': 'xcui/lib/${name}.js',\n    'namePolicy': 'dash',\n    'cssPath': ['xcui/lib/css/common.css', 'xcui/lib/css/${name}.css']\n  },\n  {\n    'libraryName': 'element-ui',\n    'libraryPath': 'element-ui/lib/${name}.js',\n    'namePolicy': 'dash',\n    'cssPath': ['element-ui/lib/theme-default/base.css', 'element-ui/lib/theme-default/${name}.css']\n  },\n  {\n    'libraryName': 'd3',\n    'libraryPath': 'd3-${name}/index.js',\n    'namePolicy': 'dash',\n    'cssPath': ''\n  }\n]\n```\n\n-------\n\n\n## thanks:\n\nhttps://github.com/ant-design/babel-plugin-import\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flin-xi%2Fbabel-plugin-import-fix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flin-xi%2Fbabel-plugin-import-fix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flin-xi%2Fbabel-plugin-import-fix/lists"}