polymer.json 中的 extraDependencies 是什么,“!”是什么?意思是?
What are extraDependencies for in polymer.json, and what does "!" mean?
在我看到的默认 polymer.json 文件中:
"extraDependencies": [
"bower_components/webcomponentsjs/*.js",
"!bower_components/webcomponentsjs/gulpfile.js",
"manifest.json"
],
文档对此有点含糊:
Dependencies that the analyzer component of the Polymer build toolchain can’t discover, possibly because they're not statically imported, and that do not need to be bundled.
- 为什么工具链无法发现它?
- 如果无法发现它们,为什么我们需要包括它们?
- 如果他们"don't need to be bundled",他们实际上做了什么?
如文档所述,工具链无法发现这些文件,因为它们不是静态导入的。分析器只知道像这样的静态导入:
<link rel="import" href="../bower_components/my-component.html">
很可能您的 bower_components/webcomponentsjs/*.js
库正在被动态导入 通过检查浏览器是否原生支持网络组件,如果不支持则加载网络组件 polyfill。至于 manifest.json
,它不是作为 HTML 导入的,而是作为如下清单导入的:
<link rel="manifest" href="/manifest.json">
如果您使用 polymer build
制作应用程序的生产版本,则需要包含 extraDependencies,因此 polymer-cli 知道将这些文件包含在您的版本中。
Web 组件 js 文件不需要捆绑(注意它们仍然需要添加到 build) 因为你不希望每个应用程序都带有完整的 web 组件 polyfill,当像 Chrome 这样的浏览器已经原生支持它时。 manifest.json 不应捆绑,因为它是获取应用程序元数据所需的独立文件。
在我看到的默认 polymer.json 文件中:
"extraDependencies": [
"bower_components/webcomponentsjs/*.js",
"!bower_components/webcomponentsjs/gulpfile.js",
"manifest.json"
],
文档对此有点含糊:
Dependencies that the analyzer component of the Polymer build toolchain can’t discover, possibly because they're not statically imported, and that do not need to be bundled.
- 为什么工具链无法发现它?
- 如果无法发现它们,为什么我们需要包括它们?
- 如果他们"don't need to be bundled",他们实际上做了什么?
如文档所述,工具链无法发现这些文件,因为它们不是静态导入的。分析器只知道像这样的静态导入:
<link rel="import" href="../bower_components/my-component.html">
很可能您的
bower_components/webcomponentsjs/*.js
库正在被动态导入 通过检查浏览器是否原生支持网络组件,如果不支持则加载网络组件 polyfill。至于manifest.json
,它不是作为 HTML 导入的,而是作为如下清单导入的:<link rel="manifest" href="/manifest.json">
如果您使用
polymer build
制作应用程序的生产版本,则需要包含 extraDependencies,因此 polymer-cli 知道将这些文件包含在您的版本中。Web 组件 js 文件不需要捆绑(注意它们仍然需要添加到 build) 因为你不希望每个应用程序都带有完整的 web 组件 polyfill,当像 Chrome 这样的浏览器已经原生支持它时。 manifest.json 不应捆绑,因为它是获取应用程序元数据所需的独立文件。