简体   繁体   English

Vulcanize-从哪里导入polymer.js?

[英]Vulcanize - where is polymer.js getting imported from?

I have a imports.html page below that I am vulcanizing. 我下面正在硫化的imports.html页面。

What is strange is....normally in my index.html I have <link rel="import" href="bower_components/polymer/polymer.html"> ....which is not in imports.html . 奇怪的是……通常在我的index.html我有<link rel="import" href="bower_components/polymer/polymer.html"> ....,这不在imports.html But when I vulcanize imports.html , somehow it gets included and I have to remove <link rel="import" href="bower_components/polymer/polymer.html"> from my index.html . 但是,当我硫化imports.html ,就以某种方式将其包括在内,并且必须从index.html删除<link rel="import" href="bower_components/polymer/polymer.html"> Otherwise, I would get 不然我会

Uncaught NotSupportedError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'dom-module'. A type with that name is already registered.

Where is polymer.html coming from when I vulcanize imports.html ? 当我硫化imports.html时, polymer.html来自哪里? Because it's not in imports.html . 因为它不在imports.html


!-- custom style sheets-->
<link rel="stylesheet" href="css/splash.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/fade-title-animation.css">
<link rel="stylesheet" href="css/paper-ripple.css">
<link rel="stylesheet" href="css/slider-animation.css">
<link rel="stylesheet" href="bower_components/components-font-awesome/css/font
-awesome.min.css">
<!-- custom style sheets-->

<!-- bower components -->
<link rel="import" href="bower_components/paper-menu/paper-menu.html">
<link rel="import" href="bower_components/paper-item/paper-item.html">
<link rel="import" href="bower_components/paper-drawer-panel/paper-drawer-panel.html">
<link rel="import" href="bower_components/iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="bower_components/paper-header-panel/paper-header-panel.html">
<link rel="import" href="bower_components/iron-collapse/iron-collapse.html">
<link rel="import" href="bower_components/iron-icon/iron-icon.html">
<link rel="import" href="bower_components/iron-icons/editor-icons.html">
<link rel="import" href="bower_components/paper-ripple/paper-ripple.html">
<link rel="import" href="bower_components/iron-icons/iron-icons.html">
<link rel="import" href="bower_components/iron-icons/image-icons.html">
<link rel="import" href="bower_components/paper-toolbar/paper-toolbar.html">
<link rel="import" href="bower_components/paper-material/paper-material.html">
<link rel="import" href="bower_components/paper-card/paper-card.html">
<link rel="import" href="bower_components/iron-media-query/iron-media-query.html">
<link rel="import" href="bower_components/paper-fab/paper-fab.html">
<link rel="import" href="bower_components/paper-button/paper-button.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="bower_components/paper-tabs/paper-tabs.html">
<!-- bower components -->

<!-- custom elements -->
<link rel="import" href="elements/portfolio/cards/card-behavior.html">
<link rel="import" href="elements/page-behavior.html">
<link rel="import" href="elements/page-styles.html">
<link rel="import" href="elements/footer-custom.html">
<link rel="import" href="elements/toolbar-menus/paper-menu-custom.html">
<link rel="import" href="elements/toolbar-menus/paper-tabs-custom.html">
<link rel="import" href="elements/portfolio/cards/portfolio-card-styles.html">
<link rel="import" href="elements/portfolio/portfolio-display.html">
<link rel="import" href="elements/portfolio/portfolio-page.html">
<link rel="import" href="elements/portfolio/cards/cloud-share-image-card.html">
<link rel="import" href="elements/portfolio/cards/cloud-monitor-card.html">
<link rel="import" href="elements/portfolio/cards/legacy-darin-card.html">
<link rel="import" href="elements/portfolio/cards/dad-site-card.html">
<link rel="import" href="elements/portfolio/cards/gulp-newy-card.html">
<link rel="import" href="elements/portfolio/cards/darin-hensley-card.html">
<link rel="import" href="elements/portfolio/cards/krunch-uploader-card.html">
<link rel="import" href="elements/resume/resume-page.html">
<link rel="import" href="elements/resume/resume-display.html">
<link rel="import" href="elements/contact-display.html">
<!-- custom elements -->

<!-- js -->
<script src="js/misc.js" ></script>
<script src="bower_components/page/page.js"></script>
<script src="js/router.js"></script>
<script src="js/resume.js"></script>
<script src="js/pdf.js"></script>
<script src="js/pdf.worker.js"></script>
<script src="js/initialize.js" defer></script>
<!-- js -->

You have one of the element that import polymer.html go over the custom element and check what file contain this import.(I think that all the polymer-elements contains this import) Vulcanize scan recursively for imports. 您有一个要导入polymer.html的元素之一,移过自定义元素并检查哪个文件包含此导入。(我认为所有的polymer元素都包含此导入) 。Vulcanize递归扫描导入。

The real problem is that you vulcanize only the import file and not all the index. 真正的问题是您仅硫化了导入文件,而没有硫化所有索引。 if you want to vulcanize only the imports.html file you have to put all the imports inside this file. 如果您只想硫化imports.html文件,则必须将所有导入文件放入该文件中。

In regular case what happand (before you vulcanize) 在正常情况下会发生什么情况(硫化之前)

The browser parse the html file. 浏览器解析html文件。 if it has 2 imports with same url it import it once. 如果它具有2个具有相同URL的导入,则将其导入一次。

In your case, vulcanize the imports file. 在您的情况下,硫化导入文件。

now it includes the polymer.html and then when you import this file on the index, the browser dont know that in the vulcanized file you have polymer.html file. 现在它包含polymer.html,然后在索引上导入此文件时,浏览器不知道在硫化文件中您具有polymer.html文件。 so it import it again.. 所以它再次导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM