Overview
As called out in WCC and MDN, code that needs to run in multiple environments should delegate any "global" references to the new globalThis.
The globalThis property provides a standard way of accessing the global this value (and hence the global object itself) across environments. Unlike similar properties such as window and self, it's guaranteed to work in window and non-window contexts. In this way, you can access the global object in a consistent manner without having to know which environment the code is being run in. To help you remember the name, just remember that in global scope the this value is globalThis.
This means that instead of calling window.addEventListener you would want to use globalThis.addEventListener.
Each environment can choose to polyfill or support some, none, or all of these features, and the code doesn't necessarily have to worry about feature detection, e.g.
if(window) {
// ... do stuff
}
Details
For Greenwood, this would apply to
Should also update to latest version of WCC to accommodate this.
One way to test is to pre-render the website with WCC instead of Puppeteer.
Overview
As called out in WCC and MDN, code that needs to run in multiple environments should delegate any "global" references to the new
globalThis.This means that instead of calling
window.addEventListeneryou would want to useglobalThis.addEventListener.Each environment can choose to polyfill or support some, none, or all of these features, and the code doesn't necessarily have to worry about feature detection, e.g.
Details
For Greenwood, this would apply to
staticRouterShould also update to latest version of WCC to accommodate this.
One way to test is to pre-render the website with WCC instead of Puppeteer.