From 2fd9f05652ede420c6783958b039d0e27fece9a9 Mon Sep 17 00:00:00 2001 From: Richard R Date: Thu, 21 May 2026 21:49:03 -0600 Subject: [PATCH] fix(config): load webpack DefinePlugin via createRequire --- next.config.ts | 6 +++++- tests/upload.spec.ts | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/next.config.ts b/next.config.ts index 3537f43..41721b8 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,6 +1,10 @@ import type { NextConfig } from "next"; import path from "node:path"; -import { DefinePlugin } from "webpack"; +import { createRequire } from "node:module"; + +type DefinePluginCtor = new (defs: Record) => unknown; +const require = createRequire(import.meta.url); +const { DefinePlugin } = require('webpack') as { DefinePlugin: DefinePluginCtor }; const securityHeaders = [ { key: 'X-Content-Type-Options', value: 'nosniff' }, diff --git a/tests/upload.spec.ts b/tests/upload.spec.ts index afcdef7..c43c7aa 100644 --- a/tests/upload.spec.ts +++ b/tests/upload.spec.ts @@ -8,7 +8,7 @@ interface HtmlDocumentRow { type HashCheckResult = | { ok: true; storedId: string; computedId: string } - | { ok: false; reason: 'Missing stored html document' }; + | { ok: false; reason: 'Missing stored html document' | 'Hash mismatch'; storedId?: string; computedId?: string }; test.describe('Document Upload Tests', () => { test.beforeEach(async ({ page }, testInfo) => { @@ -60,7 +60,10 @@ test.describe('Document Upload Tests', () => { .map((b) => b.toString(16).padStart(2, '0')) .join(''); - return { ok: computedId === docs[0].id, storedId: docs[0].id as string, computedId }; + if (computedId === docs[0].id) { + return { ok: true as const, storedId: docs[0].id as string, computedId }; + } + return { ok: false as const, reason: 'Hash mismatch', storedId: docs[0].id as string, computedId }; } finally { idb.close(); }