Skip to content

Instantly share code, notes, and snippets.

@ialexi
Created September 21, 2010 16:04
Show Gist options
  • Save ialexi/589937 to your computer and use it in GitHub Desktop.
Save ialexi/589937 to your computer and use it in GitHub Desktop.

Build Tools Directory Structure Issues

When modular (not necessarily CommonJS) loading exists, directory structure becomes more complicated.

Unless every module is explicitly required, we will have somewhat inconsistent load order.

We can determine when to load files by using getters; if getters are not available, we must load all files at startup. But if we load all files at startup, then load order is important, so we must watch for sc_require.

Further, we may have code that will need to run outside of modules; otherwise, it will be hard, for instance, to know when foundation should extend some of the components originally made in SC runtime.

Yet, we also may have some bootstrap code that is needed before any of the modules can be loaded. This wouldn't be a problem if we could always use getters, as the modules would never actually be loaded before the code, but if the code needed the modules, it could load explicitly.

My design that only accounts for the code-after case is to put all modules in lib/, and all non-modules in include/. We'd still need sc_require within both folders.

We cannot easily just fall back to using explicit requires inside include/ because the code within lib/ does not, itself, use explicit requires.

There are two solutions I can think of at the moment:

  • use explicit requires everywhere (which would suck)
  • have separate folders for before and after

Other ideas would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment