{"_id":"@arcmantle/vite-plugin-ce-auto-import","_rev":"5-99153fbf6c1e53362231d80fd5c4edab","name":"@arcmantle/vite-plugin-ce-auto-import","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@arcmantle/vite-plugin-ce-auto-import","version":"1.0.0","author":{"name":"Kristoffer Roen-Lie"},"license":"Apache-2.0","_id":"@arcmantle/vite-plugin-ce-auto-import@1.0.0","maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"dist":{"shasum":"20e10f809c86847509d16084b80f464050b8d805","tarball":"https://registry.npmjs.org/@arcmantle/vite-plugin-ce-auto-import/-/vite-plugin-ce-auto-import-1.0.0.tgz","fileCount":5,"integrity":"sha512-sNhP9KoorWzhsRbi+wgW7mzn+vl8su/lhpLaUpCu/I6tBQ4X5+Mvado/wd88seCPsFrz5el7puTqzuQLIQDmRg==","signatures":[{"sig":"MEQCIBWrTf8Pcx7hmCveDVXfVLfja8BuNNW2LbonJjl00PRvAiAZMb/xTOb6iDHwPalfhUGM3GmmLafmViyrCJJvNMca2w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12010},"main":"./dist/index.js","type":"module","_from":"file:arcmantle-vite-plugin-ce-auto-import-1.0.0.tgz","types":"./dist/index.d.ts","engines":{"node":">=22"},"exports":{".":"./dist/index.js"},"scripts":{"build":"rimraf dist && tsc --project ./src/tsconfig.json"},"_npmUser":{"name":"roenlie","actor":{"name":"roenlie","type":"user","email":"kristofferroenlie@gmail.com"},"email":"kristofferroenlie@gmail.com"},"_resolved":"/tmp/fda8826d5567393f4bfcaa9ae08f1a2a/arcmantle-vite-plugin-ce-auto-import-1.0.0.tgz","_integrity":"sha512-sNhP9KoorWzhsRbi+wgW7mzn+vl8su/lhpLaUpCu/I6tBQ4X5+Mvado/wd88seCPsFrz5el7puTqzuQLIQDmRg==","_npmVersion":"11.4.2","description":"Automatically imports required web components.","directories":{},"_nodeVersion":"24.3.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-ce-auto-import_1.0.0_1751494884686_0.7254106571508512","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@arcmantle/vite-plugin-ce-auto-import","version":"1.0.1","author":{"name":"Kristoffer Roen-Lie"},"license":"Apache-2.0","_id":"@arcmantle/vite-plugin-ce-auto-import@1.0.1","maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"dist":{"shasum":"f7cc3bc650b8502efa6a6458d72b6a520568b1db","tarball":"https://registry.npmjs.org/@arcmantle/vite-plugin-ce-auto-import/-/vite-plugin-ce-auto-import-1.0.1.tgz","fileCount":13,"integrity":"sha512-2ROUbQ9CXL80xM9Jc8qyEyNHk+/1YfQgnRwMsCH2Vf5sRPrkPPYzsy53XYIZkf9AeNFKbfEEIMK6dX8MGxGg6w==","signatures":[{"sig":"MEQCIAKCoy8D0EFr0Lct44wwvCIwzKookl8d32EYbsGxPhUcAiBz8odUkKn98eFJDdUNJS47T+FyDBESsNXz0JrHKavHzg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24199},"main":"./dist/index.js","type":"module","_from":"file:arcmantle-vite-plugin-ce-auto-import-1.0.1.tgz","types":"./dist/index.d.ts","engines":{"node":">=22"},"exports":{".":"./dist/index.js"},"scripts":{"build":"rimraf dist && tsc --project ./src/tsconfig.json"},"_npmUser":{"name":"roenlie","actor":{"name":"roenlie","type":"user","email":"kristofferroenlie@gmail.com"},"email":"kristofferroenlie@gmail.com"},"_resolved":"/tmp/1033035cbc6ba2fa4d8275bc580e8959/arcmantle-vite-plugin-ce-auto-import-1.0.1.tgz","_integrity":"sha512-2ROUbQ9CXL80xM9Jc8qyEyNHk+/1YfQgnRwMsCH2Vf5sRPrkPPYzsy53XYIZkf9AeNFKbfEEIMK6dX8MGxGg6w==","_npmVersion":"11.4.2","description":"Automatically imports required web components.","directories":{},"_nodeVersion":"24.3.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^7.0.0","rimraf":"^6.0.1","typescript":"^5.8.3","@types/node":"^24.0.10","@arcmantle/tsconfig":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-ce-auto-import_1.0.1_1751497139379_0.9229770099642791","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@arcmantle/vite-plugin-ce-auto-import","version":"1.0.2","author":{"name":"Kristoffer Roen-Lie"},"license":"Apache-2.0","_id":"@arcmantle/vite-plugin-ce-auto-import@1.0.2","maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"dist":{"shasum":"1c68051a17acc3c2c649ae7b6395f22a570b7294","tarball":"https://registry.npmjs.org/@arcmantle/vite-plugin-ce-auto-import/-/vite-plugin-ce-auto-import-1.0.2.tgz","fileCount":13,"integrity":"sha512-9zUIbO4nmLCVk9RosmiiIRJqR4frLYjdV9kuBA7k4CeEUYY6eaxXXkWRIqt6ejsGSI2xRCrijU1x6bWUR9cSBA==","signatures":[{"sig":"MEQCIAoVnkjgBWJU+1nCiK2pqIDVfO/Tg/3ZXX231J74FyjjAiBM84CSVZnw2BY0WLGgty120A27kcShCJbwtaAXFFXLpg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24181},"main":"./dist/index.js","type":"module","_from":"file:arcmantle-vite-plugin-ce-auto-import-1.0.2.tgz","types":"./dist/index.d.ts","engines":{"node":">=22"},"exports":{".":"./dist/index.js"},"scripts":{"build":"rimraf dist && tsc --project ./src/tsconfig.json"},"_npmUser":{"name":"roenlie","email":"kristofferroenlie@gmail.com"},"_resolved":"/tmp/0e28902fe79ecd49bac9613d7a6f2a37/arcmantle-vite-plugin-ce-auto-import-1.0.2.tgz","_integrity":"sha512-9zUIbO4nmLCVk9RosmiiIRJqR4frLYjdV9kuBA7k4CeEUYY6eaxXXkWRIqt6ejsGSI2xRCrijU1x6bWUR9cSBA==","_npmVersion":"11.4.2","description":"Automatically imports required web components.","directories":{},"_nodeVersion":"24.4.1","_hasShrinkwrap":false,"devDependencies":{"vite":"^7.0.0","rimraf":"^6.0.1","typescript":"^5.8.3","@types/node":"^24.0.14","@arcmantle/tsconfig":"^1.0.5"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-ce-auto-import_1.0.2_1752757867742_0.8534501748276286","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@arcmantle/vite-plugin-ce-auto-import","version":"1.0.3","author":{"name":"Kristoffer Roen-Lie"},"license":"Apache-2.0","_id":"@arcmantle/vite-plugin-ce-auto-import@1.0.3","maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"homepage":"https://github.com/arcmantle/vite-plugin-ce-auto-import#readme","bugs":{"url":"https://github.com/arcmantle/vite-plugin-ce-auto-import/issues"},"dist":{"shasum":"93a8f5be17c53fa690a58a2fb79d2c46a149281e","tarball":"https://registry.npmjs.org/@arcmantle/vite-plugin-ce-auto-import/-/vite-plugin-ce-auto-import-1.0.3.tgz","fileCount":13,"integrity":"sha512-V6RwcIb+9zuh/oPSVXDN8nSDGVtc7WPDR4ibrJrrJTSANyMyXUW2VGjYpyxyuL82BF8JVuApYlHdBh2Myp+jLQ==","signatures":[{"sig":"MEQCIHTBs4YOVkDJNnsiREgnESDcy4y/Le99VrscCD+YOLmXAiAA1XAqnShyGTKyWXG4uHJZugmVhSduuvm855xBA5lisA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24296},"main":"./dist/index.js","type":"module","_from":"file:arcmantle-vite-plugin-ce-auto-import-1.0.3.tgz","types":"./dist/index.d.ts","engines":{"node":">=22"},"exports":{".":"./dist/index.js"},"scripts":{"build":"rimraf dist && tsc --project ./src/tsconfig.json"},"_npmUser":{"name":"roenlie","email":"kristofferroenlie@gmail.com"},"_resolved":"/tmp/6a6f0c3d70c80d735c0c9920e4a07180/arcmantle-vite-plugin-ce-auto-import-1.0.3.tgz","_integrity":"sha512-V6RwcIb+9zuh/oPSVXDN8nSDGVtc7WPDR4ibrJrrJTSANyMyXUW2VGjYpyxyuL82BF8JVuApYlHdBh2Myp+jLQ==","repository":{"url":"git+https://github.com/arcmantle/vite-plugin-ce-auto-import.git","type":"git"},"_npmVersion":"11.4.2","description":"Automatically imports required web components.","directories":{},"_nodeVersion":"24.4.1","_hasShrinkwrap":false,"devDependencies":{"vite":"^7.0.0","rimraf":"^6.0.1","typescript":"^5.8.3","@types/node":"^24.0.14","@arcmantle/tsconfig":"^1.0.6"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-ce-auto-import_1.0.3_1752781599373_0.004813013454957105","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@arcmantle/vite-plugin-ce-auto-import","version":"1.0.4","description":"Automatically imports required web components.","repository":{"type":"git","url":"git+https://github.com/arcmantle/vite-plugin-ce-auto-import.git"},"license":"Apache-2.0","author":{"name":"Kristoffer Roen-Lie"},"type":"module","exports":{".":"./dist/index.js"},"main":"./dist/index.js","types":"./dist/index.d.ts","devDependencies":{"@arcmantle/tsconfig":"^1.0.9","@types/node":"^24.0.14","rimraf":"^6.0.1","typescript":"^5.8.3","vite":"^7.0.0"},"engines":{"node":">=22"},"scripts":{"build":"rimraf dist && tsc --project ./src/tsconfig.json"},"_id":"@arcmantle/vite-plugin-ce-auto-import@1.0.4","bugs":{"url":"https://github.com/arcmantle/vite-plugin-ce-auto-import/issues"},"homepage":"https://github.com/arcmantle/vite-plugin-ce-auto-import#readme","_integrity":"sha512-A7+voEg871vhzLee5bUjBUt+FFSjrrjMk9jbfi2ofRhN3F6VAWC8zTRu917+SLxEDWUjY3paAnUTRTNwtjTnAA==","_resolved":"/tmp/e0ba8914eff76c0bee4b20975edc6e4d/arcmantle-vite-plugin-ce-auto-import-1.0.4.tgz","_from":"file:arcmantle-vite-plugin-ce-auto-import-1.0.4.tgz","_nodeVersion":"24.4.1","_npmVersion":"11.4.2","dist":{"integrity":"sha512-A7+voEg871vhzLee5bUjBUt+FFSjrrjMk9jbfi2ofRhN3F6VAWC8zTRu917+SLxEDWUjY3paAnUTRTNwtjTnAA==","shasum":"b09fdf2adfb4ef0b916d56c968c0ebd859208ef2","tarball":"https://registry.npmjs.org/@arcmantle/vite-plugin-ce-auto-import/-/vite-plugin-ce-auto-import-1.0.4.tgz","fileCount":13,"unpackedSize":24296,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCXtorUqTnTyzX/bkmFqPn7vMjXekNciFaiHzqghK2G0AIhAOk/LZ7okiRfEsiTdmd0Z1K6lIqdwAj0DLzGpJOm/So7"}]},"_npmUser":{"name":"roenlie","email":"kristofferroenlie@gmail.com"},"directories":{},"maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vite-plugin-ce-auto-import_1.0.4_1752792919091_0.21045331192838423"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-02T22:21:24.492Z","modified":"2025-07-17T22:55:19.505Z","1.0.0":"2025-07-02T22:21:24.917Z","1.0.1":"2025-07-02T22:58:59.567Z","1.0.2":"2025-07-17T13:11:07.906Z","1.0.3":"2025-07-17T19:46:39.537Z","1.0.4":"2025-07-17T22:55:19.304Z"},"bugs":{"url":"https://github.com/arcmantle/vite-plugin-ce-auto-import/issues"},"author":{"name":"Kristoffer Roen-Lie"},"license":"Apache-2.0","homepage":"https://github.com/arcmantle/vite-plugin-ce-auto-import#readme","repository":{"type":"git","url":"git+https://github.com/arcmantle/vite-plugin-ce-auto-import.git"},"description":"Automatically imports required web components.","maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"readme":"# @arcmantle/vite-plugin-ce-auto-import\n\nA Vite plugin that automatically imports required web components based on their usage in your code. This plugin scans your source files for custom element tags and automatically injects the necessary import statements, eliminating the need to manually import each web component.\n\n## Features\n\n- 🔍 **Automatic Detection**: Scans files for custom element usage and automatically imports required components\n- 🏷️ **Multiple Tag Patterns**: Supports `@customElement`, `@injectableElement`, and `customElements.define` patterns\n- 📁 **Directory-based**: Configurable directories to scan for component definitions\n- 🎯 **Prefix Filtering**: Filter components by tag name prefixes (e.g., `mm-`, `pl-`)\n- ⚡ **Smart Caching**: Built-in caching system for improved performance\n- 🎛️ **Flexible Configuration**: Whitelist/blacklist patterns for both component scanning and file processing\n\n## Installation\n\n```bash\nnpm install @arcmantle/vite-plugin-ce-auto-import\n# or\npnpm add @arcmantle/vite-plugin-ce-auto-import\n# or\nyarn add @arcmantle/vite-plugin-ce-auto-import\n```\n\n## Usage\n\nAdd the plugin to your `vite.config.ts`:\n\n```typescript\nimport { defineConfig } from 'vite';\nimport { componentAutoImporter } from '@arcmantle/vite-plugin-ce-auto-import';\n\nexport default defineConfig({\n  plugins: [\n    componentAutoImporter({\n      directories: [{ path: './src/components' }],\n      prefixes: [/mm-/],\n      loadWhitelist: [/\\.ts$/],\n      loadBlacklist: [/\\.demo/],\n    }),\n  ],\n});\n```\n\n## Configuration\n\n### AutoImportPluginProps\n\n| Property | Type | Description |\n|----------|------|-------------|\n| `directories` | `Array<{ path: string; whitelist?: RegExp[]; blacklist?: RegExp[]; }>` | Directories to scan for component definitions |\n| `prefixes` | `RegExp[]` | Array of regex patterns to match tag name prefixes |\n| `loadWhitelist` | `RegExp[]` | Files that should be processed by the plugin |\n| `loadBlacklist` | `RegExp[]` | Files that should be excluded from processing |\n| `cache` | `Map<string, string>` | Optional custom cache for tag-to-file mappings |\n\n### Directory Configuration\n\nEach directory entry supports:\n\n- `path`: The directory path to scan\n- `whitelist`: Optional array of regex patterns for files to include\n- `blacklist`: Optional array of regex patterns for files to exclude\n\n## How It Works\n\n1. **Build Start**: The plugin scans specified directories for component definitions using these patterns:\n   - `@customElement('tag-name')`\n   - `@injectableElement('tag-name')`\n   - `customElements.define('tag-name', ...)`\n\n2. **File Processing**: When processing files, the plugin:\n   - Checks if the file matches whitelist/blacklist criteria\n   - Scans for closing tags matching configured prefixes (e.g., `</mm-button>`)\n   - Looks up component import paths from the cache\n   - Injects import statements at the top of the file\n\n3. **Import Injection**: Generated imports look like:\n\n   ```typescript\n   /* Component imports injected from: @arcmantle/vite-plugin-ce-auto-import */\n   import './components/button/button.component.js';\n   import './components/dialog/dialog.component.js';\n   /*  */\n\n   // Your original code here...\n   ```\n\n## Examples\n\n### Basic Configuration\n\n```typescript\ncomponentAutoImporter({\n  directories: [{ path: './src/components' }],\n  prefixes: [/my-/],\n  loadWhitelist: [/\\.(ts|js)$/],\n})\n```\n\n### Advanced Configuration\n\n```typescript\ncomponentAutoImporter({\n  directories: [\n    {\n      path: './src/components',\n      whitelist: [/\\.component\\.ts$/],\n      blacklist: [/\\.test\\.ts$/]\n    },\n    {\n      path: './src/widgets',\n      whitelist: [/\\.widget\\.ts$/]\n    }\n  ],\n  prefixes: [/mm-/, /widget-/],\n  loadWhitelist: [/\\.ts$/],\n  loadBlacklist: [/\\.demo\\.ts$/, /\\.test\\.ts$/],\n})\n```\n\n### Multiple Prefixes\n\n```typescript\ncomponentAutoImporter({\n  directories: [{ path: './src' }],\n  prefixes: [\n    /^app-/,      // matches app-header, app-footer\n    /^ui-/,       // matches ui-button, ui-input\n    /^layout-/,   // matches layout-grid, layout-flex\n  ],\n  loadWhitelist: [/\\.ts$/],\n})\n```\n\n## Component Definition Patterns\n\nThe plugin recognizes these component definition patterns:\n\n### @customElement Decorator\n\n```typescript\nimport { customElement } from 'lit/decorators.js';\n\n@customElement('my-button')\nexport class MyButton extends LitElement {\n  // component implementation\n}\n```\n\n### @injectableElement Decorator\n\n```typescript\nimport { injectableElement } from '@arcmantle/lit-utilities';\n\n@injectableElement('my-dialog')\nexport class MyDialog extends LitElement {\n  // component implementation\n}\n```\n\n### customElements.define\n\n```typescript\ncustomElements.define('my-input', class extends HTMLElement {\n  // component implementation\n});\n```\n\n## Use Cases\n\n### Component Libraries\n\nPerfect for component libraries where you want automatic imports:\n\n```typescript\n// Before: Manual imports required\nimport './components/button.js';\nimport './components/input.js';\nimport './components/dialog.js';\n\n// Your template using the components\nconst template = html`\n  <my-button>Click me</my-button>\n  <my-input placeholder=\"Enter text\"></my-input>\n  <my-dialog>Modal content</my-dialog>\n`;\n\n// After: Automatic imports based on usage\nconst template = html`\n  <my-button>Click me</my-button>\n  <my-input placeholder=\"Enter text\"></my-input>\n  <my-dialog>Modal content</my-dialog>\n`;\n// Imports are automatically injected!\n```\n\n### Large Applications\n\nFor applications with many custom elements across multiple directories:\n\n```typescript\ncomponentAutoImporter({\n  directories: [\n    { path: './src/components' },      // UI components\n    { path: './src/widgets' },         // Complex widgets\n    { path: './src/pages' },          // Page-level components\n  ],\n  prefixes: [/app-/, /ui-/, /page-/],\n  loadWhitelist: [/\\.(ts|js)$/],\n  loadBlacklist: [/\\.test\\.(ts|js)$/, /\\.stories\\.(ts|js)$/],\n})\n```\n\n## Performance\n\n- **Caching**: The plugin uses intelligent caching to avoid re-scanning unchanged files\n- **Selective Processing**: Only processes files matching whitelist criteria\n- **Build-time**: All scanning happens at build time, no runtime overhead\n\n## Requirements\n\n- Node.js >= 22\n- Vite >= 7.0.0\n\n## Dependencies\n\n- **globby**: Fast glob matching for directory scanning\n- **oxc-walker**: High-performance JavaScript/TypeScript AST walker\n- **magic-string**: Efficient string manipulation with source maps\n\n## License\n\nApache-2.0\n\n## Contributing\n\nThis package is part of the Arcmantle Weave monorepo. Contributions are welcome!\n","readmeFilename":"README.md"}