Folders not initialized when building with Typescript

Hello, I don't know if I missed out something in my tsconfig or node config but I tried making Listeners/Commands with Sapphire but after building with npx tsc and running it with node or bun the only thing that is recognized and initialized is the main index.js file (even tough tsc transpiled every files in the project dir correctly). The bot is logging in correctly and is working normally if I write it in common esm, transpiled esm or ts but when using ts with bun build or tsc with node it doesn't initialize my sub folders classes (the listeners and commands). I followed the official documentation for starting my project without using the cli btw. I have a ./src/index.ts with a ./src/listeners/ready.ts. I tried adding the sapphire ts config but it hasn't had any effects. The pic is what combination worked/didn't worked. Can you help me find my mistake? Thanks.
No description
Solution:
So, I tried and I can say that for now the bun builder (that is in beta) cannot recreate the correct structure of the project because it doesn't see the relationship between the two files (index.ts ready.ts) from its entrypoint (index.ts) as stated in the documentation and thats why I can't see my listeners or commands being initialized. Three options: - the first one is to use tsc to build the structure - and the second one is to not transpile my code and run the ts files directly. - the last one is to build each files separately using the --splitting option....
Jump to solution
8 Replies
Favna
Favna7mo ago
Please see the first big red block at the start of the guide: https://sapphirejs.dev/docs/Guide/getting-started/getting-started-with-sapphire
Sapphire Framework
Getting started with Sapphire | Sapphire
To install Sapphire, you need to install both discord.js and
Cl
ClOP7mo ago
Thanks. I will check later but I’m sure I set it for the bun version. I will keep you in touch.
Favna
Favna7mo ago
If you're running the TS code directly with bun you do have to set it to src/index.ts
Cl
ClOP7mo ago
I set the main to dist/index.js if I remember because I’m building with bun build src/index.js —target bun —outdir ./dist But I didn’t verify if my build integrate the other files. Maybe my command is only transpiling the index and not everything into a single file I get this at the end: / dist / index.js / src / index.ts / src / listeners / ready.ts
Favna
Favna7mo ago
you mean your dist doesnt have the same structure of listeners/ready.js? that's a problem
Cl
ClOP7mo ago
Yes that’s what I mean. Okay so my build phase is incorrect maybe thats why it doesn’t work. I thought bun transpiled the entrypoint and its structure into a single js file I will try it later
Solution
Cl
Cl7mo ago
So, I tried and I can say that for now the bun builder (that is in beta) cannot recreate the correct structure of the project because it doesn't see the relationship between the two files (index.ts ready.ts) from its entrypoint (index.ts) as stated in the documentation and thats why I can't see my listeners or commands being initialized. Three options: - the first one is to use tsc to build the structure - and the second one is to not transpile my code and run the ts files directly. - the last one is to build each files separately using the --splitting option. (or maybe I can try to import the listeners into the index but that shouldn't be done if it is not used directly) I will go for the second or third one.
Cl
ClOP7mo ago
Thanks for your help @Boomeravna
Want results from more Discord servers?
Add your server