最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Minimal CommonJS implementation - Stack Overflow

programmeradmin1浏览0评论

I'd like to use some CommonJS pliant modules in some of my scripts. Those scripts are just meant to do things on my laptop: it's not in the browser, it's not really in the server either. I just manipulate a mongodb that I use locally.

So I wonder, what is the best way to do that? I only found outdated wrappers that would provide CommonJS capabilities and the mongo shell.

Should I handcode a require system? Should I handcode a workaround? Is there already a minimal loader existing?

All your ideas regarding the matter will be appreciated, for sure.

Pointers towards implementation of other parts of CommonJS would be appreciated too.

I'd like to use some CommonJS pliant modules in some of my scripts. Those scripts are just meant to do things on my laptop: it's not in the browser, it's not really in the server either. I just manipulate a mongodb that I use locally.

So I wonder, what is the best way to do that? I only found outdated wrappers that would provide CommonJS capabilities and the mongo shell.

Should I handcode a require system? Should I handcode a workaround? Is there already a minimal loader existing?

All your ideas regarding the matter will be appreciated, for sure.

Pointers towards implementation of other parts of CommonJS would be appreciated too.

Share Improve this question edited Sep 12, 2012 at 17:46 m09 asked Sep 1, 2012 at 8:29 m09m09 7,5213 gold badges33 silver badges61 bronze badges 6
  • 1 Is there a reason that node.js wouldn't work here? – Joe Commented Sep 6, 2012 at 16:59
  • Well node.js does work here but I'd rather use the mongo shell and another way to include monJS modules – m09 Commented Sep 6, 2012 at 17:01
  • Ah - your question didn't really mention using mongo shell as a requirement. – Joe Commented Sep 6, 2012 at 17:17
  • well mongo shell is just an extended SpiderMonkey so a good general answer should fit – m09 Commented Sep 6, 2012 at 17:19
  • There is a list on the monjs website. Several of these wrap SpiderMonkey. – Steve Campbell Commented Sep 7, 2012 at 21:09
 |  Show 1 more ment

1 Answer 1

Reset to default 10 +500

@Mog

You should try out http://code.google./p/gpsee/ which is having general-purpose C API for embedding SpiderMonkey & CommonJS.

发布评论

评论列表(0)

  1. 暂无评论