【问题标题】:gulp browserify and bromotegulp browserify 和 bromote
【发布时间】:2014-09-23 08:45:14
【问题描述】:

我的项目正在使用 gulp-starter,它已经使用 browserify 实现了相当多的布线,我现在正在尝试添加 @987654323 @ 给这个项目。

我发现这个参考实现 bromotebrowserify browserify & factor-bundle dependency ids 并试图让它工作。

这是我得出的要点: https://gist.github.com/newtonianb/18f8bcd23ee9762324c6

它编译得很好,但我无法访问我的导出。据我了解,无论您在 bromote 中导出什么内容,您都可以在 javascript 源文件中像这样使用它

var bromote = require('bromote');
bromote.your_export_name(function(x) {});

但是在我的 javascript 源文件中,当我尝试 require('bromote') 时,我得到了

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Cannot find module node_moduleromotelibexport-remote.js' from 'node_modules\bromote\loaders'
  at node_modules\browserify\node_modules\resolve\lib\async.js:50:17
  at process (node_modules\browserify\node_modules\resolve\lib\async.js:119:43)
  at node_modules\browserify\node_modules\resolve\lib\async.js:128:21
  at load (node_modules\browserify\node_modules\resolve\lib\async.js:60:43)
  at node_modules\browserify\node_modules\resolve\lib\async.js:66:22
  at node_modules\browserify\node_modules\resolve\lib\async.js:21:47
  at Object.oncomplete (fs.js:107:15)

【问题讨论】:

    标签: node.js browserify google-api-nodejs-client browserify-shim


    【解决方案1】:

    如果您只需要谷歌地图,请放弃 bromote 并使用带有 @987654321@ npm 模块的 browserify。在大多数情况下,最好的办法是看看是否有一些东西可以与 browserify 一起使用。

    【讨论】:

    • 这可能无法达到您的预期。看这行代码:GoogleMapsLoader.createLoader = function() {script = document.createElement('script');script.type = 'text/javascript';script.src = GoogleMapsLoader.createUrl();document.body.appendChild(script);};这就是你引用的npm模块。该模块所做的只是在内存中构建一个脚本标签并将其推送到页面上。与 dom 生命周期、预加载等所有相关的任何问题仍然存在。
    猜你喜欢
    • 1970-01-01
    • 2015-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-12
    • 1970-01-01
    相关资源
    最近更新 更多