Search code examples
javascriptrequirejscreatejs

Loading CreateJS with RequrieJS. "shim" option dosen't work


In my requireJS config i have

require.config({
    baseUrl: "js",
    paths: {
        react: "libs/react/" + (DEBUG ? "react" : "react.min"),
        domready: "libs/require/plugins/domready.min",
        superagent: "libs/superagent/superagent.min",
        createjs: "libs/createjs/createjs.min" //Combined createJS lib

    },
    shim: {
        createjs: { exports: "createjs" }
    },
    waitSeconds: 0
});

Then I want to require createJS as dependency of my module

define(
    [
        "react",
        "createjs",
        "config",
        "common"
    ],
    function(React, CreateJS, Config, Common) {
        console.log(CreateJS); //Didn't work. Returning empty require module object
        console.log(createjs); //Proper CreateJS object
    }
);

CreateJS is not actual representation of global variable createjs. shim option does nothing. Result without shim the same


Solution

  • Fiddling around, I found that in combined version of createjs, there is definition of JSON3 module. This module you've got as dependency, not full createjs. To use requirejs and createjs, see this example You will need to require easel, tween and other modules separately.