There's so many things wrong with the world of script loading today. I want an easy way to:
- install locally scripts and their dependencies
- load these scripts from my application
I want it to:
- work readily with almost all existing projects, source that does not use the script loader
- handle versioning
- have as few configs as possible
- work ok with a JMVC style directory structure
- avoid loading duplicate versions at all costs (a big difference with npm)
Consider a grid widget that depends on jQuery UI, CanJS, and jquerypp
define('project/supergrid(1.0)',['jqueryui(>= 1.8)/positionable',
'jquerypp(>= 1.0)/event/resize',
'underscore(1.3.3)',
'can(>= 1.0)/control'], function(pos,resize, _, control){
})
{
jquery : "http://code.jquery.com/jquery-{}.js",
can : "https://github.com/jupiterjs/canjs/zipball/v{}",
underscore: "https://github.com/documentcloud/underscore/zipball/{1.3.3}"
}
With just project/supergrid.js defined as above run:
X install project/supergrid.js
problem whole zipped project must be downloaded to figure out dependencies. Not sure which version however.
Questions:
-
Is it possible to register a CDN that would work with this so things don't have to be local
-
What would the registry look like?
jquery : "http://code.jquery.com/jquery-{}.js"
-
How would it know the version it has w/o a config?
It would just go to 'jquery' and use that. You would get a warning if version doesn't work.
How do you manage needing 2 versions? - config!
-
How would can declare it's version?
define("can(1.0") // in can/main.js or can/can.js
I really like:
control\
control.js
control_test.js
control.html (demo page)
This is how I encourage everyone to develop, with self-contained modules for testing, experimentation, etc. This is just steal('control'). With no .js, steal just copies the last part and adds it again. I know I'm alone on this and it's now how most people organize their projects, but most people are wrong.