#--hot reload doesn't --hot reload

1 messages · Page 1 of 1 (latest)

tepid cobalt
#

Hello, I'm playing around with Bun.fileSystemRouter and fell into an issue : when I update files into my "app" dir, bun don't reload the server and I need to restart manually to see changes effects.
structure of project, package.json and index in screenshot.
Is there a way to add folder to the scope of HMR ?

amber bloom
#

bun will not watch and hot reload files which are not imported, so if you have got html files lying around and change them they will not trigger hot reloads. But for example typescript files which are imported in your entry point file will trigger a hot reload.

thorny epoch
#

If want html to reload when you change html and stuff use an extension

tepid cobalt
#

Yep, used nodemon :
nodemon -e .pug --exec 'bun run dev'

keen prairie
#

you can import the files as text

#

and then it will work with the hot reloading

#
bun --hot --loader=.pug:text ./script.ts
tepid cobalt
#

Thanks, the flag made it work but like @amber bloom said, I had to manage something to require * .pug files into my entry point, I don't think that's ideal :/

(async () => {
    const files = await readdir("./app", { recursive: true });
    files.filter((file) => file.endsWith(".pug")).forEach((file) => require("./app/" +         file));
})();```
keen prairie
#

yeah its not ideal

you could use Bun.Glob to scan for all the .pug files at least