Skip to content

WeakRef is not supported in Cloudflare Workers #1949

Description

@daniandl

Environment

playground

Reproduction

https://stackblitz.com/edit/nuxt-starter-wgz5jk?file=app.vue

Wrangler probably won't work inside the playground, you will need to clone locally.
Run NITRO_PRESET=cloudflare_pages pnpm run build to build the server.
Then run npx wrangler pages dev dist/

The page will have an error about WeakRef not being defined.

Describe the bug

WeakRef is not supported in Cloudflare Workers currently.
That makes it impossible to run this plugin with Nuxt SSR.

Additional context

Workaround:
You can polyfill this by making a plugins/weakref-polyfill.server.ts file and adding the contents of https://github.com/jaenster/weakref-pollyfill/blob/master/src/index.js.
Don't forget to add export default defineNuxtPlugin(() => {}) at the end or it will be ignored at build time.

You may consider polyfilling WeakRef in this package, but it is probably out of scope for this library.

I hope that is the last of my issues with this library for a while :)

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions