diff --git a/src/index.tsx b/src/index.tsx index 4e47a8bf..5f59ca5c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,27 +1,9 @@ +// The polyfill must be imported before anything else, as it may be required by +// other modules. +import "./polyfill"; import { preloadWasm } from "./livesplit-core/preload"; import { Label, resolve } from "./localization"; -// FIXME: Remove the polyfill later. -// https://caniuse.com/mdn-javascript_statements_using - -if (typeof Symbol.dispose !== "symbol") { - Object.defineProperty(Symbol, "dispose", { - configurable: false, - enumerable: false, - writable: false, - value: Symbol.for("dispose"), - }); -} - -if (typeof Symbol.asyncDispose !== "symbol") { - Object.defineProperty(Symbol, "asyncDispose", { - configurable: false, - enumerable: false, - writable: false, - value: Symbol.for("asyncDispose"), - }); -} - if ( process.env.NODE_ENV === "production" && window.__TAURI__ == null && diff --git a/src/polyfill.ts b/src/polyfill.ts new file mode 100644 index 00000000..ac84364f --- /dev/null +++ b/src/polyfill.ts @@ -0,0 +1,19 @@ +// FIXME: Remove the polyfill later. +// https://caniuse.com/mdn-javascript_statements_using +if (typeof Symbol.dispose !== "symbol") { + Object.defineProperty(Symbol, "dispose", { + configurable: false, + enumerable: false, + writable: false, + value: Symbol.for("dispose"), + }); +} + +if (typeof Symbol.asyncDispose !== "symbol") { + Object.defineProperty(Symbol, "asyncDispose", { + configurable: false, + enumerable: false, + writable: false, + value: Symbol.for("asyncDispose"), + }); +}