Skip to content

feat(builders): add an after-transform observer - #3163

Open
lucamaraschi wants to merge 1 commit into
vercel:mainfrom
lucamaraschi:optional-transform-hook
Open

feat(builders): add an after-transform observer#3163
lucamaraschi wants to merge 1 commit into
vercel:mainfrom
lucamaraschi:optional-transform-hook

Conversation

@lucamaraschi

Copy link
Copy Markdown

Description

Add an optional onAfterTransform observer to @workflow/builders.

The observer exposes the accepted result of each workflow SWC transform, including:

  • Transform mode
  • Source and absolute filenames
  • Original source
  • Generated code
  • Per-file workflow manifest

The callback runs only after the transformed manifest has been validated and accepted into the bundle manifest. It is awaited, and throwing from it aborts the build.

The observer cannot replace generated code. A source file may be observed multiple times across transform modes, bundles, and watch rebuilds.

BaseBuilder propagates the observer through step, workflow, and client bundle creation. The API is optional and has no effect on existing builder integrations.

How did you test your changes?

Added focused tests covering:

  • The observer payload
  • Invocation after manifest acceptance
  • Awaiting asynchronous observers
  • Aborting the build when an observer throws
  • Not observing transforms rejected because of duplicate manifest IDs

Validation performed:

  • pnpm --filter @workflow/builders build
  • pnpm --filter @workflow/builders typecheck
  • pnpm --filter @workflow/builders test
    • 18 test files passed
    • 233 tests passed
  • Biome check on all changed files
  • git diff --check main...HEAD

PR Checklist - Required to merge

  • 📦 pnpm changeset was run to create a changelog for this PR
    • Minor release for the additive @workflow/builders API
  • 🔒 DCO sign-off passes
  • 📝 Ping @vercel/workflow in a comment once the PR is ready

Signed-off-by: Luca Maraschi <luca.maraschi@gmail.com>
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c0005fa

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

This PR includes changesets to release 16 packages
Name Type
@workflow/builders Minor
@workflow/astro Patch
@workflow/cli Patch
@workflow/nest Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/nuxt Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
@workflow/vitest Patch
workflow Patch
@workflow/world-testing Patch
@workflow/core Patch
@workflow/web-shared Patch
@workflow/web Patch

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

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@lucamaraschi is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@lucamaraschi
lucamaraschi marked this pull request as ready for review July 29, 2026 21:07
@lucamaraschi
lucamaraschi requested review from a team and ijjk as code owners July 29, 2026 21:07
@lucamaraschi

Copy link
Copy Markdown
Author

@vercel/workflow ready for review

@VaguelySerious

Copy link
Copy Markdown
Member

@lucamaraschi We require commits to be signed. Could you squash+sign the PR and force-push?

Also, I'm curious what you're using this for! Can you share an example?

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