我已经构建了一个自定义元素/ Web组件来加载和显示Unity生成的WebGL内容 . Web组件导入UnityLoader.js模块 - 在使用'聚合物服务'的应用程序中使用时可以正常工作 .
但是,当我构建一个通过Polymer-CLI构建过程使用我的Web组件的应用程序时,没有给出错误,但是当我使用我的组件访问页面时,我总是在UnityLoader.js中出现错误:
"ReferenceError: BabelHelpers is not defined"
如果我直接在我的应用程序中创建元素(换句话说它不再由bower管理)那么我可以在我的应用程序的polymer.json文件的构建部分中排除缩小和编译步骤,并且应用程序的内置版本工作正常 .
"builds": [
{
"preset": "es5-bundled",
"js": {
"compile": {"exclude": ["content/**/*","UnityLoader.js"]},
"minify": {"exclude": ["content/**/*","UnityLoader.js"]}
},
"html": {
"minify": {"exclude": ["content/**/*"]}
}
}
]
我查看了我的应用程序的polymer.json文件,我可以看到extraDependecies节点包含一些其他Web组件放在那里的依赖项:
"extraDependencies": [
"bower_components/webcomponentsjs/*.js",
"!bower_components/webcomponentsjs/gulpfile.js",
"manifest.json",
"bower_components/plastic-image/intersection-observer.js",
"bower_components/ua-parser-js/dist/ua-parser.min.js"
],
我在元素的polymer.json的extraDependencies中有UnityLoader.js,但这并没有被级联到导入/使用该元素的应用程序 - 我想这必须是塑料图像和ua-parser-js已经完成的它(我看过他们的bower_components文件夹,似乎没有什么明显的 - 除了后者安装为前者的依赖) .
关于如何确保我的Web组件使用的UnityLoader.js在使用它的应用程序的构建过程中不会被编译或缩小的任何想法?
1 回答
使用
polymer-cli 1.7.0
进行ES5构建时,我遇到了与firebase-auth.js
类似的问题 . 编译/缩小特定文件时可能存在问题 . 我不得不使用npm install -g polymer-cli@1.6.0
回滚到1.6.0
来解决问题 .