{"id":16625498,"url":"https://github.com/aleclarson/esbuild-extra","last_synced_at":"2026-02-28T23:02:49.047Z","repository":{"id":144820980,"uuid":"616684792","full_name":"aleclarson/esbuild-extra","owner":"aleclarson","description":"Extra features for esbuild plugins (like onTransform hook)","archived":false,"fork":false,"pushed_at":"2025-04-01T00:58:17.000Z","size":76,"stargazers_count":17,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-15T11:54:52.185Z","etag":null,"topics":["esbuild"],"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/aleclarson.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":"2023-03-20T21:50:40.000Z","updated_at":"2025-07-07T07:13:53.000Z","dependencies_parsed_at":"2024-06-19T16:04:17.403Z","dependency_job_id":"68308355-4561-499c-bde5-bbdaed8e52f1","html_url":"https://github.com/aleclarson/esbuild-extra","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/aleclarson/esbuild-extra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fesbuild-extra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fesbuild-extra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fesbuild-extra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fesbuild-extra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aleclarson","download_url":"https://codeload.github.com/aleclarson/esbuild-extra/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fesbuild-extra/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003173,"owners_count":26083533,"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-10-10T02:00:06.843Z","response_time":62,"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":["esbuild"],"created_at":"2024-10-12T04:05:55.251Z","updated_at":"2025-10-10T07:19:23.535Z","avatar_url":"https://github.com/aleclarson.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esbuild-extra\n\nThe lighter alternative to `@chialab/esbuild-rna` that extends `esbuild` plugins with the following new features:\n\n- `onTransform` build hook for co-operative file transformation (with sourcemap support)\n- `onResolved` build hook for manipulation of `onResolve` results\n- `load` build method for loading a file via `onLoad` and `onTransform` hooks\n- `emitChunk` and `emitFile` build methods for dynamically generated outputs\n- `resolveLocallyFirst` build method for path resolution where local files are preferred, but plugin-resolved paths are used otherwise\n\nThat's it, for now!\n\nThis package is ~6x smaller than `@chialab/esbuild-rna` according to PackagePhobia (see ~1 MB [here](https://packagephobia.com/result?p=esbuild-extra) and ~6 MB [here](https://packagephobia.com/result?p=%40chialab%2Fesbuild-rna)).\n\n## Usage\n\nApart from TypeScript typings, the only exports are `wrapPlugins` and `getBuildExtensions`.\n\nThe `wrapPlugins` function can be used by build tools to provide the features of `esbuild-extra` to every esbuild plugin. In this case, I also recommend importing `esbuild-extra/global` inan ambient `.d.ts` file to transparently propagate our `PluginBuild` extensions to downstream TypeScript users.\n\n```ts\nimport { wrapPlugins } from 'esbuild-extra'\n\n// It returns a new object where everything is identical except the plugins are wrapped!\nesbuildOptions = wrapPlugins(esbuildOptions)\n```\n\nIf you're writing a standalone esbuild plugin, you'll want to use `getBuildExtensions` instead. Just note that your plugin won't play nicely with other plugins with `onLoad` hooks if they don't also use this package (but everything works fine if the other plugin isn't trying to load the files you want to transform).\n\n```ts\nimport { getBuildExtensions } from 'esbuild-extra'\n\nexport default {\n  name: 'my-esbuild-plugin',\n  setup(build) {\n    const { onTransform } = getBuildExtensions(build, 'my-esbuild-plugin')\n\n    onTransform({ loaders: ['tsx'] }, async args =\u003e {\n      // Transform args.code and return a { code, map } object when you're ready!\n    })\n  },\n}\n```\n\n### onTransform hooks\n\nHere are some tips about the `onTransform` feature.\n\n- If no `namespace` is defined for an `onTransform` hook, it will be applied to every compatible file regardless of the file's namespace. You can use `namespace: \"file\"` to only affect real files without a custom namespace.\n\n- If an `onTransform` hook is targeted at `.js` files, it will also be applied to `.jsx`, `.ts`, and `.tsx` files, but only after any `onTransform` hooks targeting those specific extensions are applied and also after the file is transpiled to plain JavaScript. Similarly, this works for `onTransform` hooks targeting `.jsx` files or `.ts` files (both applied to `.tsx` files after transpilation).\n\n## Prior art\n\n- [@chialab/esbuild-rna](https://github.com/chialab/rna/tree/main/packages/esbuild-rna)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleclarson%2Fesbuild-extra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faleclarson%2Fesbuild-extra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleclarson%2Fesbuild-extra/lists"}