Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev): optimizeDeps entries file paths on Windows #10257

Closed
wants to merge 6 commits into from

Conversation

sebastien-comeau
Copy link
Contributor

Pull Request Description:

Normalize Path for Vite Dependency Optimization on Windows

This PR addresses an issue with Vite's dependency optimization on Windows systems where incorrect path formats can lead to constant dependency reloading and performance degradation.

Problem:
On Windows, paths often use backslashes (\) as separators, while Vite expects forward slashes (/). This mismatch can cause Vite to incorrectly identify and optimize dependencies.

Example:

  • Incorrect Path: C:\data\projects\remix\app\entry.client.tsx
  • Correct Path: C:/data/projects/remix/app/entry.client.tsx

Solution:
This PR normalizes the paths using importViteEsmSync().normalizePath() to ensure they are compatible with Vite's dependency optimization.

Specific Changes:

  • Normalized Entry Point:
    - ctx.entryClientFilePath
    + importViteEsmSync().normalizePath(ctx.entryClientFilePath)
  • Optimized Route File Paths:
    - path.join(ctx.remixConfig.appDirectory, route.file)
    + resolveRelativeRouteFilePath(route, ctx.remixConfig)

Expected Benefits:

  • Improved Build Performance: Faster build times and smoother development experience.
  • Enhanced Stability: Prevents unexpected dependency reloads and other related issues.

Testing:

Please thoroughly test this change on Windows systems to verify that the issue is resolved and there are no unintended side effects.

Additional Considerations:

  • Other Potential Path Issues: Consider other areas where path normalization might be necessary.
  • Vite and Remix Versions: This fix has been tested with Vite v5.4.11 and Remix v2.14.0.

Please review and merge this PR if the changes are satisfactory.

Copy link

changeset-bot bot commented Nov 21, 2024

⚠️ No Changeset found

Latest commit: f05ee5c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sebastien-comeau sebastien-comeau changed the title fix(dev): optimizeDeps entries file paths in Windows fix(dev): optimizeDeps entries file paths on Windows Nov 21, 2024
@sebastien-comeau sebastien-comeau changed the base branch from main to dev November 21, 2024 23:55
@sebastien-comeau sebastien-comeau deleted the patch-1 branch November 21, 2024 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants