What is the recommended way of organizing big projects?

Let's say I'm making a javascript 3d game, and I want to be able to work on some new feature without having to worry or think about the rest of the code, for example let's say a new menu.

So the first thing I do is use modules, that way I don't have to worry about variable names conflicting with each other. I can have a Sound module and when I want to make a "click" sound in my menu I just do something like Sound.play("click.ogg") after importing it.

Other thing I found out is "components", so I can have an html and css files for my menu, I can work on it and then add it to the game, it has its own Shadow.dom and they are not going to interfere.

But also components are suppose to not reference each other directly, for example they use custom event listeners, or a "bus" to communicate with each other.

So that last part is what I'm not sure about. For example if I use modules the problem is I end up having to load the whole game because everything is interconnected, so it takes me 20 seconds to refresh the page to test tweeks instead of being instantaneous.

If I do things with event Listeners then I can do something like ev("sound.play","click.ogg") where ev is a function that triggers the custom event listener (just to make code cleaner). If the sound module is loaded then is going to take care of the event and play a sound, but I can also not load it and still work on the menu without sound, that's is what I want, being able to turn on and off dependencies independently.

EventListeners can't return things but that can be fixed so you can have things like: let mySound=ev("sound.play","click.ogg"), so that is okay.

The problem is two things, one is that it eliminates errors, so if something is not working is not going to warn you. The other problem is code suggestions, if you write "Sound." you get a list of suggestions like "Sound.play(name)", but if you write "ev(" you don't get anything.

So next I was thinking about doing something else, like using if statements this way:

if(Sound){
 Sound.play("click.ogg");
} 

That way if I import the module then it will warn me of errors, but if I decide not to import it I will still be able to run the code and make the menu.

But maybe that's crazy. What is the standard way of doing it?

Also a menu component is just an example, I have things like inventory, and weather control, and 3d engine, and mini games, etc. If a mini game gives you items then is interacting with the 3d engine, so it gets cumbersome. So the point is I want to be able to develop one part without having to think about the rest.

Thanks.