fex-team / fis3-hook-node_modules

fis3 node_modules 支持
81 stars 12 forks source link

lodash detect exports cause error #51

Closed huashiyiqike closed 8 years ago

huashiyiqike commented 8 years ago

lodash 的 isbuffer.js

var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;

/** Detect free variable `module`. */
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;

/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;

/** Built-in value references. */
var Buffer = moduleExports ? root.Buffer : undefined;

这里检测buffer,没有的话应该是设置成undefined,但是编译后成为直接require,没有找到会报错


 var Buffer = require("buffer").Buffer;
Buffer.isBuffer = require("is-buffer");
  var root = require('beauty-canteen:node_modules/material-ui/node_modules/lodash/_root.js'),
      stubFalse = require('beauty-canteen:node_modules/material-ui/node_modules/lodash/stubFalse.js');

  /** Detect free variable `exports`. */
  var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;

  /** Detect free variable `module`. */
  var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;

  /** Detect the popular CommonJS extension `module.exports`. */
  var moduleExports = freeModule && freeModule.exports === freeExports;

  /** Built-in value references. */
  var Buffer = moduleExports ? root.Buffer : undefined;
2betop commented 8 years ago

把这个自动加 buffer 依赖的功能关了吧。

fis.hook('node_modules', {
  shimBuffer: false
})
huashiyiqike commented 8 years ago

好了。。