scalableminds / amd-optimize

An AMD (RequireJS) optimizer that's stream-friendly. Made for gulp.
MIT License
162 stars 29 forks source link

loading order #36

Closed tamtakoe closed 9 years ago

tamtakoe commented 9 years ago
define(['module1', 'module2', 'module3'], function() {
 ... 
});

Now modules and our dependensies load in correct order (as if the files are loaded synchronously):

module1.dep1.js
module1.dep2.js
module1.dep3.js
module1.js
module2.dep1.js
module2.dep2.js
module2.dep3.js
module2.js
module3.dep1.js
module3.dep2.js
module3.dep3.js
module3.js

This is useful in some cases.

You can guarantee the preservation of order in future versions? For example, to add syncLoading flag

normanrz commented 9 years ago

The order of the output modules is very important. There's quite a chunk of code that takes care of ordering these in the asynchronous environment. Also there are a lot of tests that confirm the correct ordering. Because of that I'm quite confident future versions will preserve the ordering. Does that answer your question?

tamtakoe commented 9 years ago

Yes. Thank! It is good, because I can use it for modular application (collect dependencies for certain modules, not for the entire application).

normanrz commented 9 years ago

Perfect :-)

tamtakoe commented 9 years ago

P.S. Found by chance https://github.com/gustavohenke/toposort. It may be useful