Skip to content
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: 4 additions & 1 deletion packages/react/test/integration/react-pages-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,10 @@ describe('react-pages client (dev)', () => {
});

const serverTimeout = process.platform === 'win32' ? 45_000 : 20_000;
await waitForServer(DEV_BASE, serverTimeout);
await waitForServer(DEV_BASE, serverTimeout, {
isAlive: () => child.exitCode === null && child.signalCode === null,
diagnostics: collectServerOutput(child),
});
const paths = ['/', '/users', '/action-error', '/router-params/alpha', '/visit-await'];
coldStartResponses.push(
...(await Promise.all(
Expand Down
4 changes: 2 additions & 2 deletions packages/void/src/plugin-env-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ function stripLocalClientEnv(
}
}

/** Vite resolves symlinks in `root` (and so `envDir`); compare real paths. */
/** Match Vite's canonical paths, including Windows short names and filesystem casing. */
function realDir(dir: string): string {
try {
return realpathSync(dir);
return realpathSync.native(dir);
} catch {
return resolve(dir);
}
Expand Down
17 changes: 16 additions & 1 deletion packages/void/test/integration/plugin-env-schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { basename, dirname, join } from 'node:path';
import { build, createBuilder, resolveConfig, type InlineConfig } from 'vite';
import { afterEach, describe, expect, it, vi } from 'vite-plus/test';
import { envClientFoldPlugin } from '../../src/plugin-env-client-fold.ts';
Expand Down Expand Up @@ -247,6 +247,21 @@ describe('envSchemaPlugin auto-discovery', () => {
expect(code).not.toContain('local-api');
});

it('strips local client values when Vite canonicalizes the root casing', async (context) => {
const root = createTempRoot();
const aliasedRoot = join(dirname(root), basename(root).toUpperCase());
if (!existsSync(aliasedRoot)) {
context.skip();
}
writeFileSync(join(root, '.env'), 'VITE_API=local-api\n');
writeFileSync(join(root, 'entry.js'), 'export const api = import.meta.env.VITE_API;\n');
vi.stubEnv('VITE_API', undefined);

const code = await buildEntry(aliasedRoot);

expect(code).not.toContain('local-api');
});

it('keeps a .env NODE_ENV out of a production client build', async () => {
const root = createTempRoot();
writeFileSync(join(root, '.env'), 'NODE_ENV=local-node-env\n');
Expand Down
Loading