Skip to content

Add .jj directory to the default ignored list for file watcher #20036

@fiadliel

Description

@fiadliel

Description

I would like for the .jj directory to be included in the default ignored list for the watcher (in the vite config) when running the dev server.

Reasoning:

jj VCS aims to be a mostly git-compatible system that I'm sure many people use with vite (but I'm not sure about exact statistics for its use). It stores its state in a .jj directory under the root of the repository.

The first issue here is that this is a potentially large directory which adds significantly to the watch burden.

Secondly, it 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.

Thirdly, jj eagerly updates its state when possible. This includes the ability to set up its own file watcher, which looks for updates to the currently checked out files (minus files in .gitignore), and snapshots them in the state. This could (with badly configured gitignore) cause a loop of both watchers wanting to update their state. The impact of reloads can also extend to servers which are referenced by the open page during constant reloads.

The developers of code using vite may not even be aware that their users are using jj (to add to the ignored list in config). And it's not obvious to users of jj that their use of jj could be an issue.

So I suggest that this makes it a good candidate for the default ignored list in the configuration. It's actually more vital to keep .jj out of the ignored list than .git, because of the eager state update. The main argument against is a question of how popular jj is (I certainly think it's a viable alternative to git for most use, and a lot of people like it).

Suggested solution

In resolveChokidarOptions, the ignored list could be expanded:

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

There are two other places that are also worth considering:

  • fs.deny for serverConfigDefaults
  • the ignored files under warmup.ts

These are possibly less critical, but not including in fs.deny could expose files accidentally.

Alternative

One could leave it to developers to add to individual projects. This list of projects is almost unbounded, as every project which could be checked out by jj should have this entry added.

Alternatively, the watched files should be a whitelist, not a blacklist. But this is already tracked in other open issues.

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Discussing

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions