v0lkan/o2.js — Issue #52: automatically resolve dependencies from the source code and enable users to load only the required modules for their needs
Author: v0lkan
Created: 2012-01-30 06:56:33+00:00
State: open

{
timer : {
'core'
'stringhelper.core'
'unit'
},

unit : {
'core',
'ajax'
},

lorem : {
'core'
'ipsum'
}
}

1. load everything selected and its sub items into an array

(assuming we only seleted timer node)
timer
core
stringhelper.core
unit
ajax

2. sort the array

Here is a very naive sorting approach (similar to bubble sort), but since we do not have thousands of items, it will be sufficient.

if the current item has a dependency, move the dependency before the item

core	core	core
timer	stringhelper.core	stringhelper.core
stringhelper.core	timer	timer
unit	unit	ajax
ajax	ajax	unit

3. when the final order is achieved concat all the files into a temp file,
minimize and save it under a common name (like o2.timer.min.js)

4. stream the saved file.