Skip to content

Instantly share code, notes, and snippets.

@matthewp
Last active October 20, 2016 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewp/63edaf2177374e4aaeecede68e54c8df to your computer and use it in GitHub Desktop.
Save matthewp/63edaf2177374e4aaeecede68e54c8df to your computer and use it in GitHub Desktop.
Circular refs example
node_modules/
<title>Circular deps with steal()</title>
<script src="node_modules/steal/steal.js"></script>
steal("./one.js", "./two.js", function(one, two){
console.log(one.hello(), two.world());
});
define(["exports","./two"], function(exports, two){
exports.hello = function(){
return two.hello;
};
exports.world = "world";
});
{
"name": "circulars",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gist.github.com/63edaf2177374e4aaeecede68e54c8df.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://gist.github.com/63edaf2177374e4aaeecede68e54c8df"
},
"homepage": "https://gist.github.com/63edaf2177374e4aaeecede68e54c8df",
"dependencies": {
"steal": "^0.16.41"
}
}

Example

This shows circular refs working.

define(["exports", "./one"], function(exports, one){
exports.hello = "hello";
exports.world = function(){
return one.world;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment