jwhitley / requirejs-rails

RequireJS support for your Rails 3 or 4 application
MIT License
592 stars 202 forks source link

Engine assets not picked up by default for r.js optimization? #220

Closed drakes closed 9 years ago

drakes commented 9 years ago

I ran into trouble trying to precompile assets for an app with a custom engine (I'm guessing unrelated to #200, no crash). Initially my requirejs.yml looked like:

paths:
  mithril: 'mithril/mithril'
  amplify: 'amplify/lib/amplify.core'
shim:
  amplify:
    exports: 'amplify'

The scripts for the engine were not being optimized by r.js; I managed to fix that by adding a modules section which explicitly referred to the top-level module of the engine:

modules:
  - name: 'application'
  - name: 'vbc/application'
paths:
  mithril: 'mithril/mithril'
  amplify: 'amplify/lib/amplify.core'
shim:
  amplify:
    exports: 'amplify'

It's unclear to me whether this is expected behavior (maybe could be mentioned in the docs), or if there's something else I should be doing to point requirejs-rails to my engine (everything worked fine in development).

carsomyr commented 9 years ago

@drakes Might be a problem with the extension .core.

drakes commented 9 years ago

Heh, ignore amplify/lib/amplify.core, full filename amplify.core.js; amplify.core is compiled and loaded fine with the rest of the scripts.

In my case the main application scripts do not depend on the engine asset scripts, so it makes sense that they'd be ignored without declaring another top-level module. Not sure why I was expecting some additional magic to include them, sorry this was my misunderstanding.