{"id":16146547,"url":"https://github.com/voxpelli/plugin-importer","last_synced_at":"2025-07-09T09:34:15.911Z","repository":{"id":187735766,"uuid":"672599587","full_name":"voxpelli/plugin-importer","owner":"voxpelli","description":"  Recursively imports a plugin tree in order of dependencies","archived":false,"fork":false,"pushed_at":"2025-04-03T19:46:21.000Z","size":41,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-17T04:36:18.853Z","etag":null,"topics":["plugin-system"],"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/voxpelli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["voxpelli"]}},"created_at":"2023-07-30T16:21:31.000Z","updated_at":"2025-04-03T19:46:24.000Z","dependencies_parsed_at":"2023-08-12T00:12:52.719Z","dependency_job_id":"cebe6607-d045-46f0-814e-3b477abe3b06","html_url":"https://github.com/voxpelli/plugin-importer","commit_stats":null,"previous_names":["voxpelli/plugin-importer"],"tags_count":3,"template":false,"template_full_name":"voxpelli/node-module-template","purl":"pkg:github/voxpelli/plugin-importer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fplugin-importer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fplugin-importer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fplugin-importer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fplugin-importer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voxpelli","download_url":"https://codeload.github.com/voxpelli/plugin-importer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fplugin-importer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259466224,"owners_count":22862242,"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","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":["plugin-system"],"created_at":"2024-10-10T00:20:30.290Z","updated_at":"2025-06-12T12:37:35.200Z","avatar_url":"https://github.com/voxpelli.png","language":"JavaScript","readme":"# Plugin Importer\n\nRecursively imports a plugin tree in order of dependencies\n\n[![npm version](https://img.shields.io/npm/v/plugin-importer.svg?style=flat)](https://www.npmjs.com/package/plugin-importer)\n[![npm downloads](https://img.shields.io/npm/dm/plugin-importer.svg?style=flat)](https://www.npmjs.com/package/plugin-importer)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-7fffff?style=flat\u0026labelColor=ff80ff)](https://github.com/neostandard/neostandard)\n[![Module type: ESM](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)\n[![Types in JS](https://img.shields.io/badge/types_in_js-yes-brightgreen)](https://github.com/voxpelli/types-in-js)\n[![Follow @voxpelli.com](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpublic.api.bsky.app%2Fxrpc%2Fapp.bsky.actor.getProfile%2F%3Factor%3Dvoxpelli.com\u0026query=%24.followersCount\u0026style=social\u0026logo=bluesky\u0026label=Follow%20%40voxpelli.com)](https://bsky.app/profile/voxpelli.com)\n[![Follow @voxpelli@mastodon.social](https://img.shields.io/mastodon/follow/109247025527949675?domain=https%3A%2F%2Fmastodon.social\u0026style=social)](https://mastodon.social/@voxpelli)\n\n## Usage\n\n### Simple\n\n```javascript\nimport { resolvePlainPlugins } from 'plugin-importer';\n\nconst loadedPlugins = await resolvePlainPlugins([\n  './test-dependency',\n  'module-dependency',\n], {\n  meta: import.meta, // Ensures local paths are resolved in relation to this file\n});\n```\n\n### Powerful\n\n```javascript\nimport { loadPlugins, resolvePluginsInOrder } from 'plugin-importer';\n\n/**\n * @param {unknown} module\n * @param {import('plugin-importer').ProcessPluginContext} context\n * @returns {SupersetOfPluginDefinition}\n */\nfunction processPlugin (module, { normalizedPluginName, pluginDir }) {\n  // Whatever other stuff you want to do to resolve the SupersetOfPluginDefinition\n}\n\nconst pluginLoader = loadPlugins(processPlugin, {\n  meta: import.meta, // Ensures local paths are resolved in relation to this file\n});\n\n// loadedPlugins will be an ordered array of SupersetOfPluginDefinition,in order of who depends on whom\nconst loadedPlugins = await resolvePluginsInOrder(\n  [\n    './test-dependency',\n    'module-dependency',\n  ],\n  pluginLoader\n);\n```\n\n## Exports\n\n### Core exports\n\n* `assertToBePluginDefinition(value)` – throws if `value` isn't a valid `PluginDefinition` (and correctly narrows the type when used with TypeScript)\n * `isPluginDefinition(value)` – returns `true` if `value` is a valid `PluginDefinition` (and correctly narrows the type when used with TypeScript)\n* `loadPlugins(processPlugin, [LoadPluginsOptions])` – creates the plugin loader responsible for loading a valid plugin\n* `resolvePluginsInOrder(plugins, pluginLoader, [allowOptionalDependencies])` – resolves and loads plugins and returns them with the plugin depended upon first and the plugins depending on them last\n\n### Plain plugins exports\n\n* `loadPlainPlugins([LoadPluginsOptions])` – like `loadPlugins`, but geared to load pure `PluginDefinition` rather than supersets\n* `processPlainPlugin` – the `processPlugin` that's used in `loadPlainPlugins`, should never be needed to be called diretcly\n* `resolvePlainPlugins(dependencies, [LoadPluginsOptions])` – shortcut for calling `resolvePluginsInOrder` with `loadPlainPlugins`\n\n### Utils exports\n\n* `getExtensionlessBasename(value)` – like [`path.basename(value)`](https://nodejs.org/api/path.html#pathbasenamepath-suffix) but removes file extensions\n* `importAbsolutePath(absolutePath)` – like [`import(absolutePath)`](https://nodejs.org/api/esm.html#import-expressions) but made to easily work with absolute paths on Windows\n\n## Types\n\n* `LoadPluginsOptions` – the optional options for `loadPlugins`. Contains:\n  * `cwd` – the working directory to load relative plugin paths from\n  * `meta` – convenience option for setting `cwd` by giving an [`import.meta`](https://nodejs.org/api/esm.html#importmeta)\n  * `prefix` – a prefix that will be added to dependency names. Eg `example-prefix` would be added to `foo` to make `example-prefix-foo` and to `@voxpelli` to make `@voxpelli/example-prefix`, but eg. `example-prefix-foo` would not be prefixed as it already has the prefix and `@voxpelli/foo` would neither get prefixed. This is along the lines of what `eslint` does with [`eslint-config`](https://eslint.org/docs/latest/extend/shareable-configs#creating-a-shareable-config) prefixes\n* `PluginDefinition` – the basic definition of a plugin. All loaded plugins are expected to conform to this or a superset of this.\n* `ProcessPluginContext` – the context given to `processPlugin`\n","funding_links":["https://github.com/sponsors/voxpelli"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpelli%2Fplugin-importer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoxpelli%2Fplugin-importer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpelli%2Fplugin-importer/lists"}