Skip to content

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

@dbarnespaychex

Description

@dbarnespaychex

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

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions