{"_id":"@dword-design/unimport-fork","_rev":"3-661bfe85594c6139a7e1decdd6eade33","name":"@dword-design/unimport-fork","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@dword-design/unimport-fork","version":"0.0.1","license":"MIT","_id":"@dword-design/unimport-fork@0.0.1","maintainers":[{"name":"dword-design","email":"info@sebastianlandwehr.com"}],"homepage":"https://github.com/unjs/unimport#readme","bugs":{"url":"https://github.com/unjs/unimport/issues"},"dist":{"shasum":"030bf49a3e41c17e25a3c1609e5f3e1ae780a117","tarball":"https://registry.npmjs.org/@dword-design/unimport-fork/-/unimport-fork-0.0.1.tgz","fileCount":14,"integrity":"sha512-02i994qlV3AkBceRbGP7cL7FOlOZvAQQVQ0z8dSvYUenlzHMGFIDLJcr8DB9j6VhO8e6XhN/Ch1r/w+CL9sihg==","signatures":[{"sig":"MEUCIQCJSUlULYwJMozKA9XoKpiSY9834QLqY1r43+FRlJ3P9wIgd1dOgRx9dgS4k75b5ZjTQYCkED1+pwpfpj1+w1Xu8kM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":99017},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","engines":{"node":">=18.12.0"},"exports":{".":"./dist/index.mjs","./*":"./*","./addons":"./dist/addons.mjs","./unplugin":"./dist/unplugin.mjs"},"gitHead":"16941a7dc94f28cf6272a45091cb8b0ac1b4c55d","scripts":{"dev":"vitest dev","lint":"eslint .","play":"pnpm -C playground run dev","test":"vitest --coverage","build":"unbuild","prepack":"unbuild","release":"pnpm run test --run && bumpp","typecheck":"vue-tsc --noEmit","play:build":"pnpm -C playground run build"},"_npmUser":{"name":"dword-design","email":"info@sebastianlandwehr.com"},"repository":{"url":"git+https://github.com/unjs/unimport.git","type":"git"},"_npmVersion":"10.9.4","description":"Unified utils for auto importing APIs in modules","directories":{},"sideEffects":false,"_nodeVersion":"22.21.1","dependencies":{"mlly":"catalog:prod","acorn":"catalog:prod","pathe":"catalog:prod","scule":"catalog:prod","unplugin":"catalog:prod","local-pkg":"catalog:prod","picomatch":"catalog:prod","pkg-types":"catalog:prod","tinyglobby":"catalog:prod","magic-string":"catalog:prod","estree-walker":"catalog:prod","strip-literal":"catalog:prod","unplugin-utils":"catalog:prod","escape-string-regexp":"catalog:prod"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.22.0","devDependencies":{"h3":"catalog:test","lit":"catalog:test","bumpp":"catalog:dev","eslint":"catalog:dev","jquery":"catalog:test","vitest":"catalog:test","unbuild":"catalog:dev","vue-tsc":"catalog:dev","typescript":"catalog:dev","@types/node":"catalog:dev","@types/estree":"catalog:dev","@types/picomatch":"catalog:dev","@vitest/coverage-v8":"catalog:dev","@antfu/eslint-config":"catalog:dev"},"_npmOperationalInternal":{"tmp":"tmp/unimport-fork_0.0.1_1765594954315_0.1786109646862224","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@dword-design/unimport-fork","version":"0.0.2","license":"MIT","_id":"@dword-design/unimport-fork@0.0.2","maintainers":[{"name":"dword-design","email":"info@sebastianlandwehr.com"}],"homepage":"https://github.com/unjs/unimport#readme","bugs":{"url":"https://github.com/unjs/unimport/issues"},"dist":{"shasum":"74d4389dc287c94612078e642fd526522c69bdbe","tarball":"https://registry.npmjs.org/@dword-design/unimport-fork/-/unimport-fork-0.0.2.tgz","fileCount":14,"integrity":"sha512-R9z49I8DYwHQ8S9kvqpZCcsWgh1FhRE1Q1d9wVJFJSb87hYYA/YEQY1xNcs0tcE2B3c+ryYLRTJzwGH7A5nX0A==","signatures":[{"sig":"MEYCIQCAEZYIzf5xjGiU4pT6X7ceIYc+ZPfQ11hqR8HByRSXPQIhAJbQR578Rew5ul4Rv4gGFoulsPAAHSpFMtozfBDF6x46","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":99015},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","engines":{"node":">=18.12.0"},"exports":{".":"./dist/index.mjs","./*":"./*","./addons":"./dist/addons.mjs","./unplugin":"./dist/unplugin.mjs"},"gitHead":"a73ded03fcabb0ab443ba2c46cc68a0c8bcd7157","scripts":{"dev":"vitest dev","lint":"eslint .","play":"pnpm -C playground run dev","test":"vitest --coverage","build":"unbuild","prepack":"unbuild","release":"pnpm run test --run && bumpp","typecheck":"vue-tsc --noEmit","play:build":"pnpm -C playground run build"},"_npmUser":{"name":"dword-design","email":"info@sebastianlandwehr.com"},"repository":{"url":"git+https://github.com/unjs/unimport.git","type":"git"},"_npmVersion":"10.9.4","description":"Unified utils for auto importing APIs in modules","directories":{},"sideEffects":false,"_nodeVersion":"22.21.1","dependencies":{"mlly":"catalog:prod","acorn":"catalog:prod","pathe":"catalog:prod","scule":"catalog:prod","unplugin":"catalog:prod","local-pkg":"catalog:prod","picomatch":"catalog:prod","pkg-types":"catalog:prod","tinyglobby":"catalog:prod","magic-string":"catalog:prod","estree-walker":"catalog:prod","strip-literal":"catalog:prod","unplugin-utils":"catalog:prod","escape-string-regexp":"catalog:prod"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.22.0","devDependencies":{"h3":"catalog:test","lit":"catalog:test","bumpp":"catalog:dev","eslint":"catalog:dev","jquery":"catalog:test","vitest":"catalog:test","unbuild":"catalog:dev","vue-tsc":"catalog:dev","typescript":"catalog:dev","@types/node":"catalog:dev","@types/estree":"catalog:dev","@types/picomatch":"catalog:dev","@vitest/coverage-v8":"catalog:dev","@antfu/eslint-config":"catalog:dev"},"_npmOperationalInternal":{"tmp":"tmp/unimport-fork_0.0.2_1765847439031_0.6034198797508206","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@dword-design/unimport-fork","type":"module","version":"0.0.3","description":"Unified utils for auto importing APIs in modules","license":"MIT","repository":{"type":"git","url":"git+https://github.com/unjs/unimport.git"},"sideEffects":false,"exports":{".":"./dist/index.mjs","./unplugin":"./dist/unplugin.mjs","./addons":"./dist/addons.mjs","./*":"./*"},"main":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.mts","engines":{"node":">=18.12.0"},"dependencies":{"acorn":"^8.15.0","escape-string-regexp":"^5.0.0","estree-walker":"^3.0.3","local-pkg":"^1.1.2","magic-string":"^0.30.19","mlly":"^1.8.0","pathe":"^2.0.3","picomatch":"^4.0.3","pkg-types":"^2.3.0","scule":"^1.3.0","strip-literal":"^3.1.0","tinyglobby":"^0.2.15","unplugin":"^2.3.10","unplugin-utils":"^0.3.0"},"devDependencies":{"@antfu/eslint-config":"^5.4.1","@types/estree":"^1.0.8","@types/node":"^24.6.1","@types/picomatch":"^4.0.2","@vitest/coverage-v8":"^3.2.4","bumpp":"^10.2.3","eslint":"^9.36.0","h3":"^1.15.4","jquery":"^3.7.1","lit":"^3.3.1","typescript":"^5.9.3","unbuild":"^3.6.1","vitest":"^3.2.4","vue-tsc":"^3.1.0"},"scripts":{"build":"unbuild","dev":"vitest dev","lint":"eslint .","play":"pnpm -C playground run dev","play:build":"pnpm -C playground run build","typecheck":"vue-tsc --noEmit","release":"pnpm run test --run && bumpp","test":"vitest --coverage"},"_id":"@dword-design/unimport-fork@0.0.3","gitHead":"a73ded03fcabb0ab443ba2c46cc68a0c8bcd7157","bugs":{"url":"https://github.com/unjs/unimport/issues"},"homepage":"https://github.com/unjs/unimport#readme","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-3ndcYutpyV7AyEyVOJ5U6+2Hmdx6ijgZpUPv9d8OISwdRJNYCYwiXXl8ZPWoUmlWP5Kjf4MqZe2xfDIJkLFfeQ==","shasum":"5a9d6092fd4366755b45e7f6da5fbc8417f60671","tarball":"https://registry.npmjs.org/@dword-design/unimport-fork/-/unimport-fork-0.0.3.tgz","fileCount":14,"unpackedSize":98804,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICwlpEqrX5j8avkcfd/avs7TOt98IX9Kv9EedKB394BiAiEAv0/Dcyyh2cV2CgiehzOnkA9ZecAxPkBWEwy9rE5kdTQ="}]},"_npmUser":{"name":"dword-design","email":"info@sebastianlandwehr.com"},"directories":{},"maintainers":[{"name":"dword-design","email":"info@sebastianlandwehr.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unimport-fork_0.0.3_1765847887470_0.5260270446342814"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-13T03:02:34.191Z","modified":"2025-12-16T01:18:08.230Z","0.0.1":"2025-12-13T03:02:34.465Z","0.0.2":"2025-12-16T01:10:39.183Z","0.0.3":"2025-12-16T01:18:07.668Z"},"bugs":{"url":"https://github.com/unjs/unimport/issues"},"license":"MIT","homepage":"https://github.com/unjs/unimport#readme","repository":{"type":"git","url":"git+https://github.com/unjs/unimport.git"},"description":"Unified utils for auto importing APIs in modules","maintainers":[{"name":"dword-design","email":"info@sebastianlandwehr.com"}],"readme":"# unimport\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Codecov][codecov-src]][codecov-href]\n\n> Unified utils for auto importing APIs in modules, used in [nuxt](https://github.com/nuxt/nuxt) and [unplugin-auto-import](https://github.com/antfu/unplugin-auto-import)\n\n## Features\n\n- Auto import register APIs for Vite, Webpack or esbuild powered by [unplugin](https://github.com/unjs/unplugin)\n- TypeScript declaration file generation\n- Auto import for custom APIs defined under specific directories\n- Auto import for Vue template\n\n## Install\n\n```sh\n# npm\nnpm install unimport\n\n# yarn\nyarn add unimport\n\n# pnpm\npnpm install unimport\n```\n\n## Usage\n\n### Plugin Usage\n\nPowered by [unplugin](https://github.com/unjs/unplugin), `unimport` provides a plugin interface for bundlers.\n\n#### Vite / Rollup\n\n```ts\n// vite.config.js / rollup.config.js\nimport Unimport from 'unimport/unplugin'\n\nexport default {\n  plugins: [\n    Unimport.vite({ /* plugin options */ })\n  ]\n}\n```\n\n#### Webpack\n\n```ts\n// webpack.config.js\nimport Unimport from 'unimport/unplugin'\n\nmodule.exports = {\n  plugins: [\n    Unimport.webpack({ /* plugin options */ })\n  ]\n}\n```\n\n### Programmatic Usage\n\n<!-- eslint-skip -->\n\n```js\n// ESM\nimport { createUnimport } from 'unimport'\n\n// CommonJS\nconst { createUnimport } = require('unimport')\n```\n\n```js\nconst { injectImports } = createUnimport({\n  imports: [{ name: 'fooBar', from: 'test-id' }]\n})\n\n// { code: \"import { fooBar } from 'test-id';console.log(fooBar())\" }\nconsole.log(injectImports('console.log(fooBar())'))\n```\n\n## Configurations\n\n### Imports Item\n\n###### Named import\n\n```ts\nimports: [\n  { name: 'ref', from: 'vue' },\n  { name: 'useState', as: 'useSignal', from: 'react' },\n]\n```\n\nWill be injected as:\n\n```ts\nimport { useState as useSignal } from 'react'\nimport { ref } from 'vue'\n```\n\n###### Default import\n\n```ts\nimports: [\n  { name: 'default', as: '_', from: 'lodash' }\n]\n```\n\nWill be injected as:\n\n```ts\nimport _ from 'lodash'\n```\n\n###### Namespace import\n\n```ts\nimports: [\n  { name: '*', as: '_', from: 'lodash' }\n]\n```\n\nWill be injected as:\n\n```ts\nimport * as _ from 'lodash'\n```\n\n###### Export assignment import\n\nThis is a special case for libraries authored with [TypeScript's `export =` syntax](https://www.typescriptlang.org/docs/handbook/modules/reference.html#export--and-import--require). You don't need it the most of the time.\n\n```ts\nimports: [\n  { name: '=', as: 'browser', from: 'webextension-polyfill' }\n]\n```\n\nWill be injected as:\n\n```ts\nimport browser from 'webextension-polyfill'\n```\n\nAnd the type declaration will be added as:\n\n```ts\nconst browser: typeof import('webextension-polyfill')\n```\n\n###### Custom Presets\n\nPresets are provided as a shorthand for declaring imports from the same package:\n\n```ts\npresets: [\n  {\n    from: 'vue',\n    imports: [\n      'ref',\n      'reactive',\n      // ...\n    ]\n  }\n]\n```\n\nWill be equivalent as:\n\n```ts\nimports: [\n  { name: 'ref', from: 'vue' },\n  { name: 'reactive', from: 'vue' },\n  // ...\n]\n```\n\n###### Built-in Presets\n\n`unimport` also provides some built-in presets for common libraries:\n\n```ts\npresets: [\n  'vue',\n  'pinia',\n  'vue-i18n',\n  // ...\n]\n```\n\nYou can check out [`src/presets`](./src/presets/) for all the options available or refer to the type declaration.\n\n###### Exports Auto Scan\n\nSince `unimport` v0.7.0, we also support auto scanning the examples from a local installed package, for example:\n\n```ts\npresets: [\n  {\n    package: 'h3',\n    ignore: ['isStream', /^[A-Z]/, /^[a-z]*$/, r => r.length > 8]\n  }\n]\n```\n\nThis will be expanded into:\n\n```ts\nimports: [\n  {\n    from: 'h3',\n    name: 'appendHeader',\n  },\n  {\n    from: 'h3',\n    name: 'appendHeaders',\n  },\n  {\n    from: 'h3',\n    name: 'appendResponseHeader',\n  },\n  // ...\n]\n```\n\nThe `ignore` option is used to filter out the exports, it can be a string, regex or a function that returns a boolean.\n\nBy default, the result is strongly cached by the version of the package. You can disable this by setting `cache: false`.\n\n### Type Declarations\n\n```ts\nUnimport.vite({\n  dts: true // or a path to generated file\n})\n```\n\n### Directory Auto Import\n\n```ts\nUnimport.vite({\n  dirs: [\n    './composables/*',\n  ]\n})\n```\n\nScan for modules under `./composables` and auto-import the named exports.\n\n#### Nested Directories\n\n```ts\nUnimport.vite({\n  dirs: [\n    './composables/**/*',\n    {\n      glob: './composables/nested/**/*',\n      types: false // disable scan the type declarations\n    }\n  ]\n})\n```\n\nNamed exports for modules under `./composables/**/*` will be registered for auto imports, and filter out the types in `./composables/nested/**/*`.\n\n#### Directory Scan Options\n\nYou can also provide custom options for directory scan, for example:\n\n```ts\nUnimport.vite({\n  dirsScanOptions: {\n    filePatterns: ['*.ts'], // optional, default `['*.{ts,js,mjs,cjs,mts,cts}']`, glob patterns for matching files\n    fileFilter: file => file.endsWith('.ts'), // optional, default `() => true`, filter files\n    types: true, // optional, default `true`, enable/disable scan the type declarations\n    cwd: process.cwd(), // optional, default `process.cwd()`, custom cwd for directory scan\n  },\n  dirs: [\n    './composables/**/*',\n    {\n      glob: './composables/nested/**/*',\n      types: false\n    }\n  ]\n})\n```\n\n### Opt-out Auto Import\n\nYou can opt-out auto-import for specific modules by adding a comment:\n\n```ts\n// @unimport-disable\n```\n\nIt can be customized by setting `commentsDisable`:\n\n```ts\nUnimport.vite({\n  commentsDisable: [\n    '@unimport-disable',\n    '@custom-imports-disable',\n  ]\n})\n```\n\n### Acorn Parser\n\nBy default, `unimport` uses RegExp to detect unimport entries. In some cases, RegExp might not be able to detect all the entries (false positive & false negative).\n\nWe introduced a new AST-based parser powered by [acorn](https://github.com/acornjs/acorn), providing a more accurate result. The limitation is when using Acorn, it assumes all input code are valid and vanilla JavaScript code.\n\n```ts\nUnimport.vite({\n  parser: 'acorn'\n})\n```\n\n### Vue Template Auto Import\n\nIn Vue's template, the usage of API is in a different context than plain modules. Thus some custom transformations are required. To enable it, set `addons.vueTemplate` to `true`:\n\n```ts\nUnimport.vite({\n  addons: {\n    vueTemplate: true\n  }\n})\n```\n\n#### Caveats\n\nWhen auto-import a ref, inline operations won't be auto-unwrapped.\n\n```ts\nexport const counter = ref(0)\n```\n\n```html\n<template>\n  <!-- this is ok -->\n  <div>{{ counter }}</div>\n\n  <!-- counter here is a ref, this won't work, volar will throw -->\n  <div>{{ counter + 1 }}</div>\n\n  <!-- use this instead -->\n  <div>{{ counter.value + 1 }}</div>\n</template>\n```\n\nWe recommend using [Volar](https://github.com/johnsoncodehk/volar) for type checking, which will help you to identify the misusage.\n\n### Vue Directives Auto Import and TypeScript Declaration Generation\n\nIn Vue's template, the usage of directives is in a different context than plain modules. Thus some custom transformations are required. To enable it, set `addons.vueDirectives` to `true`:\n\n```ts\nUnimport.vite({\n  addons: {\n    vueDirectives: true\n  }\n})\n```\n\n#### Library Authors\n\nWhen including directives in your presets, you should:\n- provide the corresponding imports with `meta.vueDirective` set to `true`, otherwise, `unimport` will not be able to detect your directives.\n- use named exports for your directives, or use default export and use `as` in the Import.\n- set `dtsDisabled` to `true` if you provide a type declaration for your directives.\n\n```ts\nimport type { InlinePreset } from 'unimport'\nimport { defineUnimportPreset } from 'unimport'\n\nexport const composables = defineUnimportPreset({\n  from: 'my-unimport-library/composables',\n  /* imports and other options */\n})\n\nexport const directives = defineUnimportPreset({\n  from: 'my-unimport-library/directives',\n  // disable dts generation globally\n  dtsEnabled: false,\n  // you can declare the vue directive globally\n  meta: {\n    vueDirective: true\n  },\n  imports: [{\n    name: 'ClickOutside',\n    // disable dts generation per import\n    dtsEnabled: false,\n    // you can declare the vue directive per import\n    meta: {\n      vueDirective: true\n    }\n  }, {\n    name: 'default',\n    // you should declare `as` for default exports\n    as: 'Focus'\n  }]\n})\n```\n\n#### Using Directory Scan and Local Directives\n\nIf you add a directory scan for your local directives in the project, you need to:\n- provide `isDirective` in the `vueDirectives`: `unimport` will use it to detect them (will never be called for imports with `meta.vueDirective` set to `true`).\n- use always named exports for your directives.\n\n```ts\nUnimport.vite({\n  dirs: ['./directives/**'],\n  addons: {\n    vueDirectives: {\n      isDirective: (normalizedImportFrom, _importEntry) => {\n        return normalizedImportFrom.includes('/directives/')\n      }\n    }\n  }\n})\n```\n\n## 💻 Development\n\n- Clone this repository\n- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)\n- Install dependencies using `pnpm install`\n- Run interactive tests using `pnpm dev`\n\n## License\n\nMade with 💛\n\nPublished under [MIT License](./LICENSE).\n\n<!-- Badges -->\n[npm-version-src]: https://img.shields.io/npm/v/unimport?style=flat-square\n[npm-version-href]: https://npmjs.com/package/unimport\n\n[npm-downloads-src]: https://img.shields.io/npm/dm/unimport?style=flat-square\n[npm-downloads-href]: https://npmjs.com/package/unimport\n\n[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/unimport/ci/main?style=flat-square\n[github-actions-href]: https://github.com/unjs/unimport/actions?query=workflow%3Aci\n\n[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/unimport/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/unjs/unimport\n","readmeFilename":"README.md"}