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
8 changes: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ permissions:

jobs:
tests:
name: Build and test
runs-on: ubuntu-latest
name: Build and test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions src/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ export function fileRoutes(options: FileRoutesOptions = {}): PluginOption[] {
// plus the `src` lazy refs already expose.
if (!codeSplitting) {
return {
src: relative(root, buildId),
src: normalizePath(relative(root, buildId)),
require: `_$() => (${js.addNamespaceImport(buildId)})$_`
};
}
return {
src: relative(root, buildId),
src: normalizePath(relative(root, buildId)),
build: isBuild ? `_$() => import('${buildId}')$_` : undefined,
import: `_$() => import('${buildId}')$_`
};
Expand Down
15 changes: 15 additions & 0 deletions test/vite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ describe("fileRoutes vite plugin", () => {
expect(code.match(/pick=default&pick=\$css&lang\.tsx'\)/g)?.length).toBe(2);
});

it("serializes lazy-ref src values with forward slashes", async () => {
const directory = createRouteTree({
"index.tsx": "export default () => <h1>Home</h1>;"
});

const split = await loadVirtualModule(directory);
const eager = await loadWith(createPlugin(directory, { codeSplitting: false }), directory);

// `src` is matched against Vite's manifest keys, which are always posix,
// so it must not carry the platform separator node:path emits on Windows
const src = '"src":"src/routes/index.tsx?pick=default&pick=$css&lang.tsx"';
expect(split).toContain(src);
expect(eager).toContain(src);
});

it("resolves only the virtual module id", async () => {
const [plugin] = fileRoutes() as any[];
expect(moduleId).toBe("virtual:file-routes");
Expand Down
Loading