diff --git a/client/ErrorOverlayEntry.js b/client/ErrorOverlayEntry.js index 1a94b3a9..ae8b6f33 100644 --- a/client/ErrorOverlayEntry.js +++ b/client/ErrorOverlayEntry.js @@ -2,7 +2,7 @@ import { handleError, handleUnhandledRejection } from './utils/errorEventHandlers.js'; import formatWebpackErrors from './utils/formatWebpackErrors.js'; -import runWithPatchedUrl from './utils/patchUrl.js'; +import runWithPatchedUrl from './utils/patchUrl.cjs'; // Setup error states let isHotReload = false; diff --git a/client/utils/patchUrl.js b/client/utils/patchUrl.cjs similarity index 69% rename from client/utils/patchUrl.js rename to client/utils/patchUrl.cjs index 4d896863..03bb5fb8 100644 --- a/client/utils/patchUrl.js +++ b/client/utils/patchUrl.cjs @@ -1,6 +1,4 @@ /* global __react_refresh_polyfill_url__ */ -import SafeURL from 'core-js-pure/web/url'; -import SafeURLSearchParams from 'core-js-pure/web/url-search-params'; /** * @typedef {Object} UrlAPIs @@ -14,23 +12,23 @@ import SafeURLSearchParams from 'core-js-pure/web/url-search-params'; * @returns {void} */ function runWithPatchedUrl(callback) { - let __originalURL; - let __originalURLSearchParams; + var __originalURL; + var __originalURLSearchParams; // Polyfill the DOM URL and URLSearchParams constructors if (__react_refresh_polyfill_url__ || !window.URL) { __originalURL = window.URL; - window.URL = SafeURL; + window.URL = require('core-js-pure/web/url'); } if (__react_refresh_polyfill_url__ || !window.URLSearchParams) { __originalURLSearchParams = window.URLSearchParams; - window.URLSearchParams = SafeURLSearchParams; + window.URLSearchParams = require('core-js-pure/web/url-search-params'); } - // Pass in polyfilled URL APIs in case they are needed + // Pass in URL APIs in case they are needed callback({ URL: window.URL, URLSearchParams: window.URLSearchParams }); - // Restore polyfills to their original state + // Restore polyfill-ed APIs to their original state if (__originalURL) { window.URL = __originalURL; } @@ -39,4 +37,4 @@ function runWithPatchedUrl(callback) { } } -export default runWithPatchedUrl; +module.exports = runWithPatchedUrl; diff --git a/lib/utils/makeRefreshRuntimeModule.js b/lib/utils/makeRefreshRuntimeModule.js index 3cdf33e4..ea9211c9 100644 --- a/lib/utils/makeRefreshRuntimeModule.js +++ b/lib/utils/makeRefreshRuntimeModule.js @@ -37,7 +37,7 @@ function makeRefreshRuntimeModule(webpack) { ), '} finally {', webpack.Template.indent([ - `if (moduleObject.exports instanceof ${webpack.RuntimeGlobals.global}.Promise) {`, + `if (typeof Promise !== 'undefined' && moduleObject.exports instanceof Promise) {`, webpack.Template.indent([ // Ponyfill `Promise.finally` as it is only part of the spec after ES2018, // and Webpack's top level await implementation only rely on ES2015 Promises.