Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paper.js shim config Require.js

I'm trying to initialize an application but seem to be having trouble getting paper js to properly load into my script. I'm using require.js as my AMD loader and am trying to load paper js with the shim module.

Here's my code:

requirejs.config({
    urlArgs: "bust=" + (new Date()).getTime(),//used to keep the browser from caching the scripts as we move
    baseUrl : "scripts",//base scripts page!
    paths : {   
        'jquery' : "../components/jquery/jquery.min", //specific libraries -- can be specified later
        'underscore' : "../components/underscore/underscore",
        'paper' : "../components/paper/paper"
    },
    shim: {
        'underscore': {
            exports: '_'
        },
        'paper' : {
            exports: 'Paper'
        },
    },
});

// initialize the document with a doc ready!

requirejs(["jquery", "underscore", "paper"], function ($, _, Paper) {
    alert(_);
    alert(Paper);
});

The first alert works fine, (the underscore) meaning that it loads okay, but I can't seem to figure out how to get paper.js working properly.

Any help would be greatly appreciated.

like image 595
JonMorehouse Avatar asked Nov 03 '22 07:11

JonMorehouse


1 Answers

The PaperJS global namespace is "paper".

Simply replace "Paper" by "paper" and it should work.

'paper' : {
    exports: 'paper'
}
like image 197
Hugeen Avatar answered Nov 12 '22 17:11

Hugeen