Created
December 27, 2011 06:10
-
-
Save Siedrix/1522849 to your computer and use it in GitHub Desktop.
RequireJs on Node
This file contains 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
var requirejs = require('requirejs'); | |
requirejs.config({ | |
baseUrl: 'scripts', | |
nodeRequire: require | |
}); | |
requirejs(['bar'], | |
function ( bar ) { | |
console.log('bar: ', bar); | |
}); |
This file contains 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(['dep/foo'], function (fs,foo) { | |
console.log('foo', foo.isFoo ? true : false) | |
return { | |
isDepOfFoo : foo.isFoo ? true : false, | |
isBar : true | |
}; | |
}); |
This file contains 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(function (fs) { | |
return { | |
isFoo : true | |
}; | |
}); |
This file contains 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
<!DOCTYPE> | |
<html> | |
<head> | |
<title>RequireJs</title> | |
<script type="text/javascript" src="scripts/require.js"></script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
requirejs.config({ | |
baseUrl: 'scripts', | |
urlArgs: "bust=" + (new Date()).getTime() | |
}); | |
requirejs(['bar'], | |
function ( bar ) { | |
console.log('bar: ', bar); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bar.js debe de ir en un folder llamado scripts
foo.js debe de ir en un folder llamado dep, dentro de scripts