{"_id":"@datarose/unplugin-auto-import-collector","_rev":"11-53d7ff3defe01e16435c99d33bd440fa","name":"@datarose/unplugin-auto-import-collector","dist-tags":{"latest":"0.3.0"},"versions":{"0.0.4":{"name":"@datarose/unplugin-auto-import-collector","version":"0.0.4","keywords":["unplugin-auto-import","unplugin-auto-import-plugin","collecting exports"],"author":{"name":"Rózsa Zoltán"},"license":"GPL-3.0","_id":"@datarose/unplugin-auto-import-collector@0.0.4","maintainers":[{"name":"rozsazoltan","email":"dev@datarose.net"}],"homepage":"https://github.com/datarose-net/unplugin-auto-import-collector#readme","bugs":{"url":"https://github.com/datarose-net/unplugin-auto-import-collector/issues"},"dist":{"shasum":"09f69e28020d0e48fa0f062d31b4063782fd43b1","tarball":"https://registry.npmjs.org/@datarose/unplugin-auto-import-collector/-/unplugin-auto-import-collector-0.0.4.tgz","fileCount":6,"integrity":"sha512-M2kHLJIzUlSJszxBgNYJCRIaTxYcoZI5sf0SFo8Ex18Pa5Q6IdHS7DmOEV4/k/HmqLaAabkvxAq65htWLViMPA==","signatures":[{"sig":"MEQCID1JrN/jBwHkGlJT5/HRfe6kn00NqGmJOPQ8YGo/WUVQAiATW8jSPjyx+2X9FPAjk0LTjHF/91DWlVUkOehfiYBgIg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":42941},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=21"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./package.json":"./package.json"},"gitHead":"176b63342447287f07a5403462e7ca45a73ec22b","private":false,"_npmUser":{"name":"rozsazoltan","email":"dev@datarose.net"},"repository":{"url":"git+https://github.com/datarose-net/unplugin-auto-import-collector.git","type":"git"},"_npmVersion":"10.5.0","description":"Extension for unplugin-auto-import & Collecting exports into an array from a file","directories":{},"_nodeVersion":"21.7.1","dependencies":{},"publishConfig":{"registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"packageManager":"pnpm@8.15.4","peerDependencies":{"vite":">=5"},"_npmOperationalInternal":{"tmp":"tmp/unplugin-auto-import-collector_0.0.4_1715953065779_0.4400379734103803","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@datarose/unplugin-auto-import-collector","version":"0.2.0","keywords":["unplugin-auto-import","unplugin-auto-import-plugin","collecting exports"],"author":{"name":"Rózsa Zoltán"},"license":"GPL-3.0","_id":"@datarose/unplugin-auto-import-collector@0.2.0","maintainers":[{"name":"rozsazoltan","email":"dev@datarose.net"}],"homepage":"https://github.com/datarose-net/unplugin-auto-import-collector#readme","bugs":{"url":"https://github.com/datarose-net/unplugin-auto-import-collector/issues"},"dist":{"shasum":"ad16a1cb87810c8dec2b115a1c499fb03c0713c4","tarball":"https://registry.npmjs.org/@datarose/unplugin-auto-import-collector/-/unplugin-auto-import-collector-0.2.0.tgz","fileCount":5,"integrity":"sha512-6Msjqf7slT/fmhWHE/U0pPpVl5uHyA4WfHh/IglDL6a/iHsK4fn2ZtozQMMybKgFmuJGzhw3uDybKhNBDiU25Q==","signatures":[{"sig":"MEUCIQCXZw2e6Y6aShzFiFCUGoP5pCb1ILO0sSp91BYa53MurgIgZIUWDAhaYFA1FUqJUIgpe4PZTxgm6sHCudZ7Mfx+zAI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":42153},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=21"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"gitHead":"70b6ef5badc2fad86affa4396c38385f6cd70440","private":false,"_npmUser":{"name":"rozsazoltan","email":"dev@datarose.net"},"repository":{"url":"git+https://github.com/datarose-net/unplugin-auto-import-collector.git","type":"git"},"_npmVersion":"10.5.0","description":"Extension for unplugin-auto-import & Collecting exports into an array from a file","directories":{},"_nodeVersion":"21.7.1","publishConfig":{"registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"packageManager":"pnpm@8.15.4","peerDependencies":{"vite":">=5"},"_npmOperationalInternal":{"tmp":"tmp/unplugin-auto-import-collector_0.2.0_1721475978639_0.6198330165428063","host":"s3://npm-registry-packages"}},"0.2.1":{"name":"@datarose/unplugin-auto-import-collector","version":"0.2.1","keywords":["unplugin-auto-import","unplugin-auto-import-plugin","collecting exports"],"author":{"name":"Rózsa Zoltán"},"license":"GPL-3.0-only","_id":"@datarose/unplugin-auto-import-collector@0.2.1","maintainers":[{"name":"rozsazoltan","email":"dev@datarose.net"}],"homepage":"https://github.com/datarose-net/unplugin-auto-import-collector#readme","bugs":{"url":"https://github.com/datarose-net/unplugin-auto-import-collector/issues"},"dist":{"shasum":"5dede981edace6a29a60fa7fcbed3f104bf67062","tarball":"https://registry.npmjs.org/@datarose/unplugin-auto-import-collector/-/unplugin-auto-import-collector-0.2.1.tgz","fileCount":5,"integrity":"sha512-eAK/TZqYfvKQKtKy1P3zoCOl3F2u4WBTi5MnS77ebnATPFmPz01fLyDifBn5QgMoCa9AbHMGg7W44dGJkLU9ag==","signatures":[{"sig":"MEUCIEvM53DWJZHWY4jls7yOxKwj38AZp98y+Mu1lcKPFsCEAiEAjF1NAx1oCFcS4cGIlIZdQmHtf2pzsvd1ex8/N7BeEys=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":41651},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=21"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"gitHead":"578b6298106be7264aba61da5d8cfe8db17a38c5","private":false,"_npmUser":{"name":"rozsazoltan","email":"dev@datarose.net"},"repository":{"url":"git+https://github.com/datarose-net/unplugin-auto-import-collector.git","type":"git"},"_npmVersion":"10.5.0","description":"Extension for unplugin-auto-import & Collecting exports into an array from a file","directories":{},"_nodeVersion":"21.7.1","publishConfig":{"registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"packageManager":"pnpm@8.15.4","peerDependencies":{"vite":">=5"},"_npmOperationalInternal":{"tmp":"tmp/unplugin-auto-import-collector_0.2.1_1721914314608_0.02345235980108007","host":"s3://npm-registry-packages"}},"0.3.0":{"name":"@datarose/unplugin-auto-import-collector","version":"0.3.0","author":{"name":"Rózsa Zoltán"},"type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","private":false,"license":"GPL-3.0-only","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"},"./package.json":"./package.json"},"description":"Extension for unplugin-auto-import & Collecting exports into an array from a file","repository":{"type":"git","url":"git+https://github.com/datarose-net/unplugin-auto-import-collector.git"},"bugs":{"url":"https://github.com/datarose-net/unplugin-auto-import-collector/issues"},"homepage":"https://github.com/datarose-net/unplugin-auto-import-collector#readme","keywords":["unplugin-auto-import","unplugin-auto-import-plugin","collecting exports"],"peerDependencies":{"vite":">=5"},"engines":{"node":">=21"},"packageManager":"pnpm@8.15.4","publishConfig":{"registry":"https://registry.npmjs.org"},"_id":"@datarose/unplugin-auto-import-collector@0.3.0","gitHead":"4cc2b1c7eb62f3e74a45024a71551f0b895b48ff","_nodeVersion":"21.7.1","_npmVersion":"10.5.0","dist":{"integrity":"sha512-/c5Ql97j2QUxf8RMWrnavMU5dElgIG4CGRe5HkOAp6cADK7Rf/CSq4/qNopS7khdnNlLjDfPQMJcaDPoWKnUVw==","shasum":"87436b0424fc9e4b2077dc88610b41269778d0aa","tarball":"https://registry.npmjs.org/@datarose/unplugin-auto-import-collector/-/unplugin-auto-import-collector-0.3.0.tgz","fileCount":5,"unpackedSize":7406,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDKu/G7EGTOZYfyqjQ31Y+B9kug28P8gBi/Ky+NdWl/fQIhAKqxJTRIjlTO9uDQUIQr2fpz47qYMkUefDWMJTr+t0Vl"}]},"_npmUser":{"name":"rozsazoltan","email":"dev@datarose.net"},"directories":{},"maintainers":[{"name":"rozsazoltan","email":"dev@datarose.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/unplugin-auto-import-collector_0.3.0_1725532133324_0.5793315513266992"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-17T13:17:09.264Z","modified":"2024-09-05T10:28:53.672Z","0.0.1":"2024-05-17T13:17:09.523Z","0.0.2":"2024-05-17T13:21:17.133Z","0.0.3":"2024-05-17T13:24:49.898Z","0.0.4":"2024-05-17T13:37:45.961Z","0.1.0":"2024-07-20T08:09:13.787Z","0.2.0":"2024-07-20T11:46:18.794Z","0.2.1":"2024-07-25T13:31:54.831Z","0.3.0":"2024-09-05T10:28:53.495Z"},"bugs":{"url":"https://github.com/datarose-net/unplugin-auto-import-collector/issues"},"author":{"name":"Rózsa Zoltán"},"license":"GPL-3.0-only","homepage":"https://github.com/datarose-net/unplugin-auto-import-collector#readme","keywords":["unplugin-auto-import","unplugin-auto-import-plugin","collecting exports"],"repository":{"type":"git","url":"git+https://github.com/datarose-net/unplugin-auto-import-collector.git"},"description":"Extension for unplugin-auto-import & Collecting exports into an array from a file","maintainers":[{"name":"rozsazoltan","email":"dev@datarose.net"}],"readme":"<div align=\"center\">\n  <img width=\"200\" height=\"200\" hspace=\"10\" src=\"https://datarose.net/packages/@datarose/unplugin-auto-import-collector/logo.svg\" alt=\"@datarose / unplugin auto import collector logo\" />\n  <h1>Unplugin Auto Import Collector</h1>\n  <p>\n    Extension for <a href=\"https://github.com/unplugin/unplugin-auto-import\" target=\"_blank\">unplugin-auto-import</a>\n  </p>\n</div>\n\n<p>&nbsp;</p>\n\nThe unplugin-auto-import is capable of globally importing variables and functions from pre-declared packages or files, allowing you to optionally assign them aliases. They have a few pre-made and maintained templates, so you don't have to individually list commonly used functions, such as those in Vue. However, what if you want to import a custom file or a package not yet supported by the community? You'd have to manually list the required functions, which can be time-consuming.\n\nThe purpose of this addon is to gather all exports from a specified file path. We can provide aliases for these exports and list a few functions that we don't need globally, so we'd like to exclude them.\n\nCurrently, the addon only works with files. However, it can also be used with packages by specifying their file paths, allowing exports to be collected from them as well.\n\n## Installation\n\n> **Supports**\n>\n> - Vite >=5\n> - Node >=21\n\n```\nnpm install unplugin-auto-import @datarose/unplugin-auto-import-collector --save-dev\n```\n\n## Startup\n\n**vite.config.js**\n```js\n// vite.config.ts\nimport AutoImport from 'unplugin-auto-import/vite'\nimport { getImportsMapFrom } from '@datarose/unplugin-auto-import-collector'\n\nexport default defineConfig({\n  plugins: [\n    AutoImport({\n      imports: [{\n         // ./src/functions.(js|ts)\n        'src/functions': getImportsMapFrom('./src/functions.js', [\n          ['default', 'alis_for_default'], // set alias for export default {...}\n          ['resolve', 'alias_for_resolve'], // set alias for export const resolve = () => {...}\n          ['TITLE', ''] // exclude TITLE\n        ]),\n        \n        /*\n        RESULT (that matches the configuration: https://github.com/unplugin/unplugin-auto-import?tab=readme-ov-file#configuration)\n        'src/functions': [\n           'getPrettierDate',\n           'myAnotherFunction',\n           ['default', 'alis_for_default'],\n           ['resolve', 'alias_for_resolve'],\n        ],\n        */\n      }],\n    }),\n  ],\n})\n```\n\n## Configuration\n\n|Name|Type|Default|Description|\n|----|----|-------|-----------|\n|**path** |String||Where the file is located.|\n|**alias** |String[][]|[] (empty array)|Alias names to associate with exports.<br>If the alias name is an empty string,<br>it is treated as an exclusion.|\n\n### Example for Alias\n```\n[\n  ['originalName', 'aliasName'], // set alias for export const originalName\n  ['anotherOriginalName', 'anotherAliasName'], // set alis for export function anotherOriginalName\n  ['deprecatedFunctionName', ''], // exclude export function deprecatedFunctionName\n]\n```\n\n## How to work?\n\n\nFirst, we collect all `export (default|const|let|var|function)` declarations from the file found at the provided `path`.\n\n```\nexport default {...}\nexport const constName = ...\nexport let letName = ...\nexport var varName = ...\nexport function functionName () {...}\n```\n\nNext, we extract their names and put them into an array.\n\n```\nRESULT\n['default', 'constName', 'letName', 'varName', 'functionName']\n```\n\nWe insert the aliases into the array. (If a given alias's \"originalName\" is not found, that alias is not included in the result.) We rename the elements to an empty string if we want to exclude them.\n\n```\nConfig Alias Example\n[\n  ['default', ''], // exclude\n  ['letName', 'TITLE'], // set alias\n  ['exampleNotFoundExport', 'setAliasForNotFoundExport'], // example of renaming a missing export\n]\n```\n\nWe filter out the empty strings marked as excluded elements from the result.\n\nFinally, we return the generated array.\n\n```\nRESULT\n[\n  'constName',\n  ['letName', 'TITLE'],\n  'varName',\n  'functionName',\n]\n```\n\n## Early Access\n\nThe package is still very primitive, and we have many more plans for the future. We aim to be able to map both files and packages alike.\n\n## Open Source Repository\n\nWhile we haven't opened the plugin's repository to the public yet, we are actively working towards doing so and fostering an active community to improve the package's quality.\n\n## License\n\nAll rights reserved as specified in the [`LICENSE`](./LICENSE) file! This project can be considered reusable, copyable, and/or distributable, provided that the original public repository link is included in the source code and made visible to those who use the product that incorporates this source code/package.\n","readmeFilename":"README.md"}