Skip to content

Commit a1f71ee

Browse files
committed
test(vite): namespace imports for .server exports fail at build time
1 parent a04017b commit a1f71ee

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

integration/vite-dot-server-test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ test("Vite / .server file / named import in client fails with expected error",
3535
);
3636
});
3737

38+
test("Vite / .server file / namespace import in client fails with expected error", async () => {
39+
let cwd = await createProject({
40+
...files,
41+
"app/routes/fail-server-file-in-client.tsx": String.raw`
42+
import * as utils from "~/utils.server";
43+
44+
export default function() {
45+
console.log(utils.dotServerFile);
46+
return <h1>Fail: Server file included in client</h1>
47+
}
48+
`,
49+
});
50+
let client = viteBuild({ cwd })[0];
51+
let stderr = client.stderr.toString("utf8");
52+
expect(stderr).toMatch(
53+
`"dotServerFile" is not exported by "app/utils.server.ts"`
54+
);
55+
});
56+
3857
test("Vite / .server file / default import in client fails with expected error", async () => {
3958
let cwd = await createProject({
4059
...files,
@@ -71,6 +90,25 @@ test("Vite / .server dir / named import in client fails with expected error", as
7190
);
7291
});
7392

93+
test("Vite / .server dir / namespace import in client fails with expected error", async () => {
94+
let cwd = await createProject({
95+
...files,
96+
"app/routes/fail-server-dir-in-client.tsx": String.raw`
97+
import * as utils from "~/.server/utils";
98+
99+
export default function() {
100+
console.log(utils.dotServerDir);
101+
return <h1>Fail: Server directory included in client</h1>
102+
}
103+
`,
104+
});
105+
let client = viteBuild({ cwd })[0];
106+
let stderr = client.stderr.toString("utf8");
107+
expect(stderr).toMatch(
108+
`"dotServerDir" is not exported by "app/.server/utils.ts"`
109+
);
110+
});
111+
74112
test("Vite / .server dir / default import in client fails with expected error", async () => {
75113
let cwd = await createProject({
76114
...files,

0 commit comments

Comments
 (0)