代码之家  ›  专栏  ›  技术社区  ›  mr_js

使用requirejs在项目中包含commonjs模块的最佳方式

  •  0
  • mr_js  · 技术社区  · 8 年前

    requirejs 来管理我项目中的javascript文件。但是,我想使用一些外部库,它们不符合 AMD barba.js 。如何使用 package loading feature 关于requirejs?理想情况下,我希望在不运行转换工具的情况下包含commonjs模块。

    2 回复  |  直到 8 年前
        1
  •  1
  •   John Slegers    8 年前

    Barba不使用CommonJS模块格式。

    UMD (Universal Module Definition) 模块格式。这意味着它与

    define([
      "barba/barba"
    ], function(Barba) {
      Barba.Pjax.start(); // You can use Barba here
    });
    
        2
  •  0
  •   Salketer    8 年前

    来自requireJS文件。

    define(function(require, exports, module) {
        //Put traditional CommonJS module content here
    });
    

    这会让你一切都好起来的。但我真的不确定是否需要。