Bun hot module reloading & starting in production with Sapphire
Hey, was curious what special work would need to be done to get HMR working with Bun
Was looking at https://github.com/sapphiredev/bun-example/blob/main/package.json and that example doesn't include HMR
My understanding of the plugin https://www.npmjs.com/package/@sapphire/plugin-hmr is that it was watching for changes in the outputed files, and since bun just runs the code directly I assume it's incompatible, but figured I'd check
Along with that, for starting the bot in production w/ bun is it as simple as setting the NODE_ENV var to "production"?
Let me know if I'm able to provide any more info or help out with things, source code is https://github.com/AnswerOverflow/AnswerOverflow/tree/v2/apps/discord-bot
GitHub
bun-example/package.json at main · sapphiredev/bun-example
An example of how to setup a Sapphire project with bun - sapphiredev/bun-example
npm
@sapphire/plugin-hmr
Plugin for @sapphire/framework for hot module reloading for pieces. Latest version: 3.0.1, last published: 8 months ago. Start using @sapphire/plugin-hmr in your project by running
npm i @sapphire/plugin-hmr
. There are no other projects in the npm registry using @sapphire/plugin-hmr.GitHub
AnswerOverflow/apps/discord-bot at v2 · AnswerOverflow/AnswerOverflow
Indexing Discord Help Channel Questions into Google - AnswerOverflow/AnswerOverflow
Solution:Jump to solution
You can use the plugin regardless. It scans the files as they are in the store and with Bun that's TS files.
That said, if it doesn't work that might be up to Chokidar, or Bun's compatibility with it.
And yes you can still use NODE_ENV with Bun. But if you're so inclined you can also use BUN_ENV. It's arbitrary....
4 Replies
thanks buddy
Solution
You can use the plugin regardless. It scans the files as they are in the store and with Bun that's TS files.
That said, if it doesn't work that might be up to Chokidar, or Bun's compatibility with it.
And yes you can still use NODE_ENV with Bun. But if you're so inclined you can also use BUN_ENV. It's arbitrary.
poggers thanks, will play around with it
good bot