Skip to content

Backport #5568: [rollup] Read decorator options from tsconfig in the workflow transform - #5593

Open
github-actions[bot] wants to merge 1 commit into
stablefrom
backport/pr-5568-to-stable
Open

github-actions[bot] wants to merge 1 commit into
stablefrom
backport/pr-5568-to-stable

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Automated backport of #5568 to stable (backport job run).

AI recommendation: This fixes a build failure: Nitro and Nuxt builds crash with Expression expected on workflow files that use decorators while experimentalDecorators is on. On stable, @workflow/rollup has the same parser config with no decorator options, and the tsconfig decorator helpers in @workflow/builders already exist there. The new getCachedDecoratorOptions export only shares the existing cache, and the patch adds tests for the fix.

Merge conflicts were resolved by AI (opencode with anthropic/claude-opus-5.5). Please review the conflict resolution carefully before merging.

…rm (#5568)

`workflowTransformPlugin()` in `@workflow/rollup` runs SWC with the
workflow plugin in step mode over every file that has `"use step"` or
`"use workflow"`. `@workflow/nitro` puts it first in `rollup:before`
([nitro/src/index.ts#L104-L113](https://github.com/vercel/workflow/blob/e379eaf6a07696c904c28ee494cc128af2e2c772/packages/nitro/src/index.ts#L104-L113)),
and `@workflow/nuxt` goes through Nitro, so it sees raw TypeScript
before anything else lowers it.

**Before this PR**

A developer with `experimentalDecorators: true` in `tsconfig.json` runs
`nitro build` on an app whose `workflows/order.ts` has an
`@Injectable()` class next to a `'use step'` function.

1. Nitro's Rollup build calls the `transform` hook of
`workflowTransformPlugin()` on `workflows/order.ts`.
2. The hook builds `jsc.parser` as only `{ syntax: 'typescript', tsx }`
([rollup/src/index.ts#L148-L174](https://github.com/vercel/workflow/blob/e379eaf6a07696c904c28ee494cc128af2e2c772/packages/rollup/src/index.ts#L148-L174)),
with no `decorators`, and `jsc.transform` has no `legacyDecorator` or
`decoratorMetadata`.
3. SWC reaches `@Injectable()` with decorator parsing off.
4. The build fails with `x Expression expected` (or ``Unexpected token
`@` `` on a method decorator).

**After this PR**

Same developer, same `nitro build`.

1. Same as above through step 1.
2. The hook calls `getCachedDecoratorOptions(process.cwd())` from
`@workflow/builders`. This is the function `applySwcTransform` already
used internally, now exported so both places share one cache. It finds
the nearest `tsconfig.json` or `jsconfig.json`, follows `extends`, and
reads it once per directory.
3. `experimentalDecorators: true` gives `decorators: true` and
`legacyDecorator: true`, plus `decoratorMetadata: true` when
`emitDecoratorMetadata` is also on
([config-helpers.ts#L52-L62](https://github.com/vercel/workflow/blob/e379eaf6a07696c904c28ee494cc128af2e2c772/packages/builders/src/config-helpers.ts#L52-L62)).
4. SWC parses the decorators, lowers them to `_ts_decorate(...)`, and
the step registers as `step//./workflows/order//chargeOrder`.
5. With `experimentalDecorators` off or no tsconfig at all, all three
values are `false`, so the transform behaves exactly as it does today.

Signed-off-by: Abhiram Shaji <write4abhiram@gmail.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Co-authored-by: Peter Wielander <peter.wielander@vercel.com>
Signed-off-by: Abhiram Shaji <write4abhiram@gmail.com>
@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 50b9778

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

This PR includes changesets to release 16 packages
Name Type
@workflow/rollup Patch
@workflow/builders Patch
@workflow/astro Patch
@workflow/nitro Patch
@workflow/sveltekit Patch
@workflow/vitest Patch
workflow Patch
@workflow/cli Patch
@workflow/nest Patch
@workflow/next Patch
@workflow/vite Patch
@workflow/nuxt 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 Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
example-nextjs-workflow-turbopack Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
example-nextjs-workflow-webpack Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
example-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workbench-astro-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workbench-express-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workbench-fastify-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workbench-hono-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workbench-nestjs-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workbench-nitro-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workbench-nuxt-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workbench-python-workflow Error Error v0 Nov 18, 2026 10:10pm UTC
workbench-sveltekit-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workbench-tanstack-start-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workbench-vite-workflow Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workflow-docs Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workflow-swc-playground Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workflow-tarballs Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC
workflow-web Ready Ready Preview, v0 Nov 18, 2026 10:10pm UTC

Comment on lines +89 to +99
it('follows tsconfig extends to find experimentalDecorators', async () => {
const options = await swcOptionsFor(
projectWith({
'tsconfig.base.json': {
compilerOptions: { experimentalDecorators: true },
},
'tsconfig.json': { extends: './tsconfig.base.json' },
})
);

expect(options.jsc?.parser?.decorators).toBe(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new inheritance test fails because the stable branch’s tsconfig reader ignores extends, leaving decorators disabled for its fixture.

Fix on Vercel

This branch was successfully deployed

1 active deployment
Preview – workflow-docs — 50b97782 Deployed Nov 18, 2026 by vercel[bot]
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.

0 participants