PredixDev / predix-webapp-starter

A web application starter kit built on Polymer, Web Components, NodeJS and Predix UI Components
https://predix-webapp-starter.run.aws-usw02-pr.ice.predix.io
Other
61 stars 75 forks source link

Fragment's dependency's dependency does not resolve in a correct way #5

Closed szalonna closed 7 years ago

szalonna commented 7 years ago

Context

If I include a sub element in a view fragment, which depends on another component (like px-card), then in the built package subelement's dependency cannot resolve.

Process

  1. Create a subelement with a dependency
    <!-- demo-element/demo-element.html -->
    <link rel="import" href="../../bower_components/polymer/polymer.html" />
    <link rel="import" href="../../bower_components/px-card/px-card.html" />
    <dom-module id="demo-element">
    <template>
    <px-card header-text="Header">
      <p>Demo content</p>
    </px-card>
    </template>
    <script>
    </script>
    </dom-module>
  2. Create a fragment view which uses the subelement
    <!-- views/demo-view.html -->
    <link rel="import" href="../../bower_components/polymer/polymer.html" />
    <link rel="import" href="../demo-element/demo-element.html" />
    <dom-module id="demo-view">
    <template>
    <div>
      Demo view
      <demo-element></demo-element>
    </div>
    </template>
    <script>
    Polymer({
      is: 'demo-view'
    });
    </script>
    </dom-module>
  3. Add the fragment for an app-route
  4. Add fragment to the polymer.json
  5. Run gulp dist to make a distributable version
  6. Start a static file server in the dist/public folder

Expected result

The application up and running in a correct way with no error in the console log.

Current result

The application halts and the following error can be seen in the console:

GET http://localhost:8000/bower_components/px-card/px-card.html 404 (Not Found)

Uncaught DOMException: Failed to execute 'registerElement' on 'Document': Registration failed for type 'dom-module'. A type with that name is already registered.
    at http://localhost:8000/bower_components/polymer/polymer-micro.html:449:10
    at http://localhost:8000/bower_components/polymer/polymer-micro.html:464:2
szalonna commented 7 years ago

It turned out I am facing with an existing Polymer issue: Polymer/polymer#4134

gstroup commented 7 years ago

Yes, I think I came across that same Polymer issue. Glad you tracked it down. If I come up with a solution, I'll let you know.