{"id":13775216,"url":"https://github.com/exuanbo/rollup-plugin-esbuild-transform","last_synced_at":"2025-11-10T12:04:25.152Z","repository":{"id":56736920,"uuid":"399143540","full_name":"exuanbo/rollup-plugin-esbuild-transform","owner":"exuanbo","description":"Use esbuild with Rollup to transform any supported content types.","archived":false,"fork":false,"pushed_at":"2022-12-22T11:18:38.000Z","size":679,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T06:57:04.197Z","etag":null,"topics":["esbuild","rollup","rollup-plugin","rollup-plugin-esbuild","rollup-plugin-esbuild-transform"],"latest_commit_sha":null,"homepage":"","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/exuanbo.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}},"created_at":"2021-08-23T14:53:48.000Z","updated_at":"2023-10-23T18:26:17.000Z","dependencies_parsed_at":"2023-01-30T07:31:31.839Z","dependency_job_id":null,"html_url":"https://github.com/exuanbo/rollup-plugin-esbuild-transform","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exuanbo%2Frollup-plugin-esbuild-transform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exuanbo%2Frollup-plugin-esbuild-transform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exuanbo%2Frollup-plugin-esbuild-transform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exuanbo%2Frollup-plugin-esbuild-transform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exuanbo","download_url":"https://codeload.github.com/exuanbo/rollup-plugin-esbuild-transform/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249173061,"owners_count":21224481,"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":["esbuild","rollup","rollup-plugin","rollup-plugin-esbuild","rollup-plugin-esbuild-transform"],"created_at":"2024-08-03T17:01:35.432Z","updated_at":"2025-11-10T12:04:20.088Z","avatar_url":"https://github.com/exuanbo.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Transpilation"],"readme":"# rollup-plugin-esbuild-transform\n\n\u003e Use [`esbuild`](https://esbuild.github.io/api/#transform-api) with Rollup to transform any supported content types.\n\n[![npm](https://img.shields.io/npm/v/rollup-plugin-esbuild-transform.svg)](https://www.npmjs.com/package/rollup-plugin-esbuild-transform)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/exuanbo/rollup-plugin-esbuild-transform/nodejs.yml.svg?branch=main)](https://github.com/exuanbo/rollup-plugin-esbuild-transform/actions?query=workflow)\n[![Codecov branch](https://img.shields.io/codecov/c/gh/exuanbo/rollup-plugin-esbuild-transform/main.svg?token=hyLDj7tMfT)](https://app.codecov.io/gh/exuanbo/rollup-plugin-esbuild-transform/)\n[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)\n\n## Why\n\n[`esbuild`](https://esbuild.github.io/api/#build-api) as a bundler has some problems such as [#475](https://github.com/evanw/esbuild/issues/475) which has still not been fixed since Oct, 2020.\n\n[`rollup-plugin-esbuild`](https://github.com/egoist/rollup-plugin-esbuild) is great but there is no simpler way to use multiple `loader` with different options, and for some reason it does not provide all available options from [esbuild transform API](https://esbuild.github.io/api/#transform-api).\n\n## Install\n\n```sh\nnpm install -D esbuild rollup-plugin-esbuild-transform\n```\n\n## Example\n\n```js\n// rollup.config.js\n\nimport { join } from 'path'\nimport esbuild from 'rollup-plugin-esbuild-transform'\n\nexport default {\n  // ...\n  plugins: [\n    esbuild([\n      {\n        loader: 'json'\n      },\n      {\n        loader: 'tsx',\n        legalComments: 'eof'\n      },\n      {\n        loader: 'ts',\n        include: /\\.tsx?$/,\n        tsconfig: join(__dirname, 'tsconfig.json')\n      },\n      {\n        output: true,\n        minify: true,\n        target: 'es2015'\n      }\n    ])\n  ]\n}\n```\n\n## Options\n\n```ts\n// index.d.ts\n\nimport { TransformOptions as EsbuildTransformOptions } from 'esbuild'\nimport { FilterPattern } from '@rollup/pluginutils'\nimport { Plugin } from 'rollup'\n\nexport interface TransformOptions extends EsbuildTransformOptions {\n  tsconfig?: string\n}\n\nexport interface Options extends TransformOptions {\n  output?: boolean\n  include?: FilterPattern\n  exclude?: FilterPattern\n}\n\ndeclare function esbuildTransform(options?: Options | Options[]): Plugin\nexport default esbuildTransform\n```\n\nThis plugin uses the same options from [esbuild transform API](https://esbuild.github.io/api/#transform-api).\n\n`tsconfig` is the path to `tsconfig.json` file relative to `process.cwd()`. It will not be used if `tsconfigRaw` is provided.\n\n`output` is for indicating whether this transformation should be performed after the chunk (bundle) has been rendered.\n\n`include` and `exclude` are [`picomatch`](https://github.com/micromatch/picomatch#globbing-features) patterns. They can be `string | RegExp | Array\u003cstring | RegExp\u003e`. When supplied they will override the default values.\n\nIf `output: true`, then the options `include` and `exclude` will be applied to the chunk's filename from `RollupOptions.output.file`.\n\n### `include`\n\nDefault to \u003ccode\u003enew RegExp(\\`\\\\\\\\.(?:\\${loaderExtensions.join('|')})\\$\\`)\u003c/code\u003e (supports `.cjs`, `.mjs`, `.cts`, `.mts`), or `undefined` (match any filename) if `output: true`.\n\nIf a file is matched by more than one pattern (as the example below), the options other than `loader` will be ***shallowly*** merged into and possibly override the previous ones.\n\n```js\n// options\n[\n  {\n    loader: 'tsx',\n    legalComments: 'eof'\n  },\n  {\n    loader: 'ts',\n    include: /\\.tsx?$/,\n    tsconfig: join(__dirname, 'tsconfig.json')\n  }\n]\n\n// the final transform options for `index.tsx` will become\n{\n  loader: 'tsx',\n  legalComments: 'eof',\n  tsconfig: join(__dirname, 'tsconfig.json')\n}\n```\n\n### `exclude`\n\nDefault to `/node_modules/`, or `undefined` if `output: true`.\n\nIt takes priority over `include`.\n\n### Other default options\n\n```js\n// output: false | undefined\n{\n  format: options.loader === 'json' ? 'esm' : undefined,\n  sourcefile: id, // the resolved file path\n  sourcemap: true,\n  ...options\n}\n\n// output: true\n{\n  sourcefile: chunk.fileName,\n  sourcemap: true,\n  ...options\n}\n```\n\n## License\n\n[MIT License](https://github.com/exuanbo/rollup-plugin-esbuild-transform/blob/main/LICENSE) © 2021 [Exuanbo](https://github.com/exuanbo)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexuanbo%2Frollup-plugin-esbuild-transform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexuanbo%2Frollup-plugin-esbuild-transform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexuanbo%2Frollup-plugin-esbuild-transform/lists"}