Skip to content

Commit 9019370

Browse files
committed
Add support + docs for custom esbuild plugins
1 parent 6744617 commit 9019370

File tree

8 files changed

+229
-43
lines changed

8 files changed

+229
-43
lines changed

.changeset/rotten-eggs-occur.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@trigger.dev/build": patch
3+
"@trigger.dev/core": patch
4+
---
5+
6+
Added support for custom esbuild plugins

docs/guides/new-build-system-preview.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,33 @@ export default defineConfig({
245245
});
246246
```
247247

248+
### esbuild plugins
249+
250+
You can now add esbuild plugins to customize the build process using the `esbuildPlugin` build extension. The example below shows how to automatically upload sourcemaps to Sentry using their esbuild plugin:
251+
252+
```ts
253+
import { defineConfig } from "@trigger.dev/sdk/v3";
254+
import { esbuildPlugin } from "@trigger.dev/build/extensions";
255+
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
256+
257+
export default defineConfig({
258+
project: "<project ref>",
259+
build: {
260+
extensions: [
261+
esbuildPlugin(
262+
sentryEsbuildPlugin({
263+
org: process.env.SENTRY_ORG,
264+
project: process.env.SENTRY_PROJECT,
265+
authToken: process.env.SENTRY_AUTH_TOKEN,
266+
}),
267+
// optional - only runs during the deploy command, and adds the plugin to the end of the list of plugins
268+
{ placement: "last", target: "deploy" }
269+
),
270+
],
271+
},
272+
});
273+
```
274+
248275
## Known issues
249276

250277
- Path aliases are not yet support in your `trigger.config.ts` file. To workaround this issue you'll need to rewrite path aliases to their relative paths. (See [this](https://github.com/unjs/jiti/issues/166) and [this](https://knip.dev/reference/known-issues#path-aliases-in-config-files)) for more info.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "@trigger.dev/core/v3/build";

packages/build/src/extensions/typescript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BuildExtension, createExtensionForPlugin } from "@trigger.dev/core/v3/build";
1+
import { BuildExtension, esbuildPlugin } from "@trigger.dev/core/v3/build";
22
import type { Plugin } from "esbuild";
33
import { readFile } from "node:fs/promises";
44
import { readTSConfig } from "pkg-types";
@@ -13,7 +13,7 @@ export type EmitDecoratorMetadataOptions = {
1313
};
1414

1515
export function emitDecoratorMetadata(options: EmitDecoratorMetadataOptions = {}): BuildExtension {
16-
return createExtensionForPlugin(plugin(options));
16+
return esbuildPlugin(plugin(options));
1717
}
1818

1919
function plugin(options: EmitDecoratorMetadataOptions = {}): Plugin {

packages/core/src/v3/build/extensions.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { BuildManifest, BuildTarget } from "../schemas/build.js";
22
import type { Plugin } from "esbuild";
33
import { ResolvedConfig } from "./resolvedConfig.js";
44

5-
export function createExtensionForPlugin(
6-
plugin: Plugin,
7-
options: RegisterPluginOptions = {}
8-
): BuildExtension {
5+
export function esbuildPlugin(plugin: Plugin, options: RegisterPluginOptions = {}): BuildExtension {
96
return {
107
name: plugin.name,
118
onBuildStart(context) {

0 commit comments

Comments
 (0)