Could you take the module loader shim from the current (version 4) code in another mode, and use it here as well? All modules in the distribution are now wrapped in commonjs and amd-compatible wrappers.