Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Require.js + R.js Optimizer Ignoring Shim

R.js is not loading my shim, and thus jQuery is loading before tinyMCE and tiny is being initialized before it has loaded. How can I get the shim to work?:

build-js.js:

var requirejs = require('requirejs');
var config = {
    mainConfigFile: '../js/main.js',
    include: [],
    name: 'main',
    out: '../js/build/build.js',
};

    requirejs.optimize(config, function (buildResponse) {
    var contents = fs.readFileSync(config.out, 'utf8');
});

main.js:

require.config({
    paths: {
        jQuery: 'common/libs/jquery/jquery-min',
        TinyMCE: 'common/libs/tinyMCE/tiny_mce',
    },
    shim: {
        'jQuery': {
            deps:['TinyMCE'],
            exports: '$',
        },
       'jQueryUi': {
            deps: ['jQuery']
        },
        'jQuerySelectmenu': {
            deps: ['jQuery', 'jQueryUi']
        },
        'jQueryAutosize': {
            depts: ['jQuery']
        },
        'Underscore': {
            exports: '_'
        },
        'Backbone': {
            deps: ['Underscore', 'jQuery'],
            exports: 'Backbone'
        }
    }
});

require(['common/src/app'], function (App) {
    App.initialize();
});
like image 334
user784756 Avatar asked Jul 13 '12 15:07

user784756


1 Answers

This issue is already fixed at r.js 2.1.11

just place

wrapShim: true in the build config.

github issue

configuration example

like image 178
Randy Garces Avatar answered Nov 11 '22 13:11

Randy Garces