Skip to content

Commit d2b4fd6

Browse files
committed
Detect vinext middleware on case-insensitive filesystems, closes #743.
1 parent b4597a0 commit d2b4fd6

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

‎packages/void/src/plugin-framework-entry.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ const TANSTACK_SERVER_ENTRY = '@tanstack/react-start/server-entry';
5050

5151
/** Include proxy.ts and custom page extensions; vinext selects the actual convention file. */
5252
export function hasVinextMiddleware(root: string): boolean {
53+
// Convention lookup also succeeds with different casing on macOS and Windows.
5354
return [root, join(root, 'src')].some(
5455
(dir) =>
5556
statSync(dir, { throwIfNoEntry: false })?.isDirectory() &&
56-
readdirSync(dir).some((file) => /^(?:middleware|proxy)\./.test(file)),
57+
readdirSync(dir).some((file) => /^(?:middleware|proxy)\./i.test(file)),
5758
);
5859
}
5960

‎packages/void/test/unit/plugin-class-a-wrapper.test.ts‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,20 @@ afterEach(() => {
7474
});
7575

7676
describe('Class A framework custom entry', () => {
77-
it.each(['middleware.ts', 'src/middleware.js', 'proxy.ts', 'src/proxy.custom.ts'])(
78-
'detects vinext convention file %s without importing application code',
79-
(file) => {
80-
const root = createTanStackRoot();
81-
expect(hasVinextMiddleware(root)).toBe(false);
82-
mkdirSync(join(root, file, '..'), { recursive: true });
83-
writeFileSync(join(root, file), 'throw new Error("must not execute during config");');
84-
expect(hasVinextMiddleware(root)).toBe(true);
85-
},
86-
);
77+
it.each([
78+
'middleware.ts',
79+
'src/middleware.js',
80+
'proxy.ts',
81+
'src/proxy.custom.ts',
82+
'Middleware.ts',
83+
'src/Proxy.ts',
84+
])('detects vinext convention file %s without importing application code', (file) => {
85+
const root = createTanStackRoot();
86+
expect(hasVinextMiddleware(root)).toBe(false);
87+
mkdirSync(join(root, file, '..'), { recursive: true });
88+
writeFileSync(join(root, file), 'throw new Error("must not execute during config");');
89+
expect(hasVinextMiddleware(root)).toBe(true);
90+
});
8791

8892
it.each(['serve', 'build'] as const)(
8993
'preserves a custom TanStack Worker entry and named exports during %s',

0 commit comments

Comments
 (0)