From da3acb6586aa2c81a7cd208dc64cc6b86a37d0f2 Mon Sep 17 00:00:00 2001 From: Vaadin Bot Date: Fri, 28 Feb 2025 15:30:08 +0100 Subject: [PATCH] chore: fix `Array.fromAsync` polyfill (#3306) (CP: 24.7) (#3307) --- scripts/build.ts | 10 ++-------- scripts/polyfills.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 scripts/polyfills.ts diff --git a/scripts/build.ts b/scripts/build.ts index a80c9bd930..8a965be5ea 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -1,4 +1,6 @@ +import './polyfills.js'; import { mkdir, readFile, writeFile } from 'node:fs/promises'; +import { isAbsolute } from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; import { globIterate as glob } from 'glob'; import type { PackageJson } from 'type-fest'; @@ -8,14 +10,6 @@ import dir from './utils/dir.js'; import injectRegister from './utils/injectRegister.js'; import loadTSConfig from './utils/loadTSConfig.js'; import redirectURLPart from './utils/redirectURLPart.js'; -import { isAbsolute } from 'node:path'; - -if (!('fromAsync' in Array)) { - const { fromAsync } = await import('array-from-async'); - Object.defineProperty(Array, 'fromAsync', { - value: fromAsync, - }); -} const cwd = pathToFileURL(dir(process.cwd())); const sourceDir = new URL('src/', cwd); diff --git a/scripts/polyfills.ts b/scripts/polyfills.ts new file mode 100644 index 0000000000..4b1ee42591 --- /dev/null +++ b/scripts/polyfills.ts @@ -0,0 +1,8 @@ +if (!('fromAsync' in Array)) { + const { default: fromAsync } = await import('array-from-async'); + Object.defineProperty(Array, 'fromAsync', { + value: fromAsync, + }); +} + +export {};