Skip to content

Commit c6666a2

Browse files
Fix test story to avoid Vitest transformation issue with inline loader
The loader function needs to be defined separately to prevent Vitest's wrapDynamicImport from stripping the .then() callback when the loader is defined inline in dynamic() with ssr: false. Co-authored-by: valentinpalkovic <[email protected]>
1 parent c067304 commit c6666a2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

example/src/app/components/DynamicImport/DynamicImport.stories.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ const DynamicComponentNoSSR = dynamic(() => import("./DynamicImport"), {
88
});
99

1010
// Test case that matches the user's issue pattern: using .then((mod) => mod.Component) with ssr: false
11-
const DynamicNamedComponentNoSSR = dynamic(
12-
() => import("./NamedExport").then((mod) => mod.NamedComponent),
13-
{ ssr: false },
14-
);
11+
const namedExportLoader = () =>
12+
import("./NamedExport").then((mod) => mod.NamedComponent);
13+
const DynamicNamedComponentNoSSR = dynamic(namedExportLoader, { ssr: false });
1514

1615
// Test without ssr: false to check if issue is SSR-specific
1716
const DynamicNamedComponent = dynamic(() =>

0 commit comments

Comments
 (0)