Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove duplicate manifest imports introduced by defer work #5534

Merged
merged 1 commit into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-bulldogs-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/react": patch
---

remove duplicate manifest imports
29 changes: 29 additions & 0 deletions integration/link-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,33 @@ test.describe("route module link export", () => {
expect(await locator.getAttribute("imagesizes")).toBe("100vw");
});
});

test.describe("script imports", () => {
test("are added to the document", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/");
let scripts = await page.$$("script");
expect(scripts.length).toEqual(2);
expect(await scripts[0].innerText()).toContain("__remixContext");
let moduleScript = scripts[1];
expect(await moduleScript.getAttribute("type")).toBe("module");
let moduleScriptText = await moduleScript.innerText();
expect(
Array.from(moduleScriptText.matchAll(/import "\/build\/manifest-/g)),
"invalid build manifest"
).toHaveLength(1);
expect(
Array.from(moduleScriptText.matchAll(/import \* as route0 from "/g)),
"invalid route0"
).toHaveLength(1);
expect(
Array.from(moduleScriptText.matchAll(/import \* as route1 from "/g)),
"invalid route1"
).toHaveLength(1);
expect(
Array.from(moduleScriptText.matchAll(/import \* as route2 from "/g)),
"too many routes"
).toHaveLength(0);
});
});
});
6 changes: 3 additions & 3 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -904,11 +904,11 @@ export function Scripts(props: ScriptProps) {

let routeModulesScript = !isStatic
? " "
: `${matches
: `import ${JSON.stringify(manifest.url)};
${matches
.map(
(match, index) =>
`import ${JSON.stringify(manifest.url)};
import * as route${index} from ${JSON.stringify(
`import * as route${index} from ${JSON.stringify(
manifest.routes[match.route.id].module
)};`
)
Expand Down