diff --git a/.changeset/few-pumpkins-sit.md b/.changeset/few-pumpkins-sit.md new file mode 100644 index 0000000000..e3ac2ae8a7 --- /dev/null +++ b/.changeset/few-pumpkins-sit.md @@ -0,0 +1,6 @@ +--- +"@patternfly/pfe-tools": patch +"@patternfly/pfe-core": patch +--- + +SSR: add shim for `ResizeObserver` diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5ff7d7747c..7aabf6c219 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -73,7 +73,7 @@ jobs: - name: Configure node version uses: actions/setup-node@v4 with: - node-version: '20' + node-version-file: '.nvmrc' cache: npm - name: Install dependencies @@ -100,7 +100,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '20' + node-version-file: '.nvmrc' cache: npm - run: npm ci --prefer-offline - run: npm run build @@ -110,7 +110,7 @@ jobs: env: HOME: /root - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 if: always() with: name: ${{ env.PLAYWRIGHT_REPORT_DIR }} @@ -130,7 +130,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Download zipped HTML report - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4 with: name: ${{ env.PLAYWRIGHT_REPORT_DIR }} path: ${{ env.PLAYWRIGHT_REPORT_DIR }}/ diff --git a/core/pfe-core/ssr-shims.ts b/core/pfe-core/ssr-shims.ts index 30a6c904c9..2fe31e6d6a 100644 --- a/core/pfe-core/ssr-shims.ts +++ b/core/pfe-core/ssr-shims.ts @@ -41,6 +41,8 @@ globalThis.IntersectionObserver ??= ObserverShim; // @ts-expect-error: this runs in node globalThis.MutationObserver ??= ObserverShim; // @ts-expect-error: this runs in node +globalThis.ResizeObserver ??= ObserverShim; +// @ts-expect-error: this runs in node globalThis.getComputedStyle ??= function() { return { getPropertyPriority() { diff --git a/tools/pfe-tools/ssr/global.ts b/tools/pfe-tools/ssr/global.ts index 7fb785d67a..5209242b4f 100644 --- a/tools/pfe-tools/ssr/global.ts +++ b/tools/pfe-tools/ssr/global.ts @@ -8,7 +8,8 @@ export async function renderGlobal( html: string, importSpecifiers: string[], ): Promise { - await import('./shims.js'); + // avoid tsconfig problems + await import(['@patternfly', 'pfe-core', 'ssr-shims.js'].join('/')); const { ssr } = await import('./ssr.js'); await Promise.all(importSpecifiers.map(x => import(x))); return ssr(html); diff --git a/tools/pfe-tools/ssr/shims.ts b/tools/pfe-tools/ssr/shims.ts deleted file mode 100644 index 171259ec46..0000000000 --- a/tools/pfe-tools/ssr/shims.ts +++ /dev/null @@ -1,30 +0,0 @@ -export class ObserverShim { - observe(): void { - void 0; - } - - disconnect(): void { - void 0; - } -} - -// @ts-expect-error: i'm shimmin' here! -globalThis.window ??= globalThis; -// @ts-expect-error: i'm shimmin' here! -globalThis.ErrorEvent ??= Event; -// @ts-expect-error: i'm shimmin' here! -globalThis.IntersectionObserver ??= ObserverShim; -// @ts-expect-error: i'm shimmin' here! -globalThis.MutationObserver ??= ObserverShim; -// @ts-expect-error: i'm shimmin' here! -globalThis.getComputedStyle ??= function() { - return { - getPropertyPriority(): string { - return ''; - }, - getPropertyValue(): string { - return ''; - }, - }; -}; -