Skip to content

fix(vite-plugin): use forward slashes in the view globs and pattern on Windows - #1165

Open
goranai wants to merge 2 commits into
alpic-ai:mainfrom
goranai:fix/vite-plugin-windows-glob
Open

goranai wants to merge 2 commits into
alpic-ai:mainfrom
goranai:fix/vite-plugin-windows-glob

Conversation

@goranai

@goranai goranai commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1164

What

resolve() returns a path with backslashes on Windows. The plugin put that path into optimizeDeps.entries and 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 in transform never matched.

This adds toPosixPath() and uses it for both entries and the regex. It is the same conversion buildVirtualEntry already does. On macOS and Linux nothing changes, since those paths hold no backslash.

Behavior change

Only on Windows: optimizeDeps.entries now match the view files, so view dependencies get pre-bundled at startup, as the comment in the plugin intends. The default-export warning in transform now fires there too.

Tests

  • Two new tests in packages/vite-plugin/src/plugin.test.ts: entries hold no backslash, and transform warns 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 run in packages/vite-plugin: 4 files, 17 tests pass.
  • npx biome ci src and tsc --noEmit -p tsconfig.test.json are clean.
  • Differential fuzz of the pattern on Windows paths, 20000 cases against an oracle: main wrong on 12470 (every view file), fix wrong on 0, no case where main was right and the fix wrong.
  • Real Vite 8 dependency scan: backslash entries find ['react'], forward-slash entries find ['react', 'react/jsx-dev-runtime', 'zod'].

Validated with Claude Opus 5.5.

@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[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.

Summary

The PR converts backslashes to forward slashes in view dependency-scan globs and the pattern used to warn about missing default exports.

  • The Vite plugin uses forward slashes for view paths.

Reviews (1) · Last reviewed commit: "fix(vite-plugin): use forward slashes in..." · Reviewed by Greptile

Comment on lines +116 to +122
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("\\");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vite-plugin: on Windows the view dependency scan finds no views, so no view dependencies are pre-bundled

1 participant