Skip to content

Add support + docs for custom esbuild plugins #1270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 25, 2024

Conversation

ericallam
Copy link
Member

@ericallam ericallam commented Aug 23, 2024

This PR adds support for adding custom esbuild plugins to the build through the esbuildPlugin build extension:

import { defineConfig } from "@trigger.dev/sdk/v3";
import { esbuildPlugin } from "@trigger.dev/build/extensions";
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";

export default defineConfig({
  project: "<project ref>",
  build: {
    extensions: [
      esbuildPlugin(
        sentryEsbuildPlugin({
          org: process.env.SENTRY_ORG,
          project: process.env.SENTRY_PROJECT,
          authToken: process.env.SENTRY_AUTH_TOKEN,
        }),
        // optional - only runs during the deploy command, and adds the plugin to the end of the list of plugins
        { placement: "last", target: "deploy" }
      ),
    ],
  },
});

prisma improvement

If you have multiple generator statements defined in your schema file, you can pass in the clientGenerator option to specify the prisma-client-js generator, which will prevent other generators from being generated:

datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL")
  directUrl = env("DATABASE_URL_UNPOOLED")
}

// We only want to generate the prisma-client-js generator
generator client {
  provider        = "prisma-client-js"
}

generator kysely {
  provider     = "prisma-kysely"
  output       = "../../src/kysely"
  enumFileName = "enums.ts"
  fileName     = "types.ts"
}
import { defineConfig } from "@trigger.dev/sdk/v3";
import { prismaExtension } from "@trigger.dev/build/extensions/prisma";

export default defineConfig({
  project: "<project ref>",
  build: {
    extensions: [
      prismaExtension({
        schema: "prisma/schema.prisma",
        clientGenerator: "client",
      }),
    ],
  },
});

--env-file support for dev and deploy

You can now pass the path to your local .env file using the --env-file flag during dev and deploy commands:

npx [email protected] dev --env-file ../../.env
npx [email protected] deploy --env-file ../../.env

The .env file works slightly differently in dev vs deploy:

  • In dev, the .env file is loaded into the CLI's process.env and also into the environment variables of the Trigger.dev environment.
  • In deploy, the .env file is loaded into the CLI's process.env but not into the environment variables of the Trigger.dev environment. If you want to sync the environment variables from the .env file to the Trigger.dev environment variables, you can use the syncEnvVars build extension.

Copy link

changeset-bot bot commented Aug 23, 2024

🦋 Changeset detected

Latest commit: 2a59665

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Aug 23, 2024

commit: 2a59665

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/build@1270
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev@1270
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/core@1270
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/sdk@1270

Open in Stackblitz

@matt-aitken matt-aitken merged commit e30beb7 into main Aug 25, 2024
5 checks passed
@matt-aitken matt-aitken deleted the build-system-beta/esbuild-plugins branch August 25, 2024 15:04
D-K-P pushed a commit that referenced this pull request Sep 9, 2024
* Add support + docs for custom esbuild plugins

* Fixed the missing subpath export

* Add support for specifying the prisma client generator

* Add `—env-file` support to dev and deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants