0

I have a relatively unique requirejs structure for a game I'm getting started on. The current code is just my start, but I was trying to figure out how to build it as a single javascript file, probably with optimizations as well.

The problem I'm running into is that I've set up the engine module to have submodules for each part of the engine. The idea behind this is that it's easy to drop in different engine modules, and have their own configurations if needed. Currently I'm not taking advantage of this feature, but I may in the future, so would like to not have to work around it if possible.

Here's an idea of the tree:

game - root directory for game code
- main.js - primary application definition
- engine - engine module
- - main.js - engine module definition
- - audio - audio module
- - ...
- - scene - scene module

I have all of the submodules that make up engine as relative paths, so the engine can get moved around without having to update where it should look for it's submodules. The problem with this is that when building with node, it doesn't seem to read the require.config() settings in the engine module, causing it to look for it's submodules in places that don't exist.

I'm sure my structure is wrong, but any ideas on how I can preserve my way of separating my engine modules while being able to build my entire game structure into a single file would be greatly appreciated.

You can see the specifics in the GitHub repo: https://github.com/RedShiftDev/project-helium

superlinkx
  • 113
  • 4
  • "it doesn't seem to read the require.config() settings in the engine module", show us please its code and the error you get. – PA. Sep 12 '13 at 07:24
  • The specific code would be in /game/build.is in the repo. The engine module is in /game/engine/main.js. I'll run the build command again and post back the specific error, but it's basically trying to resolve /game/audio.js instead of the module definition of /game/engine/audio in /game/engine/main.js – superlinkx Sep 12 '13 at 11:49
  • This is the specific error message on build. Hopefully I gave you the list of files you should look at to get an idea of how the different require modules are set up in my previous comment: [Error: Error: ENOENT, no such file or directory '/storage/repos/personal/project-helium/game/audio.js' In module tree: main lithium at Object.fs.openSync (fs.js:427:18) ] – superlinkx Sep 13 '13 at 07:20

0 Answers0