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

Include/exclude config for bun run --watch #5278

Open
timnghg opened this issue Sep 13, 2023 · 4 comments
Open

Include/exclude config for bun run --watch #5278

timnghg opened this issue Sep 13, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@timnghg
Copy link

timnghg commented Sep 13, 2023

What is the problem this feature would solve?

I would like to propose improvements to the bun run --watch command in order to make it more versatile and applicable to a wider range of use cases.

E.g. prevent hard/soft restart when tsx files changed.

What is the feature you are proposing to solve the problem?

Include/exclude glob config for watch mode

1. bunfig.toml

[watch]
excludes = ["**/*.tsx"]
includes = ["**/*.ts"]

2. CLI

bun run --watch --watch-includes=**/*.ts --watch-excludes=**/*.tsx

What alternatives have you considered?

@timnghg timnghg added the enhancement New feature or request label Sep 13, 2023
@oliverjam
Copy link

Yeah Bun's hot-reloading would be amazing if we could reload on HTML/CSS/markdown etc changes, rather than just JS in the module graph. I've got a websocket-based browser reload mechanism working, but it doesn't trigger when the files that matter change 😅

Deno's --watch flag supports passing a list of paths to watch (although this doesn't appear to be in the docs it is in --help).

--watch[=<FILES>...]
  Watch for file changes and restart process automatically.
  Local files from entry point module graph are watched by default.
  Additional paths might be watched by passing them as arguments to this flag.

@jens-ox
Copy link

jens-ox commented Nov 17, 2023

I'm using Fastify and Vite for a new project. bun --watch index.ts (or bun --hot index.ts) doesn't work currently, as Vite will re-generate files during the execution of index.ts, causing bun to reload in a loop.

Having the possibility to exclude files from being watched would solve this imo.

@trya2l
Copy link

trya2l commented Oct 11, 2024

Hi, are there any interest about this issue ? Basically I'm at the same as @jens-ox, this would allow full hot reload capability with SSR

@oliverjam
Copy link

As of v1.1.27 Bun will hot-reload on arbitrary file changes if you import them

https://bun.sh/blog/bun-v1.1.27#watch-arbitrary-file-types-in-watch-and-hot

It would still be nice to be able to exclude files from the watcher though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants