-
-
Notifications
You must be signed in to change notification settings - Fork 975
fix(core): vendor superjson to fix ESM/CJS compatibility #2949
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
base: main
Are you sure you want to change the base?
Conversation
Bundle superjson and its dependency (copy-anything) during build to avoid ERR_REQUIRE_ESM errors on Node.js versions that don't support require(ESM) by default (< 22.12.0) and AWS Lambda which intentionally disables it. - Add scripts/bundle-superjson.mjs to bundle superjson with esbuild - Update build script to bundle vendor files before tshy compilation - Move superjson from dependencies to devDependencies - Update imports to use vendored bundles Fixes #2937 pnpm install
🦋 Changeset detectedLatest commit: 2519eb7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
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 |
WalkthroughAdds vendored SuperJSON bundles via a new esbuild script (packages/core/scripts/bundle-superjson.mjs), integrates vendor bundling into packages/core npm scripts, moves superjson to devDependencies, replaces imports to use local vendored superjson in packages/core/src/v3/imports, updates .gitignore and adds a changeset; introduces a new SDK compatibility test package with many runtime fixtures and tests (internal-packages/sdk-compat-tests), and adds GitHub Actions workflow composition and a dedicated SDK compatibility workflow (.github/workflows/pr_checks.yml and .github/workflows/sdk-compat.yml). Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@packages/core/package.json`:
- Around line 160-165: This change modifies the public package `@trigger.dev/core`
but lacks a changeset; run the changeset creation flow (e.g., pnpm run
changeset:add) to add a changeset for `@trigger.dev/core`, commit the generated
.changeset file so the release pipeline picks up the version/breaking changes,
and ensure the changeset metadata correctly references `@trigger.dev/core` and the
intended release type.
In `@packages/core/scripts/bundle-superjson.mjs`:
- Around line 11-15: Update the top-of-file banner comment in
scripts/bundle-superjson.mjs to reflect current gitignore behavior: change the
line that says "The output files are committed to git so the build doesn't need
esbuild at runtime." to indicate that the generated output is now ignored by git
(or explain the new workflow), so the comment accurately describes that outputs
are excluded by .gitignore and may need to be built during CI or consumer
installs.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.gitignorepackages/core/package.jsonpackages/core/scripts/bundle-superjson.mjspackages/core/src/v3/imports/superjson-cjs.ctspackages/core/src/v3/imports/superjson.ts
🧰 Additional context used
📓 Path-based instructions (6)
{packages,integrations}/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Add a changeset when modifying any public package in
packages/*orintegrations/*usingpnpm run changeset:add
Files:
packages/core/scripts/bundle-superjson.mjspackages/core/src/v3/imports/superjson-cjs.ctspackages/core/package.jsonpackages/core/src/v3/imports/superjson.ts
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}
📄 CodeRabbit inference engine (AGENTS.md)
Format code using Prettier before committing
Files:
packages/core/package.jsonpackages/core/src/v3/imports/superjson.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects instead
**/*.{ts,tsx}: Always import tasks from@trigger.dev/sdk, never use@trigger.dev/sdk/v3or deprecatedclient.defineJobpattern
Every Trigger.dev task must be exported and have a uniqueidproperty with no timeouts in the run function
Files:
packages/core/src/v3/imports/superjson.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use zod for validation in packages/core and apps/webapp
Files:
packages/core/src/v3/imports/superjson.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
Import from
@trigger.dev/coreusing subpaths only, never import from root
Files:
packages/core/src/v3/imports/superjson.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)
**/*.ts: When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs
Do not use high-cardinality attributes in OTEL metrics such as UUIDs/IDs (envId, userId, runId, projectId, organizationId), unbounded integers (itemCount, batchSize, retryCount), timestamps (createdAt, startTime), or free-form strings (errorMessage, taskName, queueName)
When exporting OTEL metrics via OTLP to Prometheus, be aware that the exporter automatically adds unit suffixes to metric names (e.g., 'my_duration_ms' becomes 'my_duration_ms_milliseconds', 'my_counter' becomes 'my_counter_total'). Account for these transformations when writing Grafana dashboards or Prometheus queries
Files:
packages/core/src/v3/imports/superjson.ts
🧠 Learnings (15)
📚 Learning: 2025-11-26T14:40:07.146Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 2710
File: packages/schema-to-json/package.json:0-0
Timestamp: 2025-11-26T14:40:07.146Z
Learning: Node.js 24+ has native TypeScript support and can execute .ts files directly without tsx or ts-node for scripts that use only erasable TypeScript syntax (type annotations, interfaces, etc.). The trigger.dev repository uses Node.js 24.11.1+ and scripts like updateVersion.ts can be run with `node` instead of `tsx`.
Applied to files:
packages/core/scripts/bundle-superjson.mjspackages/core/package.json
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : When importing from `trigger.dev/core` in the webapp, use subpath exports from the package.json instead of importing from the root path
Applied to files:
packages/core/src/v3/imports/superjson-cjs.cts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx} : In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code
Applied to files:
packages/core/src/v3/imports/superjson-cjs.ctspackages/core/src/v3/imports/superjson.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: The SDK at packages/trigger-sdk is an isomorphic TypeScript SDK
Applied to files:
packages/core/src/v3/imports/superjson-cjs.ctspackages/core/src/v3/imports/superjson.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to {packages,integrations}/**/* : Add a changeset when modifying any public package in `packages/*` or `integrations/*` using `pnpm run changeset:add`
Applied to files:
packages/core/package.json.gitignore
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to **/*.{test,spec}.{ts,tsx} : Use vitest for all tests in the Trigger.dev repository
Applied to files:
packages/core/package.json
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Run commands from root with `pnpm run` in this pnpm 10.23.0 monorepo using Turborepo
Applied to files:
packages/core/package.json
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Configure build process in trigger.config.ts using `build` object with external packages, extensions, and JSX settings
Applied to files:
packages/core/package.json
📚 Learning: 2025-11-27T16:26:44.496Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/executing-commands.mdc:0-0
Timestamp: 2025-11-27T16:26:44.496Z
Learning: For running tests, navigate into the package directory and run `pnpm run test --run` to enable single-file test execution (e.g., `pnpm run test ./src/engine/tests/ttl.test.ts --run`)
Applied to files:
packages/core/package.json
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest for running unit tests
Applied to files:
packages/core/package.json
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `trigger.dev/sdk/v3` for all imports in Trigger.dev tasks
Applied to files:
packages/core/package.json
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Use build extensions in trigger.config.ts (additionalFiles, additionalPackages, aptGet, prismaExtension, etc.) to customize the build
Applied to files:
packages/core/package.json
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
Learning: Use pnpm as the package manager (version 10.23.0 or later) and Node.js 20.20.0
Applied to files:
packages/core/package.json
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to rules/**/* : When adding new SDK features, create a new version directory in `rules/` with only the files that changed from the previous version, and update `manifest.json`
Applied to files:
.gitignore
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use function declarations instead of default exports
Applied to files:
packages/core/src/v3/imports/superjson.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: units / packages / 📊 Merge Reports
🔇 Additional comments (5)
.gitignore (1)
18-19: LGTM—ignore vendored bundles.
Keeps generated vendor artifacts out of version control.packages/core/scripts/bundle-superjson.mjs (1)
40-68: Bundling flow looks solid.
Clear CJS/ESM outputs with explicit Node targets.packages/core/src/v3/imports/superjson-cjs.cts (1)
1-17: LGTM—vendored CJS import and default usage.
Matches the new bundling approach cleanly.packages/core/src/v3/imports/superjson.ts (1)
1-10: Nice cleanup—typed serializer + vendored import.
Clearer types and aligns with the ESM/CJS mitigation.packages/core/package.json (1)
216-216: No runtime imports of superjson from npm package remain—all production code uses the vendored bundle.The codebase properly isolates superjson usage: runtime code imports from
packages/core/src/v3/imports/superjson.ts, which in turn imports from the vendored../vendor/superjson.mjsbundle. Test files use superjson directly, but test dependencies don't ship to consumers. The vendor bundles are generated at build time byscripts/bundle-superjson.mjsbefore TypeScript compilation, so moving superjson to devDependency is safe.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
10e93f0 to
2d29f7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/core/src/v3/imports/superjson-cjs.cts (1)
1-17: Add a changeset for this packages/core modification.This PR modifies
packages/core, a public package. Per the coding guidelines, add a changeset usingpnpm run changeset:addto document this change for the changelog. The existing changeset is for@trigger.dev/sdkonly.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
.gitignorepackages/core/package.jsonpackages/core/scripts/bundle-superjson.mjspackages/core/src/v3/imports/superjson-cjs.ctspackages/core/src/v3/imports/superjson.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- .gitignore
- packages/core/scripts/bundle-superjson.mjs
- packages/core/src/v3/imports/superjson.ts
- packages/core/package.json
🧰 Additional context used
📓 Path-based instructions (1)
{packages,integrations}/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Add a changeset when modifying any public package in
packages/*orintegrations/*usingpnpm run changeset:add
Files:
packages/core/src/v3/imports/superjson-cjs.cts
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx} : In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : When importing from `trigger.dev/core` in the webapp, use subpath exports from the package.json instead of importing from the root path
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : When importing from `trigger.dev/core` in the webapp, use subpath exports from the package.json instead of importing from the root path
Applied to files:
packages/core/src/v3/imports/superjson-cjs.cts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use function declarations instead of default exports
Applied to files:
packages/core/src/v3/imports/superjson-cjs.cts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx} : In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code
Applied to files:
packages/core/src/v3/imports/superjson-cjs.cts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: The SDK at packages/trigger-sdk is an isomorphic TypeScript SDK
Applied to files:
packages/core/src/v3/imports/superjson-cjs.cts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: typecheck / typecheck
- GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
🔇 Additional comments (3)
packages/core/src/v3/imports/superjson-cjs.cts (3)
1-4: LGTM – vendored import with clear rationale.The comment referencing the issue provides good context for future maintainers, and the require path aligns with the bundling script output.
6-14: LGTM – Buffer serializer correctly accesses.default.The
.defaultaccess is correct since esbuild's CJS output wraps the ESM default export. The Buffer type guards and serialization logic are appropriate.
16-17: LGTM – export maintains API compatibility.Exporting
superjson.defaultpreserves the expected superjson API surface for consumers.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@internal-packages/sdk-compat-tests/src/fixtures/deno/test.ts`:
- Around line 38-48: Export the defined task so Trigger.dev can discover it:
change the declaration of myTask (the result of task({...}) with id
"deno-test-task") to be exported (e.g., export const myTask = ...) and keep the
unique id value unchanged; ensure any local checks (the myTask.id comparison)
still work after making myTask exported.
🧹 Nitpick comments (11)
internal-packages/sdk-compat-tests/src/fixtures/typescript/test.ts (1)
27-35: Consider usingtypeinstead ofinterface.Per coding guidelines, prefer types over interfaces in TypeScript. This is a minor consistency issue given this is a test fixture.
Suggested change
-interface MyPayload { - message: string; - count: number; -} +type MyPayload = { + message: string; + count: number; +}; -interface MyOutput { - processed: boolean; - result: string; -} +type MyOutput = { + processed: boolean; + result: string; +};internal-packages/sdk-compat-tests/src/fixtures/bun/test.ts (3)
8-8: Missingmetadataandtagsimports for consistency with other fixtures.The ESM and CJS fixtures also validate
metadataandtagsexports, but this Bun fixture does not import or test them.♻️ Suggested fix
-import { task, logger, schedules, runs, configure, queue, retry, wait } from "@trigger.dev/sdk"; +import { task, logger, schedules, runs, configure, queue, retry, wait, metadata, tags } from "@trigger.dev/sdk";
10-20: Addmetadataandtagschecks for parity with other fixtures.Per the
esm-import/test.mjsandcjs-require/test.cjsfixtures, these exports should also be validated:♻️ Suggested fix
const checks: [string, boolean][] = [ ["task", typeof task === "function"], ["logger", typeof logger === "object" && typeof logger.info === "function"], ["schedules", typeof schedules === "object"], ["runs", typeof runs === "object"], ["configure", typeof configure === "function"], ["queue", typeof queue === "function"], ["retry", typeof retry === "object"], ["wait", typeof wait === "object"], + ["metadata", typeof metadata === "object"], + ["tags", typeof tags === "object"], ];
31-33: Prefertypeoverinterfaceper coding guidelines.As per the coding guidelines for TypeScript files.
♻️ Suggested fix
-interface Payload { - message: string; -} +type Payload = { + message: string; +};internal-packages/sdk-compat-tests/src/fixtures/esm-import/superjson-test.mjs (1)
27-46: Clarify test scope in comment.The task's
runfunction validates payload types but is never invoked in this test. The current comment at line 31 ("verify the payload structure matches expectations") might be misleading since it implies runtime validation. Consider clarifying that this test validates task definition and logger serialization, not runtime payload handling.📝 Suggested clarification
// Create a task that uses complex types +// Note: This task is created to verify superjson-based task definition works, +// but the run function is not invoked - runtime payload handling is tested elsewhere. const complexTask = task({ id: "superjson-test-task", run: async (payload) => { - // Just verify the payload structure matches expectations + // This would verify payload types if invoked at runtime return {internal-packages/sdk-compat-tests/src/tests/import.test.ts (1)
16-17: Remove unused variable.The
sdkDirconstant is defined but never used in this file.🧹 Proposed fix
-// Find the SDK package in the monorepo -const sdkDir = resolve(__dirname, "../../../../packages/trigger-sdk"); - // Common execa optionsinternal-packages/sdk-compat-tests/src/tests/bundler.test.ts (2)
49-86: Consider removing or utilizing the metafile option.The
metafile: trueoption is enabled but the metafile output isn't used in any assertions. If this was intended for debugging, consider removing it to keep the test focused. Alternatively, you could add assertions usingresult.metafileto verify bundle composition (e.g., check that SDK modules are included).♻️ Option 1: Remove unused option
write: false, // Don't externalize SDK - bundle it inline logLevel: "silent", - metafile: true, });♻️ Option 2: Add assertion using metafile
expect(result.outputFiles).toHaveLength(1); // Verify the bundle contains the SDK code const bundleContent = result.outputFiles[0].text; expect(bundleContent).toBeTruthy(); expect(bundleContent.length).toBeGreaterThan(1000); // Should be substantial + + // Verify SDK modules are included in the bundle + expect(result.metafile?.inputs).toBeDefined(); + const inputPaths = Object.keys(result.metafile!.inputs); + expect(inputPaths.some((p) => p.includes("@trigger.dev/sdk"))).toBe(true); });
88-116: Tree-shaking test could be strengthened.The test verifies that bundling with
treeShaking: truesucceeds, but doesn't validate that tree-shaking actually works (e.g., unused exports are excluded). Consider comparing the bundle size to the inline test or checking that unused SDK exports aren't in the output.♻️ Proposed enhancement to verify tree-shaking effectiveness
const result = await esbuild.build({ stdin: { contents: entryContent, loader: "ts", resolveDir: resolve(__dirname, "../../"), }, bundle: true, format: "esm", platform: "node", target: "node18", write: false, treeShaking: true, logLevel: "silent", + minify: false, // Keep readable for inspection }); expect(result.errors).toHaveLength(0); expect(result.outputFiles).toHaveLength(1); + + // Verify unused exports are not included + const bundleContent = result.outputFiles[0].text; + // "logger" is not imported, so its implementation shouldn't appear + // This is a heuristic check - tree-shaking may vary + expect(bundleContent).not.toContain("createContextLogger"); });internal-packages/sdk-compat-tests/src/fixtures/deno/test.ts (1)
34-36: Prefer type alias over interface.Switch to a
typeto align with repo TypeScript style.♻️ Suggested change
-interface Payload { - message: string; -} +type Payload = { + message: string; +};As per coding guidelines, use types over interfaces for TypeScript.
.github/workflows/sdk-compat.yml (2)
78-82: Pin Bun version to avoid CI drift.Using
bun-version: latestcan introduce unexpected breakages between runs; consider pinning to a specific version (or a version file) for reproducibility.
176-179: Consider locking Cloudflare fixture installs.If the fixture has (or can add) a lockfile, using
--frozen-lockfilewill keep CI deterministic.♻️ Suggested change (if a lockfile exists for the fixture)
- run: pnpm install + run: pnpm install --frozen-lockfile
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
.github/workflows/pr_checks.yml.github/workflows/sdk-compat.ymlinternal-packages/sdk-compat-tests/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/bun/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cjs-require/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/wrangler.tomlinternal-packages/sdk-compat-tests/src/fixtures/deno/deno.jsoninternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/esm-import/superjson-test.mjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjsinternal-packages/sdk-compat-tests/src/fixtures/typescript/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.jsoninternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/tsconfig.jsoninternal-packages/sdk-compat-tests/vitest.config.ts
✅ Files skipped from review due to trivial changes (4)
- internal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/wrangler.toml
- internal-packages/sdk-compat-tests/src/fixtures/deno/deno.json
- internal-packages/sdk-compat-tests/tsconfig.json
- internal-packages/sdk-compat-tests/package.json
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects instead
**/*.{ts,tsx}: Always import tasks from@trigger.dev/sdk, never use@trigger.dev/sdk/v3or deprecatedclient.defineJobpattern
Every Trigger.dev task must be exported and have a uniqueidproperty with no timeouts in the run function
Files:
internal-packages/sdk-compat-tests/vitest.config.tsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
Import from
@trigger.dev/coreusing subpaths only, never import from root
Files:
internal-packages/sdk-compat-tests/vitest.config.tsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)
**/*.ts: When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs
Do not use high-cardinality attributes in OTEL metrics such as UUIDs/IDs (envId, userId, runId, projectId, organizationId), unbounded integers (itemCount, batchSize, retryCount), timestamps (createdAt, startTime), or free-form strings (errorMessage, taskName, queueName)
When exporting OTEL metrics via OTLP to Prometheus, be aware that the exporter automatically adds unit suffixes to metric names (e.g., 'my_duration_ms' becomes 'my_duration_ms_milliseconds', 'my_counter' becomes 'my_counter_total'). Account for these transformations when writing Grafana dashboards or Prometheus queries
Files:
internal-packages/sdk-compat-tests/vitest.config.tsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}
📄 CodeRabbit inference engine (AGENTS.md)
Format code using Prettier before committing
Files:
internal-packages/sdk-compat-tests/vitest.config.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.jsoninternal-packages/sdk-compat-tests/src/fixtures/cjs-require/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.tsinternal-packages/sdk-compat-tests/src/fixtures/bun/package.json
**/*.{test,spec}.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use vitest for all tests in the Trigger.dev repository
Files:
internal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.test.{ts,tsx,js,jsx}: Test files should live beside the files under test and use descriptivedescribeanditblocks
Tests should avoid mocks or stubs and use the helpers from@internal/testcontainerswhen Redis or Postgres are needed
Use vitest for running unit tests
**/*.test.{ts,tsx,js,jsx}: Use vitest exclusively for testing and never mock anything - use testcontainers instead
Place test files next to source files with naming pattern: source file (e.g.,MyService.ts) →MyService.test.ts
Files:
internal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use testcontainers helpers (
redisTest,postgresTest,containerTest) from@internal/testcontainersfor Redis/PostgreSQL testing instead of mocks
Files:
internal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.ts
**/tsconfig.json
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use strict mode in TypeScript configuration
Files:
internal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
🧠 Learnings (35)
📓 Common learnings
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx} : In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to rules/**/* : When adding new SDK features, create a new version directory in `rules/` with only the files that changed from the previous version, and update `manifest.json`
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to {packages,integrations}/**/* : Add a changeset when modifying any public package in `packages/*` or `integrations/*` using `pnpm run changeset:add`
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `trigger.dev/sdk/v3` for all imports in Trigger.dev tasks
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Export tasks with unique IDs within the project to enable proper task discovery and execution
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/superjson-test.mjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to **/*.{test,spec}.{ts,tsx} : Use vitest for all tests in the Trigger.dev repository
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/vitest.config.tsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.ts.github/workflows/sdk-compat.ymlinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.jsoninternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.{ts,tsx} : Always import tasks from `trigger.dev/sdk`, never use `trigger.dev/sdk/v3` or deprecated `client.defineJob` pattern
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.jsoninternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx} : In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to rules/**/* : When adding new SDK features, create a new version directory in `rules/` with only the files that changed from the previous version, and update `manifest.json`
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/fixtures/typescript/package.jsoninternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/cjs-require/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/bun/package.json
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.{ts,tsx} : Every Trigger.dev task must be exported and have a unique `id` property with no timeouts in the run function
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/superjson-test.mjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use the `task()` function from `trigger.dev/sdk/v3` to define tasks with id and run properties
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Keep the `.claude/skills/trigger-dev-tasks/` skill in sync with the latest rules version when SDK features change
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjs
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `schemaTask()` from `trigger.dev/sdk/v3` with Zod schema for payload validation
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/superjson-test.mjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Export every task, including subtasks
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: The SDK at packages/trigger-sdk is an isomorphic TypeScript SDK
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.ts
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest for running unit tests
Applied to files:
internal-packages/sdk-compat-tests/vitest.config.tsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest exclusively for testing and never mock anything - use testcontainers instead
Applied to files:
internal-packages/sdk-compat-tests/vitest.config.tsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to apps/webapp/**/*.test.{ts,tsx} : For testable code in the webapp, never import env.server.ts in test files - pass configuration as options instead
Applied to files:
internal-packages/sdk-compat-tests/vitest.config.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Configure Trigger.dev project in `trigger.config.ts` using `defineConfig()` with project ref and task directories
Applied to files:
internal-packages/sdk-compat-tests/vitest.config.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to {packages,integrations}/**/* : Add a changeset when modifying any public package in `packages/*` or `integrations/*` using `pnpm run changeset:add`
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/typescript/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/esm-import/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/cjs-require/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/package.jsoninternal-packages/sdk-compat-tests/src/fixtures/bun/package.json
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use logger methods (debug, log, info, warn, error) from `trigger.dev/sdk/v3` for structured logging in tasks
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/esm-import/superjson-test.mjs
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Generate example payloads for tasks when possible
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/esm-import/superjson-test.mjsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `tasks.trigger()` with type-only imports to trigger tasks from backend code without importing the task implementation
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjsinternal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.tsinternal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Import from `trigger.dev/core` using subpaths only, never import from root
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjs
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Specify runtime environment (node or bun) in trigger.config.ts using the `runtime` property
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/bun/test.ts
📚 Learning: 2025-11-27T16:26:44.496Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/executing-commands.mdc:0-0
Timestamp: 2025-11-27T16:26:44.496Z
Learning: For running tests, navigate into the package directory and run `pnpm run test --run` to enable single-file test execution (e.g., `pnpm run test ./src/engine/tests/ttl.test.ts --run`)
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/bun/test.tsinternal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.ts
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Test files should live beside the files under test and use descriptive `describe` and `it` blocks
Applied to files:
internal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2025-11-27T16:27:40.153Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tests.mdc:0-0
Timestamp: 2025-11-27T16:27:40.153Z
Learning: Follow the tests.md guide for how to write tests in the monorepo
Applied to files:
internal-packages/sdk-compat-tests/src/tests/bundler.test.tsinternal-packages/sdk-compat-tests/src/tests/import.test.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.test.{ts,tsx} : Test files should only import classes and functions from `app/**/*.ts` files and should not import `env.server.ts` directly or indirectly; pass configuration through options instead
Applied to files:
internal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/deno/test.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Place test files next to source files with naming pattern: source file (e.g., `MyService.ts`) → `MyService.test.ts`
Applied to files:
internal-packages/sdk-compat-tests/src/tests/import.test.tsinternal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to **/tsconfig.json : Use strict mode in TypeScript configuration
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to {packages/core,apps/webapp}/**/*.{ts,tsx} : Use zod for validation in packages/core and apps/webapp
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Configure build process in trigger.config.ts using `build` object with external packages, extensions, and JSX settings
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use function declarations instead of default exports
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2025-11-26T14:40:07.146Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 2710
File: packages/schema-to-json/package.json:0-0
Timestamp: 2025-11-26T14:40:07.146Z
Learning: Node.js 24+ has native TypeScript support and can execute .ts files directly without tsx or ts-node for scripts that use only erasable TypeScript syntax (type annotations, interfaces, etc.). The trigger.dev repository uses Node.js 24.11.1+ and scripts like updateVersion.ts can be run with `node` instead of `tsx`.
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Use build extensions in trigger.config.ts (additionalFiles, additionalPackages, aptGet, prismaExtension, etc.) to customize the build
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to **/*.{ts,tsx} : Use types over interfaces for TypeScript
Applied to files:
internal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json
🧬 Code graph analysis (7)
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjs (1)
internal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjs (3)
checks(15-27)failed(29-29)myTask(38-43)
internal-packages/sdk-compat-tests/src/fixtures/bun/test.ts (3)
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjs (3)
checks(18-30)failed(32-32)myTask(41-46)internal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjs (3)
checks(15-27)failed(29-29)myTask(38-43)packages/trigger-sdk/src/v3/index.ts (1)
retry(3-3)
internal-packages/sdk-compat-tests/src/tests/bundler.test.ts (1)
packages/core/scripts/bundle-superjson.mjs (1)
__dirname(24-24)
internal-packages/sdk-compat-tests/src/tests/import.test.ts (1)
packages/core/scripts/bundle-superjson.mjs (1)
__dirname(24-24)
internal-packages/sdk-compat-tests/src/fixtures/typescript/test.ts (1)
packages/core/src/v3/taskContext/index.ts (1)
ctx(26-28)
internal-packages/sdk-compat-tests/src/fixtures/deno/test.ts (2)
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjs (3)
checks(18-30)failed(32-32)myTask(41-46)internal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjs (3)
checks(15-27)failed(29-29)myTask(38-43)
internal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts (2)
internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjs (1)
myTask(41-46)internal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjs (1)
myTask(38-43)
🔇 Additional comments (31)
internal-packages/sdk-compat-tests/src/fixtures/typescript/tsconfig.json (1)
1-12: LGTM!The TypeScript configuration correctly enables strict mode as per coding guidelines, and the NodeNext module settings are appropriate for validating ESM/CJS compatibility in this test fixture.
internal-packages/sdk-compat-tests/src/fixtures/typescript/package.json (1)
1-5: LGTM!Minimal and appropriate package.json for an internal test fixture with correct ESM configuration.
internal-packages/sdk-compat-tests/src/fixtures/typescript/test.ts (4)
8-24: Imports validate SDK export availability.The unused imports (
logger,schedules,runs,configure,wait,metadata,tags,ApiClientConfiguration) appropriately verify that these exports are available and correctly typed from the SDK. This is a valid pattern for type-checking fixtures.
37-48: LGTM!Well-structured typed task definition that validates payload typing, context access, and return type inference. The
ctx.run.idaccess aligns with the SDK'sTaskRunContextstructure.
50-66: LGTM!Good use of compile-time type assertions (
_PayloadCheck) and runtime type validation for queue and retry options. These effectively test SDK type exports.
68-74: LGTM!Runtime assertion provides a sanity check that the task ID is correctly assigned, with appropriate error handling via
process.exit(1)for CI failures.internal-packages/sdk-compat-tests/src/fixtures/bun/package.json (1)
1-5: LGTM!Minimal package.json is appropriate for this internal test fixture.
internal-packages/sdk-compat-tests/src/fixtures/bun/test.ts (2)
35-45: LGTM!Task definition with ID validation is consistent with other fixtures.
47-62: LGTM!Queue definition and exit logic are appropriate for the Bun runtime test.
internal-packages/sdk-compat-tests/src/fixtures/esm-import/package.json (1)
1-5: LGTM!Minimal and correct package.json for an ESM test fixture. The
"type": "module"correctly enables ESM semantics for.jsand.mjsfiles in this directory.internal-packages/sdk-compat-tests/src/fixtures/cjs-require/test.cjs (1)
1-57: LGTM!Well-structured CJS compatibility test that validates critical SDK exports and task creation. The test appropriately covers both the main export path and the legacy
/v3subpath to ensure backward compatibility—this is the correct approach for a compatibility test suite.internal-packages/sdk-compat-tests/src/fixtures/cjs-require/package.json (1)
1-4: LGTM!Correctly minimal package.json for a CJS fixture. The absence of
"type": "module"ensures CommonJS semantics, which is the intended behavior for this test.internal-packages/sdk-compat-tests/src/fixtures/esm-import/test.mjs (1)
1-54: LGTM!Clean ESM import validation test with proper export type checks and task creation verification. The parallel structure with the CJS test ensures consistent coverage across module systems.
internal-packages/sdk-compat-tests/src/fixtures/esm-import/superjson-test.mjs (1)
48-57: LGTM!Good validation that the logger can handle complex superjson-serializable types without throwing. This directly tests the fix for
#2937.internal-packages/sdk-compat-tests/src/tests/import.test.ts (3)
29-49: LGTM!Well-structured ESM import tests using vitest. The test appropriately validates both basic SDK imports and superjson serialization functionality.
51-73: LGTM!Good coverage for CJS compatibility. The
--experimental-require-moduletest ensures the fix works on Node versions < 22.12.0 where the flag is needed.
75-84: LGTM!TypeScript compilation test ensures type definitions are correctly exported and resolvable.
internal-packages/sdk-compat-tests/vitest.config.ts (1)
1-11: LGTM!The Vitest configuration is well-structured with appropriate timeouts for integration tests involving framework builds. The test isolation and extended timeouts align well with the nature of SDK compatibility testing.
internal-packages/sdk-compat-tests/src/tests/bundler.test.ts (2)
1-14: LGTM!Clean setup with proper ESM-compatible
__dirnamepattern, consistent with the approach used elsewhere in the codebase (e.g.,bundle-superjson.mjs).
16-47: LGTM!Both ESM and CJS bundling tests are well-structured with appropriate esbuild configuration. Externalizing the SDK correctly isolates the bundler behavior being tested.
internal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/package.json (1)
1-11: Looks good for the fixture manifest.No concerns with the package metadata or the fixture build script as written.
internal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker/src/index.ts (2)
19-40: Fetch handler logic looks solid.The runtime checks and JSON response are clear and appropriate for a compat fixture.
11-17: The original review comment is based on learnings that apply to production trigger task files (**/trigger/**/*.{ts,tsx,js,jsx}), not test fixtures. This file is a bundling validation fixture insdk-compat-tests, where the task exists only to validate that the SDK imports and basic properties work—not to be discovered by the actual Trigger.dev system. The task already has a unique ID and works correctly in its intended context.internal-packages/sdk-compat-tests/src/fixtures/deno/test.ts (4)
8-23: Export presence checks are thorough.Good coverage of core SDK exports for Deno compatibility validation.
25-31: Failure aggregation + logging is clean.Simple, readable failure accumulation and reporting.
50-59: Queue creation checks look good.Clear validation of queue construction and failure handling.
61-65: Exit path + success message are solid.Clean termination behavior for CI fixtures.
.github/workflows/sdk-compat.yml (3)
1-8: Reusable workflow setup looks good.Scope and permissions are minimal and appropriate for a workflow_call entry point.
10-57: Node.js matrix job looks solid.Build and test ordering is clear and consistent for SDK compatibility coverage.
99-143: Deno runtime job LGTM.The Deno setup and fixture execution flow is clear and self-contained.
.github/workflows/pr_checks.yml (1)
33-35: Workflow composition looks good.Reusing the SDK compatibility workflow keeps PR checks aligned with the new runtime coverage.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| const myTask = task({ | ||
| id: "deno-test-task", | ||
| run: async (payload: Payload) => { | ||
| return { received: payload.message }; | ||
| }, | ||
| }); | ||
|
|
||
| if (myTask.id !== "deno-test-task") { | ||
| console.error(`FAIL: task.id mismatch`); | ||
| failed = true; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Export the task for discovery consistency.
Even in fixtures, tasks should be exported to satisfy Trigger.dev task discovery conventions.
✅ Suggested fix
-const myTask = task({
+export const myTask = task({
id: "deno-test-task",
run: async (payload: Payload) => {
return { received: payload.message };
},
});Based on learnings, every Trigger.dev task must be exported and have a unique id.
🤖 Prompt for AI Agents
In `@internal-packages/sdk-compat-tests/src/fixtures/deno/test.ts` around lines 38
- 48, Export the defined task so Trigger.dev can discover it: change the
declaration of myTask (the result of task({...}) with id "deno-test-task") to be
exported (e.g., export const myTask = ...) and keep the unique id value
unchanged; ensure any local checks (the myTask.id comparison) still work after
making myTask exported.
Bundle superjson and its dependency (copy-anything) during build to avoid
ERR_REQUIRE_ESM errors on Node.js versions that don't support require(ESM)
by default (< 22.12.0) and AWS Lambda which intentionally disables it.
Fixes #2937