Open nickcmaynard opened 12 years ago
All require
calls use path-related addressing like "./" which makes them path dependent on installation inside project and hence requires configuration tweaks.
this.JSV = JSV; //set global object
exports.JSV = JSV; //export to CommonJS
There are globals.
There's a circular reference: jsv -> environments -> json-schema-draft-03 -> jsv.
@garycourt will have to do some refactoring to support AMD. Hope he'll find some time for it in near future.
@aoboturovorange circular references are handled/allowed in AMD
This fork of GaryCourt's JSV manually converts all relevant commonJS modules to requireJS modules. Everything should continue to work like normal, except that schema definitions must now be explicitly imported (no default is set).
FYI, the UMD project provides patterns for supporting multiple module definitions.
With Dojo etc. moving to AMD for lazy module loading, it would be great if JSV could support the AMD loader, rather than/as well as the CommonJS require() behaviour currently in place.
For minimal sites, Almond, a really small AMD shim, is only 2.3KB compiled.
There are instructions on converting "traditional" CommonJS loading behaviour to AMD here: http://requirejs.org/docs/commonjs.html
This means that those using the AMD loader method would be able to do the following, thus only loading JSV when required: 1) Register the module path for JSV 2) require(["jsv/json-schema-draft-03"], function(env) { // JSV code goes here });