[TRI-2795] Add bun support
Currently if you use bun it actually just uses npm (we detect a bun lock file and fallback to using npm).
Adding official bun support would mean you could call postinstall scripts using bun and do other bun specific things. As bun is a package manager and a runtime there are various levels of support we could go to.
Just in case anybody else needs this, I was hitting version mismatch errors after updating the sdk package (with bun update).
What I had to do was to delete the bun cache (on MacOS is at /private/tmp/bunx-501-trigger.dev@beta) and everything started working again.
Otherwise with bun everything works pretty seamlessly, here's what I did:
- Install trigger.dev with
bun add @trigger.dev/[email protected] - Create a project manually on https://cloud.trigger.dev
- Create manually the
trigger.config.tson the project root folder:
import type { TriggerConfig } from '@trigger.dev/sdk/v3';
export const config: TriggerConfig = {
project: 'project id as found under project settings on https://cloud.trigger.dev',
logLevel: 'log',
retries: {
enabledInDev: true,
default: {
maxAttempts: 3,
minTimeoutInMs: 1000,
maxTimeoutInMs: 10000,
factor: 2,
randomize: true
}
},
triggerDirectories: ['./trigger'],
};
- And obviously tasks e.g.
/trigger/example.ts:
import { logger, task, wait } from '@trigger.dev/sdk/v3';
export const helloWorldTask = task({
id: 'hello-world',
run: async (payload: any, { ctx }) => {
logger.log('Hello, world!', { payload, ctx });
await wait.for({ seconds: 5 });
return {
message: 'Hello, world!'
};
}
});
You can now run it with bunx trigger.dev@beta dev.
@cellulosa What framework are you using here?
bunx trigger.dev@beta dev seems to have problems picking up the default nextjs install which creates a src/jobs folder, despite correctly changing the trigger directory in the config.
It seems the default nextjs install doesn't even make a trigger.config.ts file but when you bunx it looks for it. Maybe I'm missing something here?
You' re right I should have said... I'm working with sveltekit
This does not work for me either Now I'm getting "cannot resolve bun"