Skip to content

Commit c600ae8

Browse files
committed
Update package configuration for Zod 3-4 compatibility
The recent Zod package updates from version 3 to 4 introduce breaking changes in TypeScript compatibility that require adjustments in our project configuration files. The primary updates involve adding type annotations and modifying import statements to support the shift without breaking existing functionality. - Updated `package.json` and initialization files to align with new compatibility requirements. - Modified server task examples to explicitly use type imports for improved error handling and consistency. - Adjusted workspace and project settings to maintain compatibility and improve configuration clarity. - Provided references to current examples for better implementation guidance.
1 parent c008320 commit c600ae8

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

docs/manual-setup.mdx

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ This approach creates a dedicated tasks package that can be consumed by multiple
339339
#### 1. Set up workspace configuration
340340

341341
**Root `package.json`**:
342+
342343
```json
343344
{
344345
"name": "my-monorepo",
@@ -357,13 +358,15 @@ This approach creates a dedicated tasks package that can be consumed by multiple
357358
```
358359

359360
**`pnpm-workspace.yaml`**:
361+
360362
```yaml
361363
packages:
362364
- "apps/*"
363365
- "packages/*"
364366
```
365367
366368
**`turbo.json`**:
369+
367370
```json
368371
{
369372
"$schema": "https://turbo.build/schema.json",
@@ -387,6 +390,7 @@ packages:
387390
#### 2. Create the tasks package
388391

389392
**`packages/tasks/package.json`**:
393+
390394
```json
391395
{
392396
"name": "@repo/tasks",
@@ -405,6 +409,7 @@ packages:
405409
```
406410

407411
**`packages/tasks/trigger.config.ts`**:
412+
408413
```typescript
409414
import { defineConfig } from "@trigger.dev/sdk";
410415
@@ -426,17 +431,20 @@ export default defineConfig({
426431
```
427432

428433
**`packages/tasks/src/index.ts`**:
434+
429435
```typescript
430436
export * from "@trigger.dev/sdk"; // Export values and types from the Trigger.dev sdk
431437
```
432438

433439
**`packages/tasks/src/trigger/index.ts`**:
440+
434441
```typescript
435442
// Export tasks
436443
export * from "./example";
437444
```
438445

439446
**`packages/tasks/src/trigger/example.ts`**:
447+
440448
```typescript
441449
import { task } from "@trigger.dev/sdk";
442450
@@ -453,9 +461,12 @@ export const helloWorld = task({
453461
});
454462
```
455463

464+
See our [turborepo-prisma-tasks-package example](https://github.com/triggerdotdev/examples/tree/main/monorepos/turborepo-prisma-tasks-package) for a more complete example.
465+
456466
#### 3. Use tasks in your apps
457467

458468
**`apps/web/package.json`**:
469+
459470
```json
460471
{
461472
"name": "web",
@@ -469,6 +480,7 @@ export const helloWorld = task({
469480
```
470481

471482
**`apps/web/app/api/actions.ts`**:
483+
472484
```typescript
473485
"use server";
474486

@@ -510,6 +522,7 @@ This approach installs Trigger.dev directly in individual apps that need backgro
510522
#### 1. Install in your app
511523

512524
**`apps/web/package.json`**:
525+
513526
```json
514527
{
515528
"name": "web",
@@ -528,6 +541,7 @@ This approach installs Trigger.dev directly in individual apps that need backgro
528541
#### 2. Add configuration
529542

530543
**`apps/web/trigger.config.ts`**:
544+
531545
```typescript
532546
import { defineConfig } from "@trigger.dev/sdk";
533547

@@ -551,6 +565,7 @@ export default defineConfig({
551565
#### 3. Create tasks
552566

553567
**`apps/web/src/trigger/example.ts`**:
568+
554569
```typescript
555570
import { task } from "@trigger.dev/sdk";
556571

@@ -570,17 +585,25 @@ export const helloWorld = task({
570585
#### 4. Use tasks in your app
571586

572587
**`apps/web/app/api/actions.ts`**:
588+
573589
```typescript
574590
"use server";
575591

576-
import { helloWorld } from "../../src/trigger/example";
592+
import { tasks } from "@trigger.dev/sdk";
593+
import type { helloWorld } from "../../src/trigger/example";
594+
// 👆 type only import
577595

578596
export async function triggerHelloWorld(name: string) {
579-
const handle = await helloWorld.trigger({
580-
name: name,
581-
});
597+
try {
598+
const handle = await tasks.trigger<typeof helloWorld>("hello-world", {
599+
name: name,
600+
});
582601

583-
return { runId: handle.id };
602+
return handle.id;
603+
} catch (error) {
604+
console.error(error);
605+
return { error: "something went wrong" };
606+
}
584607
}
585608
```
586609

@@ -608,6 +631,7 @@ nx generate @nx/js:library tasks --directory=libs/tasks
608631
#### 2. Add Trigger.dev configuration
609632

610633
**`libs/tasks/trigger.config.ts`**:
634+
611635
```typescript
612636
import { defineConfig } from "@trigger.dev/sdk";
613637

@@ -620,6 +644,7 @@ export default defineConfig({
620644
#### 3. Update project configuration
621645

622646
**`libs/tasks/project.json`**:
647+
623648
```json
624649
{
625650
"targets": {

0 commit comments

Comments
 (0)