Repository navigation
Conversation
[Medium impact] The change affects view scanning and warnings in the Skybridge Vite plugin. The fix appears safe to merge; adding Windows test coverage is a non-blocking improvement. SummaryThe PR converts backslashes to forward slashes in view dependency-scan globs and the pattern used to warn about missing default exports.
Reviews (1) · Last reviewed commit: "fix(vite-plugin): use forward slashes in..." · Reviewed by Greptile |
| it("gives Vite forward-slash globs for the dependency scan", () => { | ||
| const entries = getConfig(root).optimizeDeps?.entries; | ||
|
|
||
| expect(entries).toHaveLength(2); | ||
| for (const entry of entries as string[]) { | ||
| expect(entry).not.toContain("\\"); | ||
| } |
There was a problem hiding this comment.
CI misses the Windows regressions
Both new tests still pass with the old code on Linux, and CI runs unit tests only on Ubuntu. The Windows job only builds, so either Windows bug could return without CI catching it. Run these tests in the Windows job, or add tests that exercise backslash paths on every platform.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/vite-plugin/src/plugin.test.ts
Line: 116-122
Comment:
**CI misses the Windows regressions**
Both new tests still pass with the old code on Linux, and CI runs unit tests only on Ubuntu. The Windows job only builds, so either Windows bug could return without CI catching it. Run these tests in the Windows job, or add tests that exercise backslash paths on every platform.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Right, both tests passed with the old code on Linux. Fixed in 9eae65c.
The tests now pass the views dir as ${root}\views. On Linux that path is absolute and keeps the backslash, so the old code puts it in the glob and in the view pattern, and both tests fail there too. On Windows it is the normal path.
Checked on Windows: with the old plugin.ts the 2 tests fail, with this branch all 17 pass. biome ci and tsc are clean. I can't run Linux here, so I checked that case with node's path.posix: the old code keeps the backslash in the entry and its pattern does not match the module id, the new code does both right.
Fixes #1164
What
resolve()returns a path with backslashes on Windows. The plugin put that path intooptimizeDeps.entriesand into the regex that matches Vite module ids. Globs read\as an escape and Vite ids use/, so on Windows the dependency scan found no views and the "missing a default export" warning intransformnever matched.This adds
toPosixPath()and uses it for both entries and the regex. It is the same conversionbuildVirtualEntryalready does. On macOS and Linux nothing changes, since those paths hold no backslash.Behavior change
Only on Windows:
optimizeDeps.entriesnow match the view files, so view dependencies get pre-bundled at startup, as the comment in the plugin intends. The default-export warning intransformnow fires there too.Tests
packages/vite-plugin/src/plugin.test.ts: entries hold no backslash, andtransformwarns for a forward-slash module id. Both fail on main on Windows and pass with the change. On Linux they pass on main too, since there is no backslash to convert.npx vitest runinpackages/vite-plugin: 4 files, 17 tests pass.npx biome ci srcandtsc --noEmit -p tsconfig.test.jsonare clean.['react'], forward-slash entries find['react', 'react/jsx-dev-runtime', 'zod'].Validated with Claude Opus 5.5.