Skip to content

Conversation

@tebexjaames
Copy link
Contributor

Nuxt tries to change instances of global to globalThis, however it's a little overzealous, and ends up breaking Zoid / post-robot since it replaces a local variable named global inside the getWildcard function.

This would cause the error Unhandled Promise Rejection: Error: WeakMap expected key to be thrown when trying to launch the tebex.js popup.

This particular line in Nuxt is the culprit:
https://github.com/nuxt/nuxt/blob/a69751b96d35b0b2a4d7674652c604e45370f60c/packages/vite/src/vite.ts#L243

Which was causing this line in post-robot to be incorrectly replaced with globalThis.WINDOW_WILDCARD:
https://github.com/krakenjs/post-robot/blob/30ab862e90a023531cd46d5fe8a7342c887b521b/src/global.js#L89

This solution uses Rollup's replace function to rename the variable so that it won't be replaced by Nuxt.

@tebexjaames tebexjaames requested a review from Chilledson April 8, 2025 11:46
@Chilledson Chilledson requested a review from Copilot April 8, 2025 12:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • package.json: Language not supported
Comments suppressed due to low confidence (2)

rollup.config.js:64

  • [nitpick] Consider specifying explicit delimiters to narrowly match the intended code snippets, which helps avoid accidental replacements if the surrounding context changes.
                delimiters: ["", ""]

rollup.config.js:61

  • Verify that the new variable name 'zoidGlobal' is consistently used throughout the codebase to prevent mismatches.
                    "var global = global_getGlobal();": "var zoidGlobal = global_getGlobal();",

@Chilledson Chilledson merged commit 4f71f52 into tebexio:main Apr 8, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants