aidenybai / million

Optimize React performance and make your React 70% faster in minutes, not months.
https://million.dev
MIT License
16.38k stars 577 forks source link

lint compiler's `validateKey` function fails on vite dev servers running on windows #1150

Open dbarnespaychex opened 5 days ago

dbarnespaychex commented 5 days ago

What version of million are you using?

1.0.12

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Windows

What browser are you using?

Chrome

Describe the Bug

I can't find the source code here, but node_modules\@million\lint\dist\compiler\index.mjs line 2032 has this logic:

if (typeof filename !== "string" || !filename.includes("/"))
    return false;

On Windows, the filename includes \\ characters, so the validateKey function always fails, causing the .vite cache to be cleared and then crashing the Vite dev server because the "cache has been corrupted".

For better compatibility I think you should remove the hard-coded "/" and instead use path.sep:

  if (typeof filename !== "string" || !filename.includes(path.sep))
    return false;

After making that change locally, everything works as expected.

NOTE: The stackblitz link doesn't show the error because it fails before that point on some connection issue.

What's the expected result?

I would expect Vite dev server's cache not to be cleared while running.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/vitejs-vite-5iaffw?file=vite.config.ts

Participation

github-actions[bot] commented 5 days ago

Thanks for opening this issue! A maintainer will review it soon.

aidenybai commented 4 days ago

@dbarnespaychex, repro'd and made a fix, patch will be rolled out in the next release. Thanks for reporting!

dbarnespaychex commented 4 days ago

You're awesome. Thank you.

aidenybai commented 3 days ago

@dbarnespaychex we're in a bit of mid-refactor. I'll try to manually roll out the update sometime today/tomorrow, expect the latest EOW