Skip to content
This repository has been archived by the owner on Jan 31, 2025. It is now read-only.

WeakMap expected key #119

Closed
kevcomparadise opened this issue Feb 2, 2024 · 1 comment
Closed

WeakMap expected key #119

kevcomparadise opened this issue Feb 2, 2024 · 1 comment

Comments

@kevcomparadise
Copy link

Hello,

I've been using PostRobot for a while. I use it to communicate with my application when implementing it in an iframe. I am on Nuxt2, and it works very well.

I am currently migrating to Nuxt3 and encountering an issue. When importing the library (on the client side), I get an error like this:

"WeakMap expected key."
at _proto.has (http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/post-robot.js?v=de6bb484:931:21) at _proto.getOrSet (http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/post-robot.js?v=de6bb484:950:22) at getStore (http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/post-robot.js?v=de6bb484:1262:31) at Object.getOrSet (http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/post-robot.js?v=de6bb484:1280:38) at addRequestListener (http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/post-robot.js?v=de6bb484:2212:53) at on_on (http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/post-robot.js?v=de6bb484:2237:12) at http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/post-robot.js?v=de6bb484:2527:32 at util_getOrSet (http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/post-robot.js?v=de6bb484:1121:21) at Object.getOrSet (http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/post-robot.js?v=de6bb484:1238:24) at http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/post-robot.js?v=de6bb484:2526:47

I don't understand why, as I have the window variable accessible.

Thank you for your help.

@pegiadise
Copy link

pegiadise commented Mar 11, 2024

Same issue. Can work around it via if you import the browser version directly. Hope it saves some time to someone.

  // nuxt.config.ts
  app: {
    head: {
      // make sure to match your iframe version, @krakenjs scoped package doesn't work with this one...
      script: [{ src: 'https://unpkg.com/[email protected]/dist/post-robot.min.js' }], 
    },
  },
// global.d.ts at root nuxt folder
import PostRobot from 'post-robot'

export {}

declare global {
  interface Window {
    __NUXT__: any
    postRobot: typeof PostRobot
  }
}

@stramel stramel closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants