bodule icon indicating copy to clipboard operation
bodule copied to clipboard

Bodule概述

Open island205 opened this issue 12 years ago • 5 comments

Bodule,又一个Node模块Browser化的工具!

目标

给Node的模块文件加上Brower Loader的Wrapper,编译后的代码输出到指定目录。

示例

目录中有main.jsspinning.jspackage.json,其中main.js内容如下:

    // 通过 require 引入依赖
    var $ = require('jquery');
    var Spinning = require('./spinning');

    // 通过 exports 对外提供接口
    exports.doSomething = ...

    // 或者通过 module.exports 提供整个接口
    module.exports = ...

使用Bodule,运行 bodule main.js --loader=seajs,会被打包为:

// 所有模块都通过 define 来定义
define(function(require, exports, module) {

  // 通过 require 引入依赖
  var $ = require('[email protected]');
  var Spinning = require('./spinning');

  // 通过 exports 对外提供接口
  exports.doSomething = ...

  // 或者通过 module.exports 提供整个接口
  module.exports = ...

});

其中,@1.5.1是运行npm install之后所采用的jquery版本。

API

island205 avatar Apr 26 '13 10:04 island205

https://github.com/Bodule/Bodule/wiki/%E4%BB%8B%E7%BB%8D

island205 avatar Apr 29 '13 04:04 island205

Similar: https://github.com/mixu/gluejs https://github.com/sstephenson/stitch https://github.com/medikoo/modules-webmake More: http://blog.brianbeck.com/post/10667967423/node-js-require-in-the-browser

tiye avatar Apr 30 '13 05:04 tiye

和这些还不太一样,bodule不把文件打包成一个,只是把CommJS的包port出来,兼容流行的loader,会提供服务,我已经注册了bodule.org

island205 avatar Apr 30 '13 05:04 island205

@island205 不是很理解你的意图.. 不过你真做的好快, 总之等最终社区的选择了.

tiye avatar Apr 30 '13 05:04 tiye

@jiyinyiyong 等我多写些代码和文档,估计就清晰起来了。

island205 avatar Apr 30 '13 06:04 island205