Skip to content

Bug: WASM Compilation Fails - "No matching export in node:buffer" #131

@gilbertsahumada

Description

@gilbertsahumada

Bug: WASM Compilation Fails - "No matching export in node:buffer"

Description

Workflows fail to compile to WASM with error: could not load module 'node:buffer'

This occurs because in the cre-sdk-typescript:

  1. prepare-runtime.ts imports Buffer from node:buffer
  2. Javy (the JS→WASM compiler) cannot load Node.js built-in modules
  3. Bun bundler uses browser polyfills instead of Node.js modules (missing --target=node)

Steps to Reproduce

# 1. Create new workflow using ts-sdk
cre init test-workflow
cd test-workflow

# 2. Create simple workflow 
# 3. Run simulation
cre workflow simulate . --broadcast --target local-simulation

Error:
error: No matching export in "node:buffer" for import "Buffer"
Error: could not load module 'node:buffer'

Environment

- OS: macOS (Darwin 24.4.0)
- Bun: 1.1.30
- SDK: @chainlink/cre-sdk@0.0.9-alpha
- CRE CLI: (cre version v0.6.4-alpha)

Proposed Fix

1. packages/cre-sdk/src/sdk/utils/prepare-runtime.ts - Buffer polyfill
2. packages/cre-sdk/scripts/src/compile-to-js.ts - Add --target=node

Workaround

Use local SDK build with fixes applied.

The fixes should be implemented in the ts-sdk. I can create a PR with the solution for you to review if there are no issues.

tag @zeuslawyer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions