jupiterjs/steal — pull request #83 by asavoy (2012-05-15 16:38:32+00:00)
Title: Multi-build fixes and css packaging (updated)

### Updated

* Added multibuild tests to: ``./js steal/build/test/run.js``
* Rebased to the current master@3d14880. This should be a clean merge now.
* Added some fixes
* CSS minification works now
* Updated the pull request description.

### Overview

These are a set of fixes for getting multi-build back to a usable state. The fixes are a little crude and hacky, mainly because it duplicates some of the JS packaging, and so could be refactored a bit.

It's been tested on a site that uses ~120 JS/CSS dependencies, for a few months. We have seen a big difference in page load times using the multibuild, compared to non-production mode and to just compiling into one huge production file. It also allows us to write more modular code without penalty, and not have to think of CSS separately.

### Changes

* fixed 'Cannot read property "js" from undefined' when trying to run multi-build
* added support for CSS packaging
* packages get an embedded CSS package loader
* fixed modules embedded in packages were being executed before their dependencies loaded. also ensure they don't try to load dependencies that are already in pending packages.
* fixed IE8/9 error when trying to load a packaged app
* fixed CSS minification
* recompiled steal.production.js
* added tests

### Testing

Multibuild tests were added, run them with ``./js steal/build/test/run.js``
Note: it is a noisy test, because the multibuild already uses lots of print() instead of steal.dev.print().

Initially I worked with a project built as follows:

./js jquery/generate/app testapp/plugin1
# add & steal testapp/plugin1/plugin1.css
./js jquery/generate/app testapp/plugin2
# add & steal testapp/plugin2/plugin2.css
# steal testapp/plugin1
./js jquery/generate/app testapp/app1
# add & steal testapp/app2.css
# steal testapp/plugin2
./js jquery/generate/app testapp/app2
# add & steal testapp/app2/app2.css
# steal testapp/plugin2

# build:
./js steal/buildjs testapp/app1 testapp/app2

Then I tested with the app I'm working on, which is much larger. I've tested it on the latest of Chrome, Safari, Firefox, IE8, IE9.

### Notes

* It seems you need to wrap all third-party JS files with the right dependencies: `steal('jquery', function() { ... })` or they will potentially *evaluate* out of order.
* The output files could have less noise. It is useful for debugging, but easily removed.

### Links

http://github.com/jupiterjs/steal/issues/48
http://forum.javascriptmvc.com/topic/building-with-shared-dependencies-doesn-t-build-css
http://forum.javascriptmvc.com/topic/multi-build-and-shared-packages
http://forum.javascriptmvc.com/topic/how-to-build-with-shared-dependencies