Skip to content

Conversation

@adriandlam
Copy link
Member

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Oct 31, 2025

⚠️ No Changeset found

Latest commit: 850dd36

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Contributor

vercel bot commented Oct 31, 2025

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

Project Deployment Preview Comments Updated (UTC)
example-nextjs-workflow-turbopack Error Error Oct 31, 2025 6:29am
example-nextjs-workflow-webpack Error Error Oct 31, 2025 6:29am
example-workflow Error Error Oct 31, 2025 6:29am
workbench-nitro-workflow Error Error Oct 31, 2025 6:29am
workbench-sveltekit-workflow Error Error Oct 31, 2025 6:29am
workflow-docs Ready Ready Preview Comment Oct 31, 2025 6:29am

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​types/​bun@​1.3.11001004993100

View full report

Comment on lines +3 to +7
import { transform } from '@swc/core';
import { BaseBuilder } from '@workflow/cli/dist/lib/builders/base-builder';
import type { WorkflowConfig } from '@workflow/cli/dist/lib/config/types';
import type { BunPlugin } from 'bun';

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { transform } from '@swc/core';
import { BaseBuilder } from '@workflow/cli/dist/lib/builders/base-builder';
import type { WorkflowConfig } from '@workflow/cli/dist/lib/config/types';
import type { BunPlugin } from 'bun';
import { createRequire } from 'module';
import { transform } from '@swc/core';
import { BaseBuilder } from '@workflow/cli/dist/lib/builders/base-builder';
import type { WorkflowConfig } from '@workflow/cli/dist/lib/config/types';
import type { BunPlugin } from 'bun';
const require = createRequire(import.meta.filename);

The code uses require.resolve() without importing or initializing require, which will cause a runtime error in ES modules.

View Details

Analysis

Missing require initialization in Bun plugin causes runtime error in ES module

What fails: packages/bun/src/index.ts calls require.resolve('@workflow/swc-plugin') on line 26 without initializing require, which causes ReferenceError: require is not defined at runtime when the Bun plugin attempts to transform files with workflow directives.

How to reproduce:

  1. Import the @workflow/bun package (which has "type": "module" in package.json)
  2. Call the workflowPlugin() function to register the Bun plugin
  3. Process any TypeScript/JavaScript file containing "use workflow" or "use step" directives
  4. The plugin's build.onLoad() handler will execute and throw: ReferenceError: require is not defined

Expected behavior: The plugin should successfully resolve the SWC plugin path and transform the file. Per Node.js ES Module documentation, require must be explicitly created in ES modules using createRequire from the 'module' package.

Root cause: The file uses ES module syntax (import statements) and declares "type": "module" in package.json, but attempts to use the global require function which is only available in CommonJS modules. This contrasts with @workflow/next which uses "type": "commonjs" and can use require directly.

Solution: Import createRequire from 'module' and initialize the require function at the module level, following the pattern established in packages/cli/src/lib/builders/apply-swc-transform.ts.

@adriandlam adriandlam closed this Oct 31, 2025
@versecafe
Copy link

@adriandlam What's required to get bun support for workflows over the line?

@adriandlam
Copy link
Member Author

hey @versecafe! I'm just working on other integrations right now and will take a look at this again after. You can take a look at #162 if you'd like to get started on where I left off.

The main problem is finding a way to tap into Bun's HMR to bundle the workflows/steps/webhook routes.

Open to thoughts!

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.

3 participants