{"id":16347718,"url":"https://github.com/privatenumber/vue-import-loader","last_synced_at":"2025-09-09T21:34:33.942Z","repository":{"id":57396290,"uuid":"265647699","full_name":"privatenumber/vue-import-loader","owner":"privatenumber","description":"🌐 Webpack loader to automatically detect \u0026 import used components","archived":false,"fork":false,"pushed_at":"2020-10-02T03:51:24.000Z","size":135,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-13T23:19:57.782Z","etag":null,"topics":["components","import","loader","vue","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/privatenumber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-20T18:05:55.000Z","updated_at":"2021-08-27T21:48:56.000Z","dependencies_parsed_at":"2022-09-18T12:02:41.779Z","dependency_job_id":null,"html_url":"https://github.com/privatenumber/vue-import-loader","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/privatenumber/vue-import-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fvue-import-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fvue-import-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fvue-import-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fvue-import-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/privatenumber","download_url":"https://codeload.github.com/privatenumber/vue-import-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fvue-import-loader/sbom","scorecard":{"id":745555,"data":{"date":"2025-08-11","repo":{"name":"github.com/privatenumber/vue-import-loader","commit":"a050192a354f03c77d8ea6f1459281202dc92969"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"56 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2","Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-566m-qj78-rww5","Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx","Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch","Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94","Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-5j4c-8p2g-v4jx","Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T18:36:02.037Z","repository_id":57396290,"created_at":"2025-08-22T18:36:02.037Z","updated_at":"2025-08-22T18:36:02.037Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274366513,"owners_count":25272294,"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","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["components","import","loader","vue","webpack"],"created_at":"2024-10-11T00:45:11.162Z","updated_at":"2025-09-09T21:34:33.896Z","avatar_url":"https://github.com/privatenumber.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌐 Vue Import Loader \u003ca href=\"https://npm.im/vue-import-loader\"\u003e\u003cimg src=\"https://badgen.net/npm/v/vue-import-loader\"\u003e\u003c/a\u003e \u003ca href=\"https://npm.im/vue-import-loader\"\u003e\u003cimg src=\"https://badgen.net/npm/dm/vue-import-loader\"\u003e\u003c/a\u003e \u003ca href=\"https://packagephobia.now.sh/result?p=vue-import-loader\"\u003e\u003cimg src=\"https://packagephobia.now.sh/badge?p=vue-import-loader\"\u003e\u003c/a\u003e\n\nWebpack loader to automate local component registration by statically analyzing components in the template.\n\nCredits to the [@nuxt/components](https://github.com/nuxt/components) for the idea ❤️\n\n## ⭐️ Features\n- 🌳 **Tree-shaking** Only imports unregistered components detected in the template\n- ❤️ **Chunking friendly** Locally registers components for optimal code-splitting\n- ⚡️ **Async components** Supports the full [async component API](https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components)\n- 💠 **Dynamic components** Supports `\u003ccomponent is=\"dynamic-comp\"\u003e` *\n- 🔥 **Functional components** Supports components in [functional components](https://github.com/vuejs/vue-loader/issues/1013)\n\n_* The `is` attribute must contain the possible values inline_\n\n## :rocket: Install\n```sh\nnpm i vue-import-loader\n```\n\n## 🚦 Quick Setup\nIn your Webpack config, insert `vue-import-loader` before `vue-loader`:\n\n**Before**\n```diff\n{\n     test: /\\.vue$/,\n-    loader: 'vue-loader'\n}\n```\n\n**After \u003csup\u003e✨\u003c/sup\u003e**\n```diff\n{\n     test: /\\.vue$/,\n+    use: [\n+        {\n+            loader: 'vue-import-loader',\n+            options: {\n+\n+                // Similar to Vue's \"components\" hash\n+                components: {\n+                    ComponentTag: 'component/path/component-tag.vue',\n+                    ...\n+                }\n+            }\n+        },\n+        'vue-loader'\n+    ]\n}\n```\n\n## 👨‍🏫 Examples\n\n\u003cdetails\u003e\n\t\u003csummary\u003e\u003cstrong\u003eDynamically resolve components to a directory\u003c/strong\u003e\u003c/summary\u003e\n\t\u003cbr\u003e\n\nUse a resolver function to dynamically resolve components\n\n```js\n{\n    test: /\\.vue$/,\n    use: [\n        {\n            loader: 'vue-import-loader',\n            options: {\n                components({ kebab }, fromComponent) {\n                    if (exists(kebab)) {\n                        return `@/components/${kebab}`;\n                    }\n                }\n            }\n        },\n        'vue-loader'\n    ]\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\t\u003csummary\u003e\u003cstrong\u003eAsynchronously load components with `components` hash\u003c/strong\u003e\u003c/summary\u003e\n\t\u003cbr\u003e\n\nMap the component to an object to make it asynchronous. Refer to the **Options** section for the object schema.\n\n```js\n{\n    test: /\\.vue$/,\n    use: [\n        {\n            loader: 'vue-import-loader',\n            options: {\n                components: {\n                    SyncComp: '/components/sync-comp.vue',\n\n                    // Mapping to an object makes it asynchronous\n                    AsyncComp: {\n                        component: '/components/async-comp.vue',\n\n                        // Optional configs\n                        loading: '/components/loading.vue',\n                        error: '/components/error.vue',\n                        magicComments: ['webpackChunkName: \"async-comps\"']\n                    }\n                }\n            }\n        },\n        'vue-loader'\n    ]\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\t\u003csummary\u003e\u003cstrong\u003eAsynchronously load components prefixed with `async-`\u003c/strong\u003e\u003c/summary\u003e\n\t\u003cbr\u003e\n\nReturn an object to make it asynchronous. Refer to the **Options** section for the object schema.\n\nThis demo shows how prefixing your components with `async-` in the template can make them asynchronously loaded.\n\n```js\n{\n    test: /\\.vue$/,\n    use: [\n        {\n            loader: 'vue-import-loader',\n            options: {\n                components({ kebab }) {\n                    if (kebab.startsWith('async-')) {\n                        return {\n                            component: `/components/${kebab.replace(/^async-/)}.vue`,\n\n                            // Optional configs\n                            loading: '/components/loading.vue',\n                            error: '/components/error.vue',\n                            magicComments: ['webpackChunkName: \"async-comps\"']\n                        };\n                    }\n\n                    return `/components/${kebab}.vue`;\n                }\n            }\n        },\n        'vue-loader'\n    ]\n}\n```\n\u003c/details\u003e\n\n\n## ⚙️ Options\n- `components` `Object|Function`\n  - `Object` Similar to Vue's `components` hash. Key is the component tag in kebab-case or PascalCase. \n      - Value can be:\n        - `String`: Component path for synchronous loading (supports aliases)\n        - `Object`: Component data for [asynchronous loading](https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components) meeting the following schema:\n\n\n  ```js\n  {\n      // Component path (Required)\n      component: '...',\n\n      // Loading component path\n      loading: '...',\n\n      // Error component path\n      error: '...',\n\n      // Delay in ms before Loading component is displayed\n      delay: 200,\n\n      // Timeout in ms before Error component is displayed\n      timeout: Infinity,\n\n      // Magic comments to configure the dynamic import:\n      // https://webpack.js.org/api/module-methods/#magic-comments\n      magicComponents: [\n          'webpackChunkName: \"my-chunk-name\"'\n      ]\n  }\n  ```\n\n  - `Function` `({ kebab, pascal }, fromComponent)`\n    - Use a function to dynamically resolve component tags to component paths. Supports outputting a string for synchronous, and an object for asynchronous imports as defined above. For example, this function resolves components to the \"components\" directory:\n    ```js\n    components({ kebab }, fromComponent) {\n    \tconst componentPath = `../components/${kebab}.vue`;\n    \tif (fs.existsSync(componentPath)) {\n    \t\treturn `@/components/${kebab}`;\n    \t}\n    }\n    ```\n\n- `functional` (_Experimental_) `Boolean` (Default: `false`)\n  - Whether to resolve components in functional components. Functional components are [known to not support the `components` hash](https://github.com/vuejs/vue-loader/issues/1013) but can be hacked around by registering the components to the parent instead. Since this feature mutates the parent's `component` hash, it is disabled by default.\n\n## 💁‍♂️ FAQ\n### How's this different from Vue's [global registration](https://vuejs.org/v2/guide/components-registration.html#Global-Registration)?\n- **Global registration**\n  - Bundles-in registered components regardless of whether they're actually used\n  - Registers components to the Vue runtime, making them available to all-components\n    - Could lead to component name collision in large code-bases\n\n- **Vue Import loader**\n  - Only bundles-in components that it detects in the app's Vue component templates\n  - Components are registered locally per-component for optimal code-splitting\n  - Nuanced control over which files get what components via resolution function\n\n### How's this different from [Nuxt.js Components](https://github.com/nuxt/components)?\n- **Nuxt.js Components**\n  - Designed specifically for [Nuxt.js](https://nuxtjs.org)\n  - Automatically resolves components in the \"components\" directory\n  - Supports async components but not the full API (eg. `loading`, `error`, `delay`, `timeout`)\n\n- **Vue Import loader**\n  - Supports any Webpack build\n  - Resolves components using a user-configured component-map or a resolution function\n  - Has built-in static analysis to detect registered components\n  - Supports the full [async component API](https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components)\n  - Supports dynamic components if possible values are inline\n    - eg. `\u003ccomponent :is=\"condition ? 'comp-a' : 'comp-b'\"\u003e`\n  - Supports [functional components](https://github.com/vuejs/vue-loader/issues/1013)\n\n### Why wouldn't I want to use this?\nThe costs of implicitly registering components locally is close to [registering components globally](https://vuejs.org/v2/guide/components-registration.html#Global-Registration).\n\n- The benefit this has over global registration is that it doesn't import components blindly at the top-level of your App, but instead, imports them intelligently at each detected usage. Unused components will not be bundled-in.\n\n- **Maintainability** Your components might become harder to maintain because of the lack of explicitly declared dependencies.\n  - **Automation magic** It's better to have code you understand and can control than to leave it to _magic_.\n  - **Debugging** If there's a bug in your resolver, it might not be an obvious place to look or troubleshoot.\n\n- **Build-tool coupling** Module-level concerns are introduced into the build configuration; perhaps comparable to creating aliases. Doing this couples the app to the build via config and makes it harder to migrate to a different environment (new tools, upgrades, etc).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fvue-import-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprivatenumber%2Fvue-import-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fvue-import-loader/lists"}