fix(config): load webpack DefinePlugin via createRequire
This commit is contained in:
parent
7a49ff9896
commit
2fd9f05652
2 changed files with 10 additions and 3 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
import path from "node:path";
|
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 = [
|
const securityHeaders = [
|
||||||
{ key: 'X-Content-Type-Options', value: 'nosniff' },
|
{ key: 'X-Content-Type-Options', value: 'nosniff' },
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ interface HtmlDocumentRow {
|
||||||
|
|
||||||
type HashCheckResult =
|
type HashCheckResult =
|
||||||
| { ok: true; storedId: string; computedId: string }
|
| { 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.describe('Document Upload Tests', () => {
|
||||||
test.beforeEach(async ({ page }, testInfo) => {
|
test.beforeEach(async ({ page }, testInfo) => {
|
||||||
|
|
@ -60,7 +60,10 @@ test.describe('Document Upload Tests', () => {
|
||||||
.map((b) => b.toString(16).padStart(2, '0'))
|
.map((b) => b.toString(16).padStart(2, '0'))
|
||||||
.join('');
|
.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 {
|
} finally {
|
||||||
idb.close();
|
idb.close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue