inspirehep/inspire-next — pull request #93 by jmartinm (2014-09-12 13:49:55+00:00)
Title: Wip build changes

This PR should allow to run deposit pages both with ```ASSETS_DEBUG=False``` and ```ASSETS_DEBUG=True```.

When running with ```ASSETS_DEBUG=False``` the steps to get the assets ready are:

1. ```$ inveniomanage assets build``` will write all assets in static/gen. If you already have them, they can be cleaned with ```$ inveniomanage assets clean```
2. Make sure ```ASSETS_DEBUG=False``` and ```REQUIREJS_RUN_IN_DEBUG = True``` in order to load the compiled assets.

A problem the PR tries to solve is that with the current Invenio webassets configuration, for each bundle configuration like:

```python
js = Bundle(
"vendors/plupload/js/moxie.js",
"vendors/plupload/js/plupload.dev.js",
"js/deposit/init.js",
output="deposit.js",
filters="requirejs",
weight=51,
bower={
"plupload": "latest",
"ckeditor": "latest",
"flight": "latest"
}
)
```

for **each** line like ``"vendors/plupload/js/moxie.js"`` and ``"js/deposit/init.js"`` r.js runs independently getting all required modules and at then end concatenates all the output into the file ``deposit.js``.

That means that if we add even more lines on INSPIRE like ``inspire_init.js`` we end with a file where, for example, jQuery is duplicated.

That problem also happens if the same page includes several different Bundles. Each of them gets generated independently and we can end up with jQuery code 3-4 times in the page. That can cause problems with non-AMD jQuery plugins as they can get attached to different instances of jQuery $ and cause errors.

So, until a better fix is proposed, adding to the same page different Bundles from separate modules can cause problems.

In this case, for deposit module, only deposit.js is added, which then gets all dependencies through ```require()``` calls.