4

app/js/d3.js在一个使用 requirejs 的早午餐项目中有一个文件。当我构建文件时,其中的代码按预期app/js/d3.js连接。app.js但它包含在一些看起来像需要的代码中,如下所示:

require.register("js/d3", function(exports, require, module) { #this wrapper is added
window.onload = function() { #then there is the start of code from app/js/d3.js

我足够新,以至于我无法判断这是否应该发生,或者这是否是早午餐的意外行为。当我在需要 api中搜索register 时,我没有看到 register 方法。

这是怎么回事?为什么我的代码会这样包装?我的 config.coffee 看起来像这样:

  files:
    javascripts:
      joinTo:
        "js/app.js": /^app/
        "js/vendor.js": /^(bower_components|vendor)/
      order:
        before: [
          'bower_components/queue-async/queue.js',
          'bower_components/topojson/topojson.js',
          'bower_components/topojson/topojson.js',
          'bower_components/d3/d3.js',
          'bower_components/requirejs/requirejs.js'
        ]
4

1 回答 1

2

我只需要将这段代码添加到我的配置文件中

  files:
    ...
  modules:  //this stops the wrapping
    wrapper: false
于 2014-02-19T12:18:55.180 回答