How to update to 3.0.0 from the beta
3.0.x in the latest tag. This is our first official release of v3 under the latest tag, and we recommend anyone still using packages in the beta tag to upgrade to the latest version. This guide will help you upgrade your project to the latest version of Trigger.dev.
The major changes in this release are a new build system, which is more flexible and powerful than the previous build system. We’ve also made some changes to the trigger.dev CLI to improve the developer experience.
The main features of the new build sytem are:
@trigger.dev/sdk package in your package.json:
trigger.dev CLI to use the latest release. If you run the CLI via npx you can update to the latest release like so:
trigger.dev CLI to your devDependencies, then you should update the version to point to the latest release:
npm i or the equivalent with your preferred package manager.
trigger.config.tstrigger.config.ts file.
defineConfigdefineConfig function from @trigger.dev/sdk/v3 and export the config as the default export:
dependenciesToBundledependenciesToBundle no longer makes any sense and can be removed.
defineConfig function:
external is an array of strings, where each string is the name of a dependency that should be made external. Glob expressions are also supported and use the minimatch matcher.
additionalFiles option has been moved to our new build extension system.
To use build extensions, you’ll need to add the @trigger.dev/build package to your devDependencies:
additionalFiles build extension and use it in your trigger.config.ts file:
additionalPackages option has been moved to our new build extension system.
To use build extensions, you’ll need to add the @trigger.dev/build package to your devDependencies:
additionalPackages build extension and use it in your trigger.config.ts file:
resolveEnvVars export has been moved to our new build extension system.
To use build extensions, you’ll need to add the @trigger.dev/build package to your devDependencies:
syncEnvVars build extension and use it in your trigger.config.ts file:
syncEnvVars callback function works very similarly to the deprecated resolveEnvVars handler, but now instead of returning an object with a variables key that contains the environment variables, you return an object with the environment variables directly (see the example above).
One other difference is now params.env only contains the environment variables that are set in the Trigger.dev environment variables, and not the environment variables from the process. If you want to access the environment variables from the process, you can use process.env.
See the syncEnvVars documentation for more information.
emitDecoratorMetadata tsconfig compiler option, you’ll need to enable this in the new build sytem using the emitDecoratorMetadata build extension:
@trigger.dev/build package to your devDependencies:
prismaExtension build extension and use it in your trigger.config.ts file, passing in the path to your Prisma schema file:
dev command, so you’ll need to make sure you
generate your client locally first.migrate option:
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:
esbuildPlugin build extension. The example below shows how to automatically upload sourcemaps to Sentry using their esbuild plugin:
trigger.dev CLItsc command before running the deploy command.
tsc command before deploying to Trigger.dev.
--dry-run--dry-run flag:
--env-file.env file using the --env-file flag during dev and deploy commands:
.env file works slightly differently in dev vs deploy:
dev, the .env file is loaded into the CLI’s process.env and also into the environment variables of the Trigger.dev environment.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.dev is supported via VS Code, without having to pass in any additional flags. Create a launch configuration in .vscode/launch.json:
Trigger.dev: Dev configuration in the debug panel, and set breakpoints in your tasks code.
dev command using the TRIGGER_ACCESS_TOKEN environment variable. Previously this was only supported in the deploy command.
proj_rrkpdguyagvsoktglnod)
deploy commandtrigger.config.ts file. To workaround this issue you’ll need to rewrite path aliases to their relative paths. (See this and this) for more info.*.test.ts and .spec.ts files inside the trigger dirs will be bundled and could cause issues. You’ll need to move these files outside of the trigger dirs to avoid this issue.