jwhitley / requirejs-rails

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

config not passed to r.js #197

Open Rush opened 9 years ago

Rush commented 9 years ago

I have set up a shim config for my application in config/requirejs.yml, such as:

shim: 
  jquery:
    exports: 'jQuery'
  jquery_ujs:
    deps: ['jquery']
  'bootstrap': ['jquery', 'jquery_ujs']
  'twitter/bootstrap/rails/confirm':
    deps: ['bootstrap', 'jquery_ujs']
  'novnc/rfb':
    deps: ["novnc/util","novnc/webutil", "novnc/base64", "novnc/websock", "novnc/des",
        "novnc/keysymdef", "novnc/keyboard", "novnc/input", "novnc/display", "novnc/jsunzip"]
  'novnc':
    deps: ['novnc/rfb']
    exports: 'RFB'
modules:
  - name: 'application'
wrapShim: true

but I am not seeing those options passed to r.js, file tmp/requirejs/rjs_driver.js contains:

var requirejs = require("/home/rush/.rvm/gems/ruby-2.1.3/gems/requirejs-rails-0.9.5/bin/r.js")
var baseConfig = {
  "baseUrl": "/home/rush/virtkick/webapp/tmp/requirejs/src",
  "dir": "/home/rush/virtkick/webapp/tmp/requirejs/dst"
};

baseConfig.modules = [
  {
  "name": "application"
},
];

What is wrong, is this application bug? How can I make the build_config to be loaded?

carsomyr commented 9 years ago

@RushPL Looks like the failure is with wrapShim, which is fixed with PR #193. Will merge once I get around to it. Let me know if this isn't your problem, and I'll reopen.

Rush commented 9 years ago

Yeah .. wrapShim is one thing, but shouldn't shim deps be passed to r.js as well? Wrap shim is gonna wrap them but it needs the actual dependencies to actually the code in wrapped blocks, if you know what I'm saying.

Rush commented 9 years ago

I think it's both shim and wrapShim that need to be passed to it in order to work.

I checked manually by running: node tmp/requirejs/rjs_driver.js

If I manually make the config mention my dependencies, it works properly:

var requirejs = require("/home/rush/.rvm/gems/ruby-2.1.3/gems/requirejs-rails-0.9.5/bin/r.js")
var baseConfig = {
  "baseUrl": "/home/rush/virtkick/webapp/tmp/requirejs/src",
  "optimize": "none",
  "wrapShim": "true",
  "dir": "/home/rush/virtkick/webapp/tmp/requirejs/dst",
  "shim": {
    "jquery": {
      "exports": "jQuery"
    },
    "jquery_ujs": {
      "deps": [
        "jquery"
      ]
    },
    "bootstrap": [
      "jquery",
      "jquery_ujs"
    ],
    "twitter/bootstrap/rails/confirm": {
      "deps": [
        "bootstrap",
        "jquery_ujs"
      ]
    },
    "novnc/rfb": {
      "deps": [
        "novnc/util",
        "novnc/webutil",
        "novnc/base64",
        "novnc/websock",
        "novnc/des",
        "novnc/keysymdef",
        "novnc/keyboard",
        "novnc/input",
        "novnc/display",
        "novnc/jsunzip"
      ]
    },
    "novnc": {
      "deps": [
        "novnc/rfb"
      ],
      "exports": "RFB"
    }
  }
};

baseConfig.modules = [
  {
  "name": "application"
},
];

requirejs.optimize(baseConfig);

Please reopen the issue.

ianwalter commented 9 years ago

+1 Shim deps don't work.

arfl commented 8 years ago

+1

carsomyr commented 8 years ago

Thanks for the reports guys. I'm going to be looking into this in the upcoming week.