Rspack/Rsbuild: `@workflow/swc-plugin` can't run in `builtin:swc-loader`. Open to an `@workflow/rsbuild`?

Open
#4,447 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust, typescript

Research direction

Start by running the documented npm install and npx rspack build reproduction, then read the @workflow/next/loader entry point. Review packages/builders/src/vercel-build-output-api.ts and the related Nitro and Astro builder files to understand the proposed integration boundaries. Done means an agreed Rsbuild integration or thin third-party path that supports the reported build and preserves existing .vercel/output/config.json content.

Written by the indexing model from the issue text.

Description

@workflow/swc-plugin fails in Rspack's builtin:swc-loader, so Rsbuild/Rspack apps have no supported way to use Workflow.

Repro
npm i -D @rspack/[email protected] @rspack/[email protected] @workflow/[email protected]
// src/index.ts
export async function add(a: number, b: number) {
  'use step';
  return a + b;
}
// rspack.config.mjs
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);

export default {
  target: 'node',
  entry: './src/index.ts',
  module: {
    rules: [{
      test: /\.ts$/,
      loader: 'builtin:swc-loader',
      options: { jsc: {
        parser: { syntax: 'typescript' },
        experimental: { plugins: [[require.resolve('@workflow/swc-plugin'), { mode: 'step' }]] },
      } },
    }],
  },
};

Run npx rspack build.

Expected: the step transform runs.
Actual: failed to invoke plugin ... Failed to deserialize program received from host. The plugin pins swc_core 49 (Cargo.toml); Rspack 2.2 embeds swc_core 79.

Versions

@rspack/core 2.2.7; @workflow/swc-plugin 4.1.3 and 5.0.0-beta.7 (still swc_core 49 on main).

Workaround

@workflow/next/loader works as a plain Rspack JS loader.

Ask

Would you take an @workflow/rsbuild package? We have one working on workflow 4.8 (JS loader, BaseBuilder subclass, dev middleware) and can contribute it. If you'd rather keep it out of tree, two changes would keep a third-party plugin thin:

  1. Export the loader from a bundler-neutral path, e.g. @workflow/builders/loader.
  2. Have VercelBuildOutputAPIBuilder merge into an existing .vercel/output/config.json instead of overwriting it (vercel-build-output-api.ts#L111-L126). Nitro and Astro each re-merge it today (nitro, astro).
Dominant language
TypeScript
Stars
2.5k
Forks
401
Avg merge
1d 21h
Merged PRs (30d)
201

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel/workflow

All issues in vercel/workflow

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.