#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
fix(frontend): prevent duplicate entry preloads in WebKit (#8050)
ConnorYoh613bed25c8d5
diff --git a/frontend/editor/src/core/tests/stubbed/console-clean.spec.ts b/frontend/editor/src/core/tests/stubbed/console-clean.spec.tsindex 5379f98705..7f585754e4 100644--- a/frontend/editor/src/core/tests/stubbed/console-clean.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/console-clean.spec.ts@@ -96,6 +96,12 @@ test.describe("Console hygiene: representative routes load cleanly", () => {for (const route of ROUTES) {test(`${route.name} (${route.path})`, async ({ page }) => {const entries = attachListeners(page);+ const scriptRequests: string[] = [];+ page.on("request", (request) => {+ if (request.resourceType() === "script") {+ scriptRequests.push(request.url());+ }+ });await page.goto(route.path, { waitUntil: "domcontentloaded" });// Give async effects (i18n load, lazy chunks, posthog init) a beat to// surface anything they were going to log.@@ -109,6 +115,17 @@ test.describe("Console hygiene: representative routes load cleanly", () => {if (!(err instanceof errors.TimeoutError)) throw err;});await expectCleanConsole(entries);+ const entryUrls = await page+ .locator('script[type="module"][src]')+ .evaluateAll((scripts) =>+ scripts.map((script) => (script as HTMLScriptElement).src),+ );+ for (const url of entryUrls) {+ expect(+ scriptRequests.filter((requestUrl) => requestUrl === url),+ `Entry module was fetched again by a lazy import: ${url}`,+ ).toHaveLength(1);+ }});}});diff --git a/frontend/editor/vite.config.ts b/frontend/editor/vite.config.tsindex 30d6b01680..353c806ecc 100644--- a/frontend/editor/vite.config.ts+++ b/frontend/editor/vite.config.ts@@ -423,6 +423,12 @@ export default defineConfig(async ({ mode, command }) => {},build: {target: "esnext",+ modulePreload: {+ // Lazy chunks can import the entry again. An upfront link lets Vite reuse+ // its preload instead of fetching an already-running module in WebKit.+ resolveDependencies: (filename, deps, { hostType }) =>+ hostType === "html" ? [filename, ...deps] : deps,+ },rollupOptions: {output: {manualChunks(id) {