CodeDredd / pinia-orm

The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.
https://pinia-orm.codedredd.de/
MIT License
454 stars 39 forks source link

WeakRef is not supported in Cloudflare Workers #1949

Open daniandl opened 2 weeks ago

daniandl commented 2 weeks ago

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

CodeDredd commented 5 hours ago

@daniandl ok...have you tried using this SimpleCache in the config? I think this should solve it.

related: https://github.com/cloudflare/workerd/issues/3053