BabelHelpers 不是使用 Polymer 定义的

BabelHelpers is not defined using Polymer

我正在使用 Polymer 及其构建过程。捆绑文件是通过我的 polymer.json 文件生成的。

我并没有明确使用 Babel,我只是看到它被 "paper-autocomplete" 使用。

访问网站时,出现 js 错误,提示未定义 BabelHelpers。

当 运行 它在本地工作正常。当我将它部署到我的服务器时,我遇到了这个问题。

我 运行 它是一个独立的 Java 应用程序,因为它有一个 Spring 后端。 该网站作为多个入口点,适用于所有其他入口点。

堆栈跟踪:

命令:

polymer build --js-minify --css-minify --html-minify

polymer.json 文件

{
  "entrypoint": "pt.html",
  "builds": [{
      "bundle": true,
      "js": {"compile": true, "minify": true},
      "css": {"minify": true},
      "html": {"minify": false},
      "addServiceWorker": true 
    }],
  "shell": "resources/elements-platform.html",
  "fragments": [
    "resources/html/lazy-resources.html",
    "resources/html/ym-dashboard.html",
    "resources/html/ym-partners.html",
    "resources/html/ym-favorite.html",
    "resources/html/ym-agenda.html",
    "resources/html/ym-todos.html",
    "resources/html/ym-profile.html",
    "resources/html/ym-messages.html",
    "resources/html/shop-list.html",
    "resources/html/shop-detail.html"
  ],
  "sources": [
   "resources/src/**/*",
   "resources/css/**/*",
   "resources/data/**/*",
   "resources/images/**/*",
   "resources/img/**/*",
   "resources/js/*",
   "resources/js/cal/*",
   "resources/js/countdown/*",
   "resources/bower.json"
  ],
  "extraDependencies": [
    "resources/bower_components/webcomponentsjs/webcomponents-lite.min.js"
  ]
}

我 运行 几天前在我将 Polymer-cli 更新到最新版本后遇到了同样的问题。但就我而言,我的应用程序在本地虚拟主机(使用自签名证书)上抛出了同样的错误。在生产网站上没问题。

实际上,babelHelpers 被注入到 polymer.json 文件中被选为 entrypoint 的文件中。如果您有正确的现有文件,也许可以尝试查看那里。

github 上很少有关于此问题的现有问题。不幸的是,没有经过验证的答案(Polymer 团队并不真正关心 github 问题)

https://github.com/Polymer/polymer-cli/issues/787 https://github.com/Polymer/polymer-cli/issues/765

Whosebug 上也有同样的问题,答案是: polymer-cli - getting "Can’t find variable: babelHelpers" when I set compile to true

我也看到了 'babelHelpers' is undefined。在我的例子中,它来自 redux.js:

q='object'==('undefined'===typeof self?'undefined':babelHelpers
.typeof(self))&&self&&self.Object===Object&&self,r=p||q||
Function('return this')(),s=r.Symbol,t=Object.prototype,

Babel helpers 也像 Issue #606 中那样被引发,它表示它已解决并关闭。但是它或类似的东西又回来了。

我做了一些修改,但我不知道哪一个解决了问题。问题来自纸张自动完成。当我停止使用它时,我不再有问题了。 我仍在使用它,但我做了一些更改:

  • 我确定我使用的是生成的 service-worker
  • 我停止使用我的 bower (3.2.1) 中的 JQuery 版本并从 JQuery CDN (2.3.1) 使用它,因为我发现它有时会导致问题
  • 在 polymer.json 文件中添加了 manifest.json