Created
March 11, 2010 23:15
-
-
Save tim-smart/329813 to your computer and use it in GitHub Desktop.
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
| [06:03] Tim_Smart: isaacs: You think I should have registerExtension enabled to return not just javascript strings? | |
| [06:03] isaacs: Tim_Smart: i think i suggested that registerExtension should return a javascript function representing the module | |
| [06:04] Tim_Smart: isaacs: Meaning, you can return a function or something? | |
| [06:04] Tim_Smart: isaacs: Well, I don't want to re-implement the module system | |
| [06:04] isaacs: Tim_Smart: i see, so you don't want to return a javascript function, and instead want the existing module system to wrap the js string in the process.compile cruft? | |
| [06:05] isaacs: i guess that makes sense. | |
| [06:05] Tim_Smart: atm, it only accepts a string as a return, and puts it through the same paces as the other JS modules | |
| [06:05] isaacs: right | |
| [06:05] Tim_Smart: But, it would be awesome if you didn't return a string, it directly attaches it to the exports | |
| [06:05] isaacs: i guess i'm just thinking of a case where maybe you want to actually compile the thing to a function, because it's not using process.compile, but some other thing that creates a v8 function | |
| [06:05] isaacs: maybe that's yak shaving | |
| [06:06] isaacs: but it seems like it'd be pretty easy to say, if it's a string, then compile its brains out, otherwise, just take it as is | |
| [06:06] Tim_Smart: yeah, like what I said above. Then you could register .mu files with a template compiler, then return the compile function or something | |
| [06:06] isaacs: bingo | |
| [06:06] Tim_Smart: or an object with properties, that get attached to exports | |
| [06:06] Tim_Smart: Yeah I'll add that to the branch soon | |
| [06:06] isaacs: hm..... that seems odd | |
| [06:07] isaacs: so the registerExtension just returns the exports object for that module? | |
| [06:07] isaacs: like, directly? | |
| [06:07] isaacs: i suppose there's no reason why that wouldn't work... | |
| [06:07] Tim_Smart: so, it sends the file contents to the compiler function, then that function either returns a string or some other variable | |
| [06:07] rektide: ok ok ok.... its only taken me two days to catch up on api changes | |
| [06:07] rektide: dear heaven | |
| [06:08] rektide: ((yes i was quite a bit behind)) | |
| [06:08] Tim_Smart: if it isn't a string, then it attaches it directly to exports | |
| [06:08] isaacs: Tim_Smart: right, but it sounds lik eyou'er saying, it can return a string, and then it gets process.compiled as usuall.. | |
| [06:08] Tim_Smart: otherwise, put it though the normal javascript stuff | |
| [06:08] isaacs: right, that object | |
| [06:08] isaacs: what actually happens to it? | |
| [06:09] isaacs: is it like, a collection of things that get put on the exports object? | |
| [06:09] Tim_Smart: It gets wrapped in a function atm, and gets passed require, exports etc etc | |
| [06:09] Tim_Smart: then process.compiled | |
| [06:09] Tim_Smart: that is for a normal js module | |
| [06:09] isaacs: right | |
| [06:09] isaacs: got that | |
| [06:09] isaacs: i'm talking about having my registerExtension compiler function return an object and not a string. | |
| [06:10] isaacs: what would you suggest about that? (i know it's not supported atm) | |
| [06:10] Tim_Smart: yeah same, maybe I'll gist an example? :p | |
| [06:10] isaacs: yes please :) | |
| [06:15] Tim_Smart: isaacs: http://gist.github.com/328894 | |
| [06:15] cedricv has joined the channel | |
| [06:15] isaacs: got it. | |
| [06:15] isaacs: yeah, that's what i was saying | |
| [06:16] Tim_Smart: good, we are on the same level :D | |
| [06:16] isaacs: so, if the compiler returns an object, then that object is the exports object returned to the require() caller | |
| [06:16] Tim_Smart: yeah | |
| [06:16] isaacs: great. | |
| [06:16] isaacs: add one more use-case | |
| [06:16] isaacs: ACTION gisting | |
| [06:17] Tim_Smart: isaacs: also http://gist.github.com/328894 | |
| [06:17] brainss has joined the channel | |
| [06:17] creationix_ has joined the channel | |
| [06:19] isaacs: Tim_Smart: http://gist.github.com/328895 | |
| [06:20] isaacs: i'm suggesting you special-case functions, so returning them actually means that they'll be called with the module system args | |
| [06:20] isaacs: when require()ed | |
| [06:20] isaacs: but, i guess if the extension registration can return an object, it could just run that function right now anyway | |
| [06:21] isaacs: but the problem would be that it won't have access to module or __filename or __dirname and suck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment