compile into single file

Bundling the bot into a single file fails because sapphire loads commands/listeners files when run, not via import. Is there a simple setting in the bot to statically import all the commands?
26 Replies
24
242y ago
What is the reason to deploy a single file?
chmod
chmod2y ago
works easier with the hosting provider. can't change this circumstance, need static imports, but don't see any docs on that
24
242y ago
I don't think you can override that
chmod
chmod2y ago
you're saying this would require editing the sapphire framework?
24
242y ago
More like not supported? It revolves around pieces which are loaded at runtime
chmod
chmod2y ago
how necessary are those pieces to be loaded at runtime though
24
242y ago
considering that's how every single part of sapphire works really rough
Ben
Ben2y ago
Everything in sapphire is a piece
24
242y ago
yeah basically it's built around pieces as modules you just add more moduels to load more commands or your own modules you don't bundle really
Ben
Ben2y ago
It would seem your best option is to use a hosting provider that allows you to have more than one file
24
242y ago
in fact I'd say bundling is probably an anti pattern here
chmod
chmod2y ago
huh well ty for preventing me from wasting hours to mold sapphire to do that
24
242y ago
yeah wouldn't want that
chmod
chmod2y ago
still gotta somehow get it bundled unfortunately. ill find another way ig
24
242y ago
maybe you're going down the wrong path take a closer look at your hosting solution maybe you're not limited
Ben
Ben2y ago
Yeah I’d either switch hosting providers or switch frameworks but honestly a provider with limits like that is probably just going to cause you more headaches down the line
chmod
chmod2y ago
1 bundled file remains ideal headaches? works fine with 2 other bots hosted, but they're not on sapphire kinda curious tho why pieces are a must sure it removes some boilerplate of specifying where commands are by automatically detecting them but its not like you cant make bots without loading extra scripts at runtime
Ben
Ben2y ago
I’m just thinking that if they have a massive limit of only one file, what other massive limits need to be worked around. Personally I’d prefer to know I won’t run into stuff like that. The whole internal structure of the framework is also piece based
chmod
chmod2y ago
why tho
Ben
Ben2y ago
It’s now pretty much everything works in sapphire
chmod
chmod2y ago
but why not just import {mod} from "bar";
24
242y ago
because we load them on demand also means it's dynamic and extendable e.g. you're not tied to any specific path structure you can unload and load modules at any time, reload them, etc
Ben
Ben2y ago
Because that’s not really doable when you don’t know what mod is called or where bar is. Basing things odd the file structure allows you to know what stuff is called and still load it on demand.
chmod
chmod2y ago
hmm, hows this different from something like vites hmr? so this basically
24
242y ago
considering vite is a build tool and pieces is a generic module loader for importing classes at runtime there is little similarities hmr really is just a file watch system that can tell the bundler to re-import that value pieces can do that but you don't watch the system you call it manually it's a low level construct it's not something as a bot developer you'd use
chmod
chmod2y ago
i see
Want results from more Discord servers?
Add your server