Reputation: 21
Currently I migrate a Polymer 2.0 app to Polymer 3.0. But at the moment understandably a lot of components are still not migrated, yet (like e.g vaadin-gid as one example).
How can I use these Polymer 2 components in my migrated Polymer 3 app?
Upvotes: 2
Views: 860
Reputation: 63
my solutions was upgrade the polymer 2.0 elements to polymer 3.0, using polymer-modulizer
[https://polymer-library.polymer-project.org/3.0/docs/upgrade][1]
Upvotes: 0
Reputation: 2111
basicly add this code in <head>
and delete /bower_components/polymer
folder
<script type="module">
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
window.Polymer = {
Element: PolymerElement
};
window.loadElement = function(filename) {
var l = document.createElement('link');
l.rel = 'import';
l.href = filename
var h = document.getElementsByTagName('head')[0];
h.parentNode.insertBefore(l, h);
}
// Load de main element
loadElement('/main-poly2.html');
</script>
load polymer 3 elements in polymer 2
<script type="module">
import './poly3-element'
class MainPoly2 extends Polymer.Element {
...
}
</script>
load polymer 2 elements in polymer 3
import {PolymerElement, html} from '/node_modules/@polymer/polymer/polymer-element.js';
loadElement('/poly2-element.html');
class Poly3Element extends PolymerElement {
....
}
I write a example in:
https://github.com/herberthobregon/polymer2-3
It works but the polymer team has not answered me if the implementation is correct, but works
Upvotes: 1