{"name":"babel-plugin-import","version":"1.13.4","description":"Component modular import plugin for babel.","repository":{"type":"git","url":"git+https://github.com/ant-design/babel-plugin-import.git"},"main":"lib/index.js","scripts":{"build":"father-build","test":"umi-test --coverage","debug":"umi-test","lint":"eslint --ext .js src","coveralls":"cat ./coverage/lcov.info | coveralls","prepack":"npm run build","prepublishOnly":"npm run build && np --no-cleanup --yolo --no-publish --any-branch"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["eslint","prettier --write"]},"keywords":["babel-plugin","antd"],"author":{"name":"chencheng","email":"sorrycc@gmail.com"},"license":"MIT","devDependencies":{"@babel/core":"^7.0.0","@babel/preset-react":"^7.0.0","@umijs/test":"^3.2.28","babel-core":"^7.0.0-0","babel-preset-umi":"^1.0.0","coveralls":"^3.0.6","eslint":"^7.1.0","eslint-config-airbnb":"^18.1.0","eslint-config-prettier":"^6.11.0","eslint-plugin-import":"^2.20.2","eslint-plugin-prettier":"^3.1.3","father-build":"^1.21.2","husky":"^4.2.5","lint-staged":"^10.2.8","material-ui":"^0.20.2","np":"^6.2.0","prettier":"^2.0.5","react-toolbox":"^1.2.5"},"babel":{"presets":["umi"]},"dependencies":{"@babel/helper-module-imports":"^7.0.0","@babel/runtime":"^7.0.0"},"gitHead":"7af38ecb2a48da6fe060de0271f848d394c2c4b0","bugs":{"url":"https://github.com/ant-design/babel-plugin-import/issues"},"homepage":"https://github.com/ant-design/babel-plugin-import#readme","_id":"babel-plugin-import@1.13.4","_nodeVersion":"16.10.0","_npmVersion":"7.24.0","dist":{"integrity":"sha512-mgxDddD6cIBZPn6OzDyxj7pDedHPZy+UFvKvKg3y58IAlRwTYz/bk5Kb/crywB/0NpcfQd0y6EBxd24BgdH7Ew==","shasum":"1581899353a8cf595b3feca20979bf980a008dd6","tarball":"http://registry-npm.ywwl.com/babel-plugin-import/download/babel-plugin-import-1.13.4.tgz","fileCount":6,"unpackedSize":41570,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtq/3Lg8tkKVO9UWdMSGvHei8rr4metz/1t+YLAHZujwIgOOAuuZcpBnV4GQy1zDhjkzK5rlke2ZxNH4+s/lipMmA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiU6JjACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoFmg/6A3sIBGdCcGSUKEbfQGxtVtV8Pk3ooIVbP5wPsNcrleRvEUWH\r\nRdtr+3KHAcXs1UqckNOU26MSdqi95gnmsJTzLioz2bppK0n89m8OAX3CbviF\r\nxXOXsaETxmt414et4szl8BJm7DBduc+QnFvZl5G5X5hQzEBzUmnp9iqIIz2p\r\nAWsfYSRf1HH7H4cAecEKfRnr8rBDC1Gb41BHICOE/pJXlvXd4Em8UDtRSo3G\r\ndzW39SyYkA784MARgNIl3UvB0BxAC4+nh79UrIjvEOpilkXKZvu2fERPYUH7\r\nzGWLREifjM5hCa9Vj2QjmQXrzDw4eRFOO3tXD5DF8/XxMhZYln24/fRBqXl7\r\nBc5YEp8y0vMY+dVIBAXidmLiM6Jn5MTOt2evRTWWvspSEDTB6YJXbtjYWIQX\r\n0fjnw7DAzxKEJBysF/CUctb5M7tJjykngA9YnBcvjmqssL2MJUfGTUShtnZ7\r\ndoH56HK8ApErDQb0GxqMsPDNtvEdEJIzbR0fRlOJVDhHzhSHsL05dv99P2aw\r\n6ZJnMevr01X7HVd8tO3gDKiwXR1sHM7AN7xBh65vwxvipqw3/H1s8Z//A+m3\r\ne1irvVH0We5QibYxbomGTFAd7Vmq/HO8HtMhKz4lcWNSybG1x08hVtARHgY/\r\njt5MBo0TQyj7iynl7lSK3WUoE9m3R3RXREc=\r\n=ULqS\r\n-----END PGP SIGNATURE-----\r\n","size":8541,"noattachment":false,"key":"/babel-plugin-import/-/babel-plugin-import-1.13.4.tgz"},"_npmUser":{"name":"sorrycc","email":"sorrycc@gmail.com"},"directories":{},"maintainers":[{"name":"yesmeck","email":"yesmeck@gmail.com"},{"name":"sorrycc","email":"sorrycc@gmail.com"},{"name":"afc163","email":"afc163@gmail.com"},{"name":"paranoidjk","email":"hust2012jiangkai@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/babel-plugin-import_1.13.4_1649648227274_0.335345318793153"},"_hasShrinkwrap":false,"readme":"# babel-plugin-import\n\nModular import plugin for babel, compatible with [antd](https://github.com/ant-design/ant-design), [antd-mobile](https://github.com/ant-design/ant-design-mobile), lodash, [material-ui](http://material-ui.com/), and so on.\n\n[![NPM version](https://img.shields.io/npm/v/babel-plugin-import.svg?style=flat)](https://npmjs.org/package/babel-plugin-import)\n[![Build Status](https://img.shields.io/travis/ant-design/babel-plugin-import.svg?style=flat)](https://travis-ci.org/ant-design/babel-plugin-import)\n\n----\n\n## Why babel-plugin-import\n\n- [English Instruction](https://ant.design/docs/react/getting-started#Import-on-Demand)\n- [中文说明](https://ant.design/docs/react/getting-started-cn#%E6%8C%89%E9%9C%80%E5%8A%A0%E8%BD%BD)\n\n## Where to add babel-plugin-import\n\n- [babelrc](https://babeljs.io/docs/usage/babelrc/)\n- [babel-loader](https://github.com/babel/babel-loader)\n\n## Example\n\n#### `{ \"libraryName\": \"antd\" }`\n\n```javascript\nimport { Button } from 'antd';\nReactDOM.render(<Button>xxxx</Button>);\n\n      ↓ ↓ ↓ ↓ ↓ ↓\n\nvar _button = require('antd/lib/button');\nReactDOM.render(<_button>xxxx</_button>);\n```\n\n#### `{ \"libraryName\": \"antd\", style: \"css\" }`\n\n```javascript\nimport { Button } from 'antd';\nReactDOM.render(<Button>xxxx</Button>);\n\n      ↓ ↓ ↓ ↓ ↓ ↓\n\nvar _button = require('antd/lib/button');\nrequire('antd/lib/button/style/css');\nReactDOM.render(<_button>xxxx</_button>);\n```\n\n#### `{ \"libraryName\": \"antd\", style: true }`\n\n```javascript\nimport { Button } from 'antd';\nReactDOM.render(<Button>xxxx</Button>);\n\n      ↓ ↓ ↓ ↓ ↓ ↓\n\nvar _button = require('antd/lib/button');\nrequire('antd/lib/button/style');\nReactDOM.render(<_button>xxxx</_button>);\n```\n\nNote : with `style: true` css source files are imported and optimizations can be done during compilation time. With `style: \"css\"`, pre bundled css files are imported as they are.\n\n`style: true` can reduce the bundle size significantly, depending on your usage of the library.\n\n## Usage\n\n```bash\nnpm install babel-plugin-import --save-dev\n```\n\nVia `.babelrc` or babel-loader.\n\n```js\n{\n  \"plugins\": [[\"import\", options]]\n}\n```\n\n### options\n\n`options` can be object.\n\n```javascript\n{\n  \"libraryName\": \"antd\",\n  \"style\": true,   // or 'css'\n}\n```\n\n```javascript\n{\n  \"libraryName\": \"lodash\",\n  \"libraryDirectory\": \"\",\n  \"camel2DashComponentName\": false,  // default: true\n}\n```\n\n```javascript\n{\n  \"libraryName\": \"@material-ui/core\",\n  \"libraryDirectory\": \"components\",  // default: lib\n  \"camel2DashComponentName\": false,  // default: true\n}\n```\n\n~`options` can be an array.~ It's not available in babel@7+\n\nFor Example:\n\n```javascript\n[\n  {\n    \"libraryName\": \"antd\",\n    \"libraryDirectory\": \"lib\",   // default: lib\n    \"style\": true\n  },\n  {\n    \"libraryName\": \"antd-mobile\"\n  },\n]\n```\n`Options` can't be an array in babel@7+, but you can add plugins with name to support multiple dependencies.\n\nFor Example:\n\n```javascrit\n// .babelrc\n\"plugins\": [\n  [\"import\", { \"libraryName\": \"antd\", \"libraryDirectory\": \"lib\"}, \"antd\"],\n  [\"import\", { \"libraryName\": \"antd-mobile\", \"libraryDirectory\": \"lib\"}, \"antd-mobile\"]\n]\n```\n\n#### style\n\n- `[\"import\", { \"libraryName\": \"antd\" }]`: import js modularly\n- `[\"import\", { \"libraryName\": \"antd\", \"style\": true }]`: import js and css modularly (LESS/Sass source files)\n- `[\"import\", { \"libraryName\": \"antd\", \"style\": \"css\" }]`: import js and css modularly (css built files)\n\nIf option style is a `Function`, `babel-plugin-import` will auto import the file which filepath equal to the function return value. This is useful for the components library developers.\n\ne.g.\n- ``[\"import\", { \"libraryName\": \"antd\", \"style\": (name) => `${name}/style/2x` }]``: import js and css modularly & css file path is `ComponentName/style/2x`\n\nIf a component has no style, you can use the `style` function to return a `false` and the style will be ignored.\n\ne.g.\n```js\n[\n  \"import\",\n    {\n      \"libraryName\": \"antd\",\n      \"style\": (name: string, file: Object) => {\n        if(name === 'antd/lib/utils'){\n          return false;\n        }\n        return `${name}/style/2x`;\n      }\n    }\n]\n```\n\n#### styleLibraryDirectory\n\n- `[\"import\", { \"libraryName\": \"element-ui\", \"styleLibraryDirectory\": \"lib/theme-chalk\" }]`: import js and css modularly\n\nIf `styleLibraryDirectory` is provided (default `null`), it will be used to form style file path,\n`style` will be ignored then. e.g.\n\n```javascript\n{\n  \"libraryName\": \"element-ui\",\n  \"styleLibraryDirectory\": \"lib/theme-chalk\",\n}\n\nimport { Button } from 'element-ui';\n\n      ↓ ↓ ↓ ↓ ↓ ↓\n\nvar _button = require('element-ui/lib/button');\nrequire('element-ui/lib/theme-chalk/button');\n```\n\n#### customName\n\nWe can use `customName` to customize import file path.\n\nFor example, the default behavior:\n\n```typescript\nimport { TimePicker } from \"antd\"\n↓ ↓ ↓ ↓ ↓ ↓\nvar _button = require('antd/lib/time-picker');\n```\n\nYou can set `camel2DashComponentName` to `false` to disable transfer from camel to dash:\n\n```typescript\nimport { TimePicker } from \"antd\"\n↓ ↓ ↓ ↓ ↓ ↓\nvar _button = require('antd/lib/TimePicker');\n```\n\nAnd finally, you can use `customName` to customize each name parsing:\n\n```js\n[\n  \"import\",\n    {\n      \"libraryName\": \"antd\",\n      \"customName\": (name: string, file: object) => {\n        const filename = file.opts.filename;\n        if (name === 'TimePicker'){\n          return 'antd/lib/custom-time-picker';\n        }\n        if (filename.indexOf('/path/to/my/different.js') >= 0) {\n          return 'antd/lib/custom-name';\n        }\n        return `antd/lib/${name}`;\n      }\n    }\n]\n```\n\nSo this result is:\n\n```typescript\nimport { TimePicker } from \"antd\"\n↓ ↓ ↓ ↓ ↓ ↓\nvar _button = require('antd/lib/custom-time-picker');\n```\n\nIn some cases, the transformer may serialize the configuration object. If we set the `customName` to a function, it will lost after the serialization.\n\nSo we also support specifying the customName with a JavaScript source file path:\n\n```js\n[\n  \"import\",\n    {\n      \"libraryName\": \"antd\",\n      \"customName\": require('path').resolve(__dirname, './customName.js')\n    }\n]\n```\n\nThe `customName.js` looks like this:\n\n```js\nmodule.exports = function customName(name) {\n  return `antd/lib/${name}`;\n};\n```\n\n#### customStyleName\n\n`customStyleName` works exactly the same as customName, except that it deals with style file path.\n\n#### transformToDefaultImport\n\nSet this option to `false` if your module does not have a `default` export.\n\n### Note\n\nbabel-plugin-import will not work properly if you add the library to the webpack config [vendor](https://webpack.js.org/concepts/entry-points/#separate-app-and-vendor-entries).\n","publish_time":1649648227419,"_cnpm_publish_time":1649648227419,"dist-tags":{"beta":"1.6.3-beta.1","latest":"1.13.8"}}