Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

WeakMap expected key #119

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

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/post-robot@10.0.46/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
  }
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants