CommonJS 使用 Node.js 的四个环境变量
module
exports
require
global

只要能够提供这四个变量,浏览器就能加载 CommonJS 模块

Browserify 是目前最常用的 CommonJS 格式转换的工具。

Browserify:http://browserify.org/

 

使用下面的命令,就能将main.js转为浏览器可用的格式。
$ browserify main.js > compiled.js

相关文章:

  • 2022-12-23
  • 2021-12-11
  • 2021-10-23
  • 2021-09-14
  • 2022-12-23
  • 2021-12-29
  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2022-02-13
  • 2022-12-23
  • 2021-08-21
  • 2022-01-01
相关资源
相似解决方案