hearsayit / HearsayRequireJSBundle

RequireJS integration for Symfony2.
130 stars 55 forks source link

output module assets as .js #17

Closed arnaud-lb closed 11 years ago

arnaud-lb commented 12 years ago

This changes the output path to use a .js extension. This allows to use the bundle with .coffee scripts.

dunglas commented 11 years ago

:+1:

ihortymoshenko commented 11 years ago

@arnaud-lb, see my answer on the https://github.com/hearsayit/HearsayRequireJSBundle/issues/31 issue.

arnaud-lb commented 11 years ago

@IgorTimoshenko here are some reasons require-cs cannot be used with the bundle:

  1. require-cs compiles the coffeescript files on the client side, which is not desirable:
    1. it's slow (especially with large code size / many modules, i.e. on a single-page app), and makes development very unpleasant
    2. cannot use my js-aware / js-specific assetic filters anymore, since assetic only sees coffee-script code now
    3. the coffee assetic filter is usualy applied implicitly on every .coffee file on projects with a few coffee scripts (with apply_to: \.coffee$ in assetic.filters.coffee), so it breaks require-cs (the bundle outputs compiled coffee-script, i.e. javascript code, with a .coffee extension, which require-cs loads and tries to compile as coffee-script, which wouldn't work)
  2. require-cs uses XMLHttpRequest to get the source of coffee files, which may not work on some setups (e.g. because assets are hosted on static.example.com while pages are at www.example.com)
ihortymoshenko commented 11 years ago

@arnaud-lb, I see. I can commit the proposal changes from this PR. Should it be enough to support CoffeeScript? Thanks!

arnaud-lb commented 11 years ago

@IgorTimoshenko yes, this change is enough to support coffee-script :)

ihortymoshenko commented 11 years ago

@arnaud-lb, note that the proposed changes won't work with the r.js filter for Assetic.