-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Describe the bug
I was attempting to run mastra within next.js on cloudflare using OpenNext and hit an issue with module resolution for xxhash which provides a conditional import for workerd to support workers. From the error I'm getting it seems to stuggle to create the server bundle due to the wasm/workerd setup within xxhash.
I'm not sure if this is specific to that package or all packages that have added a workerd conditional import, in this case the workerd specific entrypoint is there to allow for wasm to be imported.
I've recreated the setup using the default templates from both, it can be found here.
Would be good if someone outlined if this was expected to work or fell outside the supported path for opennext/cloudflare.
partial error, full error found in repo readme;
Applying code patches: 1.921s
# copyPackageTemplateFiles
⚙️ Bundling the OpenNext server...
✘ [ERROR] Could not resolve "xxhash-wasm"
.open-next/server-functions/default/node_modules/@mastra/memory/dist/index.js:6:19:
6 │ import xxhash from 'xxhash-wasm';
╵ ~~~~~~~~~~~~~
The module "./workerd/xxhash-wasm.js" was not found on the file system:
.open-next/server-functions/default/node_modules/xxhash-wasm/package.json:10:15:
10 │ "workerd": "./workerd/xxhash-wasm.js",
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "xxhash-wasm" as external to exclude it from the bundle, which will remove
this error and leave the unresolved path in the bundle.
✘ [ERROR] Could not resolve "cloudflare/_shims/auto/runtime"
.open-next/server-functions/default/node_modules/cloudflare/_shims/index.mjs:5:22:
5 │ import * as auto from 'cloudflare/_shims/auto/runtime';
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Steps to reproduce
You can easily create this by setting up mastra on the default template like so https://github.com/timReynolds/my-cf-mastra-next-app
Expected behavior
This runs and deploys as expected
@opennextjs/cloudflare version
latest
Wrangler version
latest
next info output
see example
Additional context
No response