hearsayit/HearsayRequireJSBundle — pull request #65 by guilhermeblanco (2014-03-07 02:04:24+00:00)
Title: Implement a flag that controls if defines will be declared as their module names

While configuring our application here, we came to a situation where r.js compiles the file and creates at the end something like: `define('.{32}', ['dep1'], function (dep) { ... });`
The problem we faced is because we automated page file loading, but there is no way to determine which md5() it creates. We found a way to get it working by hacking and adding the `$moduleName` as the define name instead of that md5.
As a result of this, multiple attempts showed us it is reliable to make this change and we spent some time to create a patch that is BC.

We can discuss this over, but I would like to illustrate our approach for JS loading here: https://gist.github.com/guilhermeblanco/7d00c8cf1413f79ca84e

The difference is that by leaving the file inside of Bundle and by using the module name, we end up creating a file inside of `/js/` with the following path: `/js/AcmeDemo/Page/Authentication/Login.js`, which creates the define after compiling with r.js: `define('AcmeDemo/Page/Authentication/Login', ...);`, which provides a perfect integration with Symfony routing information: `{{ app.request.attributes.get('_route')|replace({'Bundle': '', '_': '/'}) }}`.
At the end, all we had to define was a `baseUrl` pointing to `/js` and everything worked perfectly in the overall strategy we planned.

So, at the end, we wanted to provide you back the approach we took with required changes and also provide an idea for other developers on how they could get this bundle on a rather unique way and an architecture that is ready to go.