gruntjs / grunt-contrib-requirejs

Optimize RequireJS projects using r.js.
http://gruntjs.com/
MIT License
504 stars 105 forks source link

Support for Map? #54

Closed reggi closed 10 years ago

reggi commented 10 years ago

I was wondering if this was a problem with grunt-contrib-require or just a problem with my code. I'm trying to replicate this answer on stackoverflow, it's also in the requirejs docs.

Here's my code:

require.config({
    paths: {
        "jquery": "../../bower_components/jquery/jquery",
    },
    map: {
      "*": {
        "jquery": "noconflict"
      },
      "noconflict": {
        "jquery": "jquery"
      }
    }
});

define(["jquery"], function($) {
  return $.noConflict(true);
});

define("main", function(){
    var $ = require("jquery");
    console.log($().jquery);
});

require(["main"]);

Here's the error:

Running "requirejs:main" (requirejs) task
>> Tracing dependencies for: main
>> Error: ENOENT, no such file or directory
>> '/Users/user/.../noconflict.js'
>> In module tree:
>>     main
reggi commented 10 years ago

Nevermind! I figured it out! I needed to put:

define(["jquery"], function($) {
  return $.noConflict(true);
});

in another file named noconflict.js.