Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

🐛 Work around incorrect global context in @percy/dom #164

Merged
merged 2 commits into from
Feb 4, 2021

Conversation

wwilsman
Copy link
Contributor

@wwilsman wwilsman commented Feb 4, 2021

What is this?

The @percy/dom package uses a UMD format which assigns exports to a globalThis variable when in a browser environment. However, if the implementation of globalThis is incorrect (mozilla/geckodriver#1798), the PercyDOM object is not correctly carried forward into other script executions where the DOM is meant to be serialized.

This PR aims to work around this issue by checking if window and globalThis are not equal to each other (which technically should be impossible under normal circumstances). If they are not equal, the library adds itself to window ahead of the eventual UMD dance.

While testing this, I also noticed that babel helpers were inlined multiple times. Updating this setting to bundled will ensure they are only bundled once in the final output.

@wwilsman wwilsman added the 🐛 bug Something isn't working label Feb 4, 2021
@wwilsman wwilsman requested a review from Robdel12 February 4, 2021 00:56
Copy link
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

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

🏁 I should have caught this the first time around.

@wwilsman wwilsman merged commit a7e077d into master Feb 4, 2021
@wwilsman wwilsman deleted the ww/dom-bundle-this-workaround branch February 4, 2021 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants