Created
November 8, 2011 23:54
-
-
Save samcday/1349759 to your computer and use it in GitHub Desktop.
r.js does not set define.amd during optimization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define([ | |
| "myplugin!foo" | |
| ], function(result) { | |
| console.log("plugin result:", result); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define(["plugindep"], function(dep) { | |
| return { | |
| load: function(name, parentRequire, load, config) { | |
| if(!dep) { | |
| console.log("It's broken :("); | |
| process.exit(-1); | |
| } | |
| else { | |
| load("It works."); | |
| } | |
| } | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log("Has define():", !!define); | |
| console.log("Has define.amd:", !!define.amd); | |
| if(typeof define === "function" && define.amd) { | |
| define(function() { | |
| return { | |
| importantinfo: "Yep." | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment