#HMR not Working correctly

1 messages · Page 1 of 1 (latest)

high badge
#

I am using the @sapphire/plugin-hmr Plugin to reload my bot on code changes without relogging to discord.
When I change the text in an embed for example and hmr reloads my changes, they are displayed correctly in discord with the new text.
If you change console logs, add container.logger.info(xyz) or edit helper files, the changes there are not reflected correctly with the latest changes.

If I want to see the changes I have to stop the dev process and restart the bot completely.
Is this wanted behavior or am I doing something wrong?

thorny pondBOT
#

@high badge to help others find answers, you can mark your question as solved via Right Click Solution Message->Apps->✅ Mark Solution

dawn badger
high badge
#

I run npm run dev.
npm run dev runs run-p watch start
watch = tsc -w
start = node dist/index.js

fossil wyvern
#

This is expected behavior. @sapphire/plugin-hmr only handles "piece" files (commands, listeners, preconditions, etc)

#

What you might be able to do is change and save a helper file, and then change and save a command file that uses it. This forces the command to reload, which would reimport the helper file with the new changes

#

I'm not sure if that works but it would be worth a try

high badge
#

tried and its not working :(

#

an option to reload on all file changes would be dope tbh

fluid trellis
#

that won't really be added because there is no good way to reload files in a running process anyway

#

in CJS there is require cache, and in ESM you can add query params to imports but both are very so/so

#

You can add it to your own bot or make your own plugin, but we won't be adding it