Add `.jj` Directory To The Default Ignored List For File Watcher

by ADMIN 65 views

Description

When running the dev server with Vite, the .jj directory is not included in the default ignored list for the file watcher. This can cause issues with the performance of the watcher and potentially lead to a loop of both watchers wanting to update their state. In this article, we will discuss the reasoning behind adding the .jj directory to the default ignored list and provide a suggested solution.

Reasoning

jj VCS is a version control system that aims to be mostly git-compatible. It stores its state in a .jj directory under the root of the repository. This can cause several issues:

  • The .jj directory is potentially large, which adds significantly to the watch burden.
  • jj supports a "co-located store" option, where it stores a copy of the checked out git repository in .jj/repo/store/git, which does not match the default .git ignore pattern.
  • jj eagerly updates its state when possible, which can cause a loop of both watchers wanting to update their state.

Suggested Solution

To address these issues, we suggest adding the .jj directory to the default ignored list in the Vite configuration. This can be done by expanding the ignored list in resolveChokidarOptions:

  const ignored: WatchOptions['ignored'] = [
    '**/.git/**',
    '**/.jj/**',
    '**/node_modules/**',
    '**/test-results/**', // Playwright
    escapePath(cacheDir) + '/**',
    ...arraify(ignoredList || []),
  ]

This will ensure that the .jj directory is ignored by default, preventing potential issues with the performance of the watcher and the loop of both watchers wanting to update their state.

Alternative

One alternative to adding the .jj directory to the default ignored list is to leave it to developers to add it to individual projects. However, this can be impractical, as every project that could be checked out by jj should have this entry added. Another alternative is to use a whitelist of watched files instead of a blacklist, but this is already tracked in other open issues.

Additional Context

There is no additional context to consider in this case.

Validations

To ensure that this feature request is valid, we have:

Conclusion

Q: What is the purpose of adding the .jj directory to the default ignored list for the file watcher?

A: The purpose of adding the .jj directory to the default ignored list for the file watcher is to prevent potential issues with the performance of the watcher and the loop of both watchers wanting to update their state. The .jj directory is potentially large and can cause the watch burden to increase, while the "co-located store" option in jj can cause the watcher to update its state unnecessarily.

Q: Why is the .jj directory not ignored by default?

A: The .jj directory is not ignored by default because it is not a well-known issue and the developers of Vite may not be aware of the potential problems it can cause. However, with the increasing popularity of jj, it is essential to address this issue to prevent potential problems.

Q: How can I add the .jj directory to the default ignored list for the file watcher?

A: To add the .jj directory to the default ignored list for the file watcher, you can expand the ignored list in resolveChokidarOptions:

  const ignored: WatchOptions['ignored'] = [
    '**/.git/**',
    '**/.jj/**',
    '**/node_modules/**',
    '**/test-results/**', // Playwright
    escapePath(cacheDir) + '/**',
    ...arraify(ignoredList || []),
  ]

Q: What are the potential consequences of not adding the .jj directory to the default ignored list for the file watcher?

A: The potential consequences of not adding the .jj directory to the default ignored list for the file watcher include:

  • Increased watch burden due to the large size of the .jj directory
  • Loop of both watchers wanting to update their state, causing performance issues
  • Potential data loss or corruption due to the eager state update in jj

Q: Can I use a whitelist of watched files instead of a blacklist?

A: Yes, you can use a whitelist of watched files instead of a blacklist. However, this is already tracked in other open issues, and it may require significant changes to the Vite configuration.

Q: How can I ensure that the .jj directory is ignored in other places?

A: To ensure that the .jj directory is ignored in other places, you can add it to the fs.deny list in serverConfigDefaults and the ignored files under warmup.ts.

Q: What are the benefits of adding the .jj directory to the default ignored list for the file watcher?

A: The benefits of adding the .jj directory to the default ignored list for the file watcher include:

  • Improved performance of the watcher
  • Prevention of potential data loss or corruption
  • Simplified configuration and maintenance of the Vite project

Q: How can I contribute to the development of Vite and ensure that the .jj directory is ignored by default? --------------------------------------------------------------------------------A: To contribute to the development of Vite and ensure that the .jj directory is ignored by default, you can:

  • Follow the Contributing Guidelines
  • Read the docs
  • Create an issue or pull request to address the problem
  • Participate in the Vite community and provide feedback on the issue.