-
-
Save isaacs/328895 to your computer and use it in GitHub Desktop.
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
// This returns a Javascript string | |
require.registerExtension('.coffee', function(async, source, callback) { | |
return compileCoffee(source); | |
}); | |
// True | |
require('coffee').test === 123; | |
// This returns a object | |
require.registerExtension('.mu', function(async, source, callback) { | |
return { | |
html: compileTemplate(source), | |
test: 321 | |
}; | |
}); | |
// True | |
require('template').test === 321; | |
// this one returns the module function | |
require.registerExtension(".foo", function (async, source, callback) { | |
return function (exports, require, module, __filename, __dirname) { | |
exports.hello = "world" | |
} | |
}); | |
require("foofile").hello === "world" |
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
exports.test: 123 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment