2014-02-19 84 views
4

我在使用requirejs的早午餐项目中有一个文件app/js/d3.js。当我建立文件时,按照预期将app/js/d3.js中的代码连接成app.js。但它被包裹在看起来像一些需要的代码,如下所示:为什么早午餐会添加这个requirejs代码?

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 

我有足够的新要求,如果这是应该发生的或者我不能说这是否是从早午餐的意外情况。当我搜索require api注册时,我看不到注册方法。

发生了什么事?为什么我的代码被这种方式包装?我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' 
     ] 

回答

2

我只需要将此代码添加到我的配置文件

files: 
    ... 
    modules: //this stops the wrapping 
    wrapper: false