在webpack中包含CSV-JS(动态需要错误)

时间:2017-01-13 15:51:09

标签: javascript webpack ui-grid

我是webpack的新手,并且一直在努力解决这个问题,需要一些帮助。

此回购:github.com/gkindel/CSV-JS

我无法使用webpack构建。它抛出错误:

WARNING in ./bower_components/CSV-JS/csv.js
Critical dependencies:
203:20-27 require function is used in a way in which dependencies cannot be statically extracted

以下是我尝试使用它的方法:

// CSV-JS used by angular ui-grid CSV importer
window.CSV = require('../bower_components/CSV-JS');

它失败的线看起来像这样:

 CSV.stream = function () {
    var s = new require('stream').Transform({objectMode: true});
    ...

我很确定ui-grid不在库中使用此函数,但webpack必须解析整个文件。我猜这是在节点环境中使用的功能。

无论如何,任何人都有办法加载这种依赖?或者也许是另类图书馆? (不确定这是否可行,因为ui-grid取决于CSV.parse()函数)。

0 个答案:

没有答案