【问题标题】:Including Typeahead.js Bloodhound with Browserify gives empty object {}使用 Browserify 包含 Typeahead.js Bloodhound 会给出空对象 {}
【发布时间】:2014-08-16 20:39:38
【问题描述】:

我正在我的 Browserify 项目中尝试使用 Bloodhound 和 Typeahead。我正在使用 browserify-shim。

package.json

{
     ...
    "browserify": {
        "transform": ["browserify-shim"]
    },
    "browserify-shim": "./shim.js",
}

shim.js

module.exports = {
    ...
    'typeahead.js/dist/bloodhound': {
        exports: 'Bloodhound',
        depends: {jquery: 'jQuery'}
    }
};

test.js

...
var Bloodhound = require('typeahead.js/dist/bloodhound');

module.exports = function() {
    console.log(Bloodhound);
}

输出一个空对象 ({})。

我已经关注了relevant question 中的所有内容,从命令行使用 vanilla Browserify,但仍然没有骰子。


我可以通过添加来让它工作

module.exports = Bloodhound;

到 bloodhound.js 文件,但这远非理想。 browserify-shim 不应该添加导出吗?我在生成的 bundle.js 中没有看到 Bloodhound 的 module.exports。

【问题讨论】:

    标签: javascript typeahead browserify bloodhound browserify-shim


    【解决方案1】:

    显然这将在 v0.11 中得到修复,因为 typeahead.js 正在移动到 UMD

    https://github.com/twitter/typeahead.js/issues/743#issuecomment-52412193

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-19
      • 1970-01-01
      • 1970-01-01
      • 2018-07-05
      • 1970-01-01
      相关资源
      最近更新 更多