Skip to content

8139322383 Fix Nuxt support#20

Merged
Chilledson merged 3 commits into
tebexio:mainfrom
tebexjaames:8139322383-fix-nuxt-support
Apr 8, 2025
Merged

8139322383 Fix Nuxt support#20
Chilledson merged 3 commits into
tebexio:mainfrom
tebexjaames:8139322383-fix-nuxt-support

Conversation

@tebexjaames

Copy link
Copy Markdown
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

Copilot AI left a comment

Copy link
Copy Markdown

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
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.

3 participants