{"id":14155930,"url":"https://github.com/kravetsone/esbuild-plugin-autoload","last_synced_at":"2025-04-11T15:33:10.229Z","repository":{"id":244575458,"uuid":"815646609","full_name":"kravetsone/esbuild-plugin-autoload","owner":"kravetsone","description":"Bun/esbuild plugin for work with autoload at runtime","archived":false,"fork":false,"pushed_at":"2025-02-04T17:28:12.000Z","size":59,"stargazers_count":7,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T16:01:52.490Z","etag":null,"topics":["autoload","bun-plugin","elysia","esbuild-plugin","plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kravetsone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-06-15T17:57:51.000Z","updated_at":"2025-02-04T17:27:42.000Z","dependencies_parsed_at":"2024-06-15T19:20:23.605Z","dependency_job_id":"b41ad611-dcc4-4817-942c-01f99f03036b","html_url":"https://github.com/kravetsone/esbuild-plugin-autoload","commit_stats":null,"previous_names":["kravetsone/esbuild-plugin-autoload"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kravetsone%2Fesbuild-plugin-autoload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kravetsone%2Fesbuild-plugin-autoload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kravetsone%2Fesbuild-plugin-autoload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kravetsone%2Fesbuild-plugin-autoload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kravetsone","download_url":"https://codeload.github.com/kravetsone/esbuild-plugin-autoload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248431944,"owners_count":21102293,"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":["autoload","bun-plugin","elysia","esbuild-plugin","plugin"],"created_at":"2024-08-17T08:05:05.934Z","updated_at":"2025-04-11T15:33:10.220Z","avatar_url":"https://github.com/kravetsone.png","language":"TypeScript","funding_links":[],"categories":["others"],"sub_categories":[],"readme":"# esbuild-plugin-autoload\n\nThis [esbuild](https://esbuild.github.io/)/[Bun](https://bun.sh/docs/bundler) bundler plugin helps to use libraries for `autoload` endpoints, command and etc. At the build stage, it obtains what needs to be `import`-ed and includes it in the final file\n\n\u003e [!IMPORTANT]\n\u003e You need `Bun` or `Node@\u003e=22` to run this plugin\n\n# [Bun build](https://bun.sh/docs/bundler) usage\n\n```ts\n// @filename: build.ts\nimport { autoload } from \"esbuild-plugin-autoload\"; // default import also supported\n\nawait Bun.build({\n    entrypoints: [\"src/index.ts\"],\n    target: \"bun\",\n    outdir: \"out\",\n    plugins: [autoload()],\n}).then(console.log);\n```\n\nThen, build it with `bun build.ts` and run with `bun out/index.ts`\n\n### [Bun compile](https://bun.sh/docs/bundler/executables) usage\n\nYou can bundle and then compile it into a [single executable binary file](https://bun.sh/docs/bundler/executables)\n\n```ts\nimport { autoload } from \"esbuild-plugin-autoload\"; // default import also supported\n\nawait Bun.build({\n    entrypoints: [\"src/index.ts\"],\n    target: \"bun\",\n    outdir: \"out\",\n    plugins: [autoload()],\n}).then(console.log);\n\nawait Bun.$`bun build --compile out/index.js`;\n```\n\n\u003e [!WARNING]\n\u003e You cannot use it in `bun build --compile` mode without extra step ([Feature issue](https://github.com/oven-sh/bun/issues/11895))\n\n## Options\n\n| Key        | Type    | Default                            | Description                                                         |\n| ---------- | ------- | ---------------------------------- | ------------------------------------------------------------------- |\n| pattern?   | string  | \"\\*\\*\\/\\*.{ts,tsx,js,jsx,mjs,cjs}\" | [Glob patterns](\u003chttps://en.wikipedia.org/wiki/Glob_(programming)\u003e) |\n| directory? | string  | \"./src/routes\"                     | The folder where something that will be autoloaded are located      |\n| debug?     | boolean | false                              | Debug mode, will log generated code                                 |\n\nYou can also pass the directory by the first argument instead of an object with full options\n\n```ts\nawait Bun.build({\n    entrypoints: [\"src/index.ts\"],\n    target: \"bun\",\n    outdir: \"out\",\n    plugins: [autoload(\"./src/commands\")],\n}).then(console.log);\n```\n\n### [esbuild](https://esbuild.github.io/) usage\n\n```ts\n// @filename: build.ts\nimport { autoload } from \"esbuild-plugin-autoload\"; // default import also supported\nimport esbuild from \"esbuild\";\n\nawait esbuild\n    .build({\n        entrypoints: [\"src/index.ts\"],\n        outdir: \"out\",\n        bundle: true,\n        plugins: [autoload()],\n    })\n    .then(console.log);\n```\n\nThen, build it with `bunx tsx build.ts` and run with `node out/index.ts`\n\n### Supported `autoload`-ers\n\nSadly, this plugin can only work with supported libraries.\n\n-   [`elysia-autoload`](https://github.com/kravetsone/elysia-autoload)\n-   [`@gramio/autoload`](https://github.com/gramiojs/autoload)\n\n### TODO:\n\n-   [ ] Think more about multiple plugins usage with different CWD\n-   [ ] Rewrite to `unplugin`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkravetsone%2Fesbuild-plugin-autoload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkravetsone%2Fesbuild-plugin-autoload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkravetsone%2Fesbuild-plugin-autoload/lists"}