fix(config): load webpack DefinePlugin via createRequire

This commit is contained in:
Richard R 2026-05-21 21:49:03 -06:00
parent 7a49ff9896
commit 2fd9f05652
2 changed files with 10 additions and 3 deletions

View file

@ -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<string, string>) => unknown;
const require = createRequire(import.meta.url);
const { DefinePlugin } = require('webpack') as { DefinePlugin: DefinePluginCtor };
const securityHeaders = [
{ key: 'X-Content-Type-Options', value: 'nosniff' },

View file

@ -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();
}