Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support AMD for lazy loading #50

Open
nickcmaynard opened this issue Jul 16, 2012 · 4 comments
Open

Support AMD for lazy loading #50

nickcmaynard opened this issue Jul 16, 2012 · 4 comments

Comments

@nickcmaynard
Copy link

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 });
@aoboturovorange
Copy link

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.

@neonstalwart
Copy link

@aoboturovorange circular references are handled/allowed in AMD

@rsolomon
Copy link

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).

https://github.com/rsolomon/JSV

@jeffrose
Copy link

jeffrose commented Dec 2, 2013

FYI, the UMD project provides patterns for supporting multiple module definitions.

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

No branches or pull requests

5 participants