{"id":14984946,"url":"https://github.com/twosaturdayscode/esbuild-deno-plugin","last_synced_at":"2025-04-10T23:14:01.553Z","repository":{"id":253025107,"uuid":"842233197","full_name":"twosaturdayscode/esbuild-deno-plugin","owner":"twosaturdayscode","description":"Deno modules resolution and loading for esbuild.","archived":false,"fork":false,"pushed_at":"2025-02-28T10:07:26.000Z","size":139,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T23:13:54.357Z","etag":null,"topics":["deno","esbuild","esbuild-plugin"],"latest_commit_sha":null,"homepage":"https://jsr.io/@duesabati/esbuild-deno-plugin","language":"TypeScript","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/twosaturdayscode.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-14T00:06:29.000Z","updated_at":"2025-03-09T08:54:09.000Z","dependencies_parsed_at":"2024-09-07T15:28:51.606Z","dependency_job_id":"31b00875-7f9e-4b80-8021-d2b6b48934f3","html_url":"https://github.com/twosaturdayscode/esbuild-deno-plugin","commit_stats":{"total_commits":54,"total_committers":2,"mean_commits":27.0,"dds":0.05555555555555558,"last_synced_commit":"d03c5c526ef55777c8c83cf64e2edd8f549757b3"},"previous_names":["twosaturdayscode/esbuild-deno-plugin"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twosaturdayscode%2Fesbuild-deno-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twosaturdayscode%2Fesbuild-deno-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twosaturdayscode%2Fesbuild-deno-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twosaturdayscode%2Fesbuild-deno-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twosaturdayscode","download_url":"https://codeload.github.com/twosaturdayscode/esbuild-deno-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312135,"owners_count":21082638,"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":["deno","esbuild","esbuild-plugin"],"created_at":"2024-09-24T14:09:54.396Z","updated_at":"2025-04-10T23:14:01.521Z","avatar_url":"https://github.com/twosaturdayscode.png","language":"TypeScript","readme":"# esbuild-deno-plugin\n[![deno doc](https://jsr.io/badges/@duesabati/esbuild-deno-plugin)](https://jsr.io/@duesabati/esbuild-deno-plugin)\n\n\u003e [!IMPORTANT]\n\u003e This is a fork and rewrite of the original work of [esbuild_deno_loader](https://github.com/lucacasonato/esbuild_deno_loader).\n\u003e I've added features that were missing and refactored the code to be more readable and maintainable.\n\u003e\n\u003e I've also dropped the \"portable\" use case since it adds a lot of complexity \n\u003e that I did not fully understand and I think it's better to keep things simple.\n\u003e\n\u003e I may create another plugin that does that in the future but for now I'm focusing on this one.\n\nDeno modules resolution and loading for `esbuild`.\n\n## Features\n\n### Already available\n\n- Support for `file:`, `https:`, and `data:` specifiers.\n- Support for `npm:` specifiers.\n- Support for `jsr:` specifiers.\n- Support for import maps (including embedded into `deno.json`).\n- Use Deno's global cache directory.\n\n### Workspaces\n\nRecently added [`workspaces`](https://docs.deno.com/runtime/manual/basics/workspaces/)\nfeature is supported, not only it enables you to bundle workspace members but it\nresolves their import maps too! Look at the following example.\n\nIf you have a `snake` package/member like this:\n\n```typescript\n// packages/snake/mod.ts (workspace member)\nimport { toSnakeCase } from \"@std/text\"\n\nexport function snake(hiss: string) {\n  return toSnakeCase(hiss)\n}\n```\n\nIt can have an import map that defines the \"defaults\" of your imports.\n\n```jsonc\n// packages/snake/deno.json\n{\n  \"name\": \"@myscope/snake\",\n  \"version\": \"0.1.0\",\n  \"exports\": \"./mod.ts\",\n  \"imports\": {\n    \"@std/text\": \"jsr:@std/text@1.0.3\"\n  }\n}\n```\n\nThen you refer to is as usual.\n\n```typescript\n// apps/web/main.ts\nimport { snake } from \"@myscope/snake\"\n\nfunction main() {\n  console.log(snake(\"hello world\"))\n}\n\nmain()\n```\n\n```jsonc\n// apps/web/deno.json\n{\n  \"workspace\": [\"./packages/snake\"]\n}\n```\n\nThe plugin simply works by adding `scopes` to the main `deno.json` imports map\noverrding the member's imports, obviously your own written scopes takes\nprecendence.\n\n### Vendoring\n\nSupport for [`vendoring`](https://docs.deno.com/runtime/manual/basics/vendoring/)\ncoming soon.\n\n## Example\n\nThis example bundles an entrypoint into a single ESM output.\n\n```ts\nimport * as esbuild from \"npm:esbuild@0.23.0\";\n\nimport { denoPlugins } from \"jsr:@duesabati/esbuild-deno-plugin@^0.0.1\";\n\nconst result = await esbuild.build({\n  plugins: [...denoPlugins()],\n  entryPoints: [\"https://deno.land/std@0.185.0/bytes/mod.ts\"],\n  outfile: \"./dist/bytes.esm.js\",\n  bundle: true,\n  format: \"esm\",\n});\n\nconsole.log(result.outputFiles);\n\nesbuild.stop();\n```\n\n### Permissions\n\nThis plugins requires the following permissions:\n\n- `--allow-read` if you need to resolve local files.\n- `--allow-net` if you need to resolve remote files.\n\nIf the program is run with `--allow-run`, the plugin will use the `deno` binary\nto resolve remote files. This allows the plugin to re-use the Deno module cache.\n\n## Usage with other plugins\n\nFor some use-cases these plugins should be manually instantiated. For example if\nyou want to add your own loader plugins that handles specific file extensions or\nURL schemes, you should insert these plugins between the Deno resolver, and Deno\nloader.\n\n\u003e [!NOTE]\n\u003e In most cases, the `denoResolverPlugin` should be the first plugin in the plugin array.\n\nFor more details read the \"How it works\" section.\n\n## How it works\n\nThe library consists of two separate plugins (that are however most commonly\nused together):\n\n1. The resolver, which resolves specifiers within a file relative to the file\n   itself ('absolutization'), taking into account _import maps_.\n1. The loader, which takes a fully resolved specifier, and attempts to load it.\n   If the loader encounters redirects, these are processed until a final module\n   is found.\n\nMost commonly these two plugins are used together, chained directly after each\nother using the denoPlugins() function. This function returns an array of\nesbuild.Plugin instances, which can be spread directly into the plugins array of\nthe esbuild build options.\n\n@todo: Further explain precautions about usage with other plugins.\n\n## Why this project?\n\nI've decided to rewrite the original project found at\n[esbuild_deno_loader](https://github.com/lucacasonato/esbuild_deno_loader) as a\nrefactor exercise/challenge and to understand what was going on. I also think\nthat the code is more readable and better designed but this is a **completely\npersonal opinion** and **NOT** a judgement on the original work.\n\nWith that being said, I really hope this library helps you.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwosaturdayscode%2Fesbuild-deno-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwosaturdayscode%2Fesbuild-deno-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwosaturdayscode%2Fesbuild-deno-plugin/lists"}