Lazy load web-components from other services in polymer 3












0














I have a microservice based application and each service has a set of polymer based web-components. I want to load these at runtime in the application that is served by one of them at runtime, so that I can run, maintain and deploy the services seperately.
I would like to avoid having a npm repo that serves the components for a central build and each new web component version would make it necessary to rebuild and redeploy the application.



Existing lazy loading examples all lazy load components of the same application, so it's built as a whole and just packaged in chunks.



The application is available under /app/ and the modules are under /mod/...



I can do this in to react to a route:



import('/mod/admindashboard/kw-admindashboard.js').then((module) => {
// Put code in here that you want to run every time when
// navigating to view1 after my-view1.js is loaded.
console.log("Loaded admindashboard");
});


and then I can use the corresponding web component, but for this to work I need to hack the component like this:



import { PolymerElement, html } from '/app/node_modules/@polymer/polymer/polymer-element.js';
import '/app/node_modules/@polymer/iron-icon/iron-icon.js';
import '/app/node_modules/@polymer/iron-icons/iron-icons.js';

class KwAdmindashboard extends PolymerElement {
static get template() {
...


But this approach prevents me completely to run tests, create static builds and IDE support is not available either in many areas, as it's not able to see what is available later at runtime. So as absolute fallback this would be possible. Isn't there a way to utilize the serviceWorkers to handle mapping?










share|improve this question




















  • 1




    Since you keep update your question, I believe you will find your answer soon but one thing I want to share based on my experience (not much) I would prefer to have a private npm repo for each component. In this way you can easily manage version for each component in each application. This is obviously separate build not central. And also If you separate build each component and then import you may end up with a lot of duplicate dependencies. Thanks.
    – User 28
    Nov 20 at 8:02








  • 1




    I'm a bit confused. At first glance, I think you want to create a service like private unpkg to serve your private components and used by multiple applications. But you said "The application is available under /app/ and the modules are under /mod/" so this is a single application and their dependencies is in the same repo?
    – User 28
    Nov 20 at 9:14






  • 1




    If I am not wrong, you want to load a module dynamically when you navigated to the page. and load module with this page' s label or name?
    – HakanC
    Nov 20 at 14:39






  • 1




    Here below I will try to add an example which I inspired from shop-app before It was 2.x and I will try to convert it 3.0 version
    – HakanC
    Nov 20 at 18:23






  • 1




    @PatrickCornelissen If you serve each services with esm, everything should work fine with dynamic import. If you have to transpile it to non-module for support old browser, you have to separate build self-contained for each services then import it with dynamic import as usual. You can use url like http://repo.../dist/index.js or use some prefix like /mod then proxy it from nginx or whatever. You can do integration test as usual but IDE support it will be impossible.
    – User 28
    Nov 21 at 2:27


















0














I have a microservice based application and each service has a set of polymer based web-components. I want to load these at runtime in the application that is served by one of them at runtime, so that I can run, maintain and deploy the services seperately.
I would like to avoid having a npm repo that serves the components for a central build and each new web component version would make it necessary to rebuild and redeploy the application.



Existing lazy loading examples all lazy load components of the same application, so it's built as a whole and just packaged in chunks.



The application is available under /app/ and the modules are under /mod/...



I can do this in to react to a route:



import('/mod/admindashboard/kw-admindashboard.js').then((module) => {
// Put code in here that you want to run every time when
// navigating to view1 after my-view1.js is loaded.
console.log("Loaded admindashboard");
});


and then I can use the corresponding web component, but for this to work I need to hack the component like this:



import { PolymerElement, html } from '/app/node_modules/@polymer/polymer/polymer-element.js';
import '/app/node_modules/@polymer/iron-icon/iron-icon.js';
import '/app/node_modules/@polymer/iron-icons/iron-icons.js';

class KwAdmindashboard extends PolymerElement {
static get template() {
...


But this approach prevents me completely to run tests, create static builds and IDE support is not available either in many areas, as it's not able to see what is available later at runtime. So as absolute fallback this would be possible. Isn't there a way to utilize the serviceWorkers to handle mapping?










share|improve this question




















  • 1




    Since you keep update your question, I believe you will find your answer soon but one thing I want to share based on my experience (not much) I would prefer to have a private npm repo for each component. In this way you can easily manage version for each component in each application. This is obviously separate build not central. And also If you separate build each component and then import you may end up with a lot of duplicate dependencies. Thanks.
    – User 28
    Nov 20 at 8:02








  • 1




    I'm a bit confused. At first glance, I think you want to create a service like private unpkg to serve your private components and used by multiple applications. But you said "The application is available under /app/ and the modules are under /mod/" so this is a single application and their dependencies is in the same repo?
    – User 28
    Nov 20 at 9:14






  • 1




    If I am not wrong, you want to load a module dynamically when you navigated to the page. and load module with this page' s label or name?
    – HakanC
    Nov 20 at 14:39






  • 1




    Here below I will try to add an example which I inspired from shop-app before It was 2.x and I will try to convert it 3.0 version
    – HakanC
    Nov 20 at 18:23






  • 1




    @PatrickCornelissen If you serve each services with esm, everything should work fine with dynamic import. If you have to transpile it to non-module for support old browser, you have to separate build self-contained for each services then import it with dynamic import as usual. You can use url like http://repo.../dist/index.js or use some prefix like /mod then proxy it from nginx or whatever. You can do integration test as usual but IDE support it will be impossible.
    – User 28
    Nov 21 at 2:27
















0












0








0







I have a microservice based application and each service has a set of polymer based web-components. I want to load these at runtime in the application that is served by one of them at runtime, so that I can run, maintain and deploy the services seperately.
I would like to avoid having a npm repo that serves the components for a central build and each new web component version would make it necessary to rebuild and redeploy the application.



Existing lazy loading examples all lazy load components of the same application, so it's built as a whole and just packaged in chunks.



The application is available under /app/ and the modules are under /mod/...



I can do this in to react to a route:



import('/mod/admindashboard/kw-admindashboard.js').then((module) => {
// Put code in here that you want to run every time when
// navigating to view1 after my-view1.js is loaded.
console.log("Loaded admindashboard");
});


and then I can use the corresponding web component, but for this to work I need to hack the component like this:



import { PolymerElement, html } from '/app/node_modules/@polymer/polymer/polymer-element.js';
import '/app/node_modules/@polymer/iron-icon/iron-icon.js';
import '/app/node_modules/@polymer/iron-icons/iron-icons.js';

class KwAdmindashboard extends PolymerElement {
static get template() {
...


But this approach prevents me completely to run tests, create static builds and IDE support is not available either in many areas, as it's not able to see what is available later at runtime. So as absolute fallback this would be possible. Isn't there a way to utilize the serviceWorkers to handle mapping?










share|improve this question















I have a microservice based application and each service has a set of polymer based web-components. I want to load these at runtime in the application that is served by one of them at runtime, so that I can run, maintain and deploy the services seperately.
I would like to avoid having a npm repo that serves the components for a central build and each new web component version would make it necessary to rebuild and redeploy the application.



Existing lazy loading examples all lazy load components of the same application, so it's built as a whole and just packaged in chunks.



The application is available under /app/ and the modules are under /mod/...



I can do this in to react to a route:



import('/mod/admindashboard/kw-admindashboard.js').then((module) => {
// Put code in here that you want to run every time when
// navigating to view1 after my-view1.js is loaded.
console.log("Loaded admindashboard");
});


and then I can use the corresponding web component, but for this to work I need to hack the component like this:



import { PolymerElement, html } from '/app/node_modules/@polymer/polymer/polymer-element.js';
import '/app/node_modules/@polymer/iron-icon/iron-icon.js';
import '/app/node_modules/@polymer/iron-icons/iron-icons.js';

class KwAdmindashboard extends PolymerElement {
static get template() {
...


But this approach prevents me completely to run tests, create static builds and IDE support is not available either in many areas, as it's not able to see what is available later at runtime. So as absolute fallback this would be possible. Isn't there a way to utilize the serviceWorkers to handle mapping?







polymer polymer-3.x






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 7:36

























asked Nov 20 at 4:03









Patrick Cornelissen

5,72123562




5,72123562








  • 1




    Since you keep update your question, I believe you will find your answer soon but one thing I want to share based on my experience (not much) I would prefer to have a private npm repo for each component. In this way you can easily manage version for each component in each application. This is obviously separate build not central. And also If you separate build each component and then import you may end up with a lot of duplicate dependencies. Thanks.
    – User 28
    Nov 20 at 8:02








  • 1




    I'm a bit confused. At first glance, I think you want to create a service like private unpkg to serve your private components and used by multiple applications. But you said "The application is available under /app/ and the modules are under /mod/" so this is a single application and their dependencies is in the same repo?
    – User 28
    Nov 20 at 9:14






  • 1




    If I am not wrong, you want to load a module dynamically when you navigated to the page. and load module with this page' s label or name?
    – HakanC
    Nov 20 at 14:39






  • 1




    Here below I will try to add an example which I inspired from shop-app before It was 2.x and I will try to convert it 3.0 version
    – HakanC
    Nov 20 at 18:23






  • 1




    @PatrickCornelissen If you serve each services with esm, everything should work fine with dynamic import. If you have to transpile it to non-module for support old browser, you have to separate build self-contained for each services then import it with dynamic import as usual. You can use url like http://repo.../dist/index.js or use some prefix like /mod then proxy it from nginx or whatever. You can do integration test as usual but IDE support it will be impossible.
    – User 28
    Nov 21 at 2:27
















  • 1




    Since you keep update your question, I believe you will find your answer soon but one thing I want to share based on my experience (not much) I would prefer to have a private npm repo for each component. In this way you can easily manage version for each component in each application. This is obviously separate build not central. And also If you separate build each component and then import you may end up with a lot of duplicate dependencies. Thanks.
    – User 28
    Nov 20 at 8:02








  • 1




    I'm a bit confused. At first glance, I think you want to create a service like private unpkg to serve your private components and used by multiple applications. But you said "The application is available under /app/ and the modules are under /mod/" so this is a single application and their dependencies is in the same repo?
    – User 28
    Nov 20 at 9:14






  • 1




    If I am not wrong, you want to load a module dynamically when you navigated to the page. and load module with this page' s label or name?
    – HakanC
    Nov 20 at 14:39






  • 1




    Here below I will try to add an example which I inspired from shop-app before It was 2.x and I will try to convert it 3.0 version
    – HakanC
    Nov 20 at 18:23






  • 1




    @PatrickCornelissen If you serve each services with esm, everything should work fine with dynamic import. If you have to transpile it to non-module for support old browser, you have to separate build self-contained for each services then import it with dynamic import as usual. You can use url like http://repo.../dist/index.js or use some prefix like /mod then proxy it from nginx or whatever. You can do integration test as usual but IDE support it will be impossible.
    – User 28
    Nov 21 at 2:27










1




1




Since you keep update your question, I believe you will find your answer soon but one thing I want to share based on my experience (not much) I would prefer to have a private npm repo for each component. In this way you can easily manage version for each component in each application. This is obviously separate build not central. And also If you separate build each component and then import you may end up with a lot of duplicate dependencies. Thanks.
– User 28
Nov 20 at 8:02






Since you keep update your question, I believe you will find your answer soon but one thing I want to share based on my experience (not much) I would prefer to have a private npm repo for each component. In this way you can easily manage version for each component in each application. This is obviously separate build not central. And also If you separate build each component and then import you may end up with a lot of duplicate dependencies. Thanks.
– User 28
Nov 20 at 8:02






1




1




I'm a bit confused. At first glance, I think you want to create a service like private unpkg to serve your private components and used by multiple applications. But you said "The application is available under /app/ and the modules are under /mod/" so this is a single application and their dependencies is in the same repo?
– User 28
Nov 20 at 9:14




I'm a bit confused. At first glance, I think you want to create a service like private unpkg to serve your private components and used by multiple applications. But you said "The application is available under /app/ and the modules are under /mod/" so this is a single application and their dependencies is in the same repo?
– User 28
Nov 20 at 9:14




1




1




If I am not wrong, you want to load a module dynamically when you navigated to the page. and load module with this page' s label or name?
– HakanC
Nov 20 at 14:39




If I am not wrong, you want to load a module dynamically when you navigated to the page. and load module with this page' s label or name?
– HakanC
Nov 20 at 14:39




1




1




Here below I will try to add an example which I inspired from shop-app before It was 2.x and I will try to convert it 3.0 version
– HakanC
Nov 20 at 18:23




Here below I will try to add an example which I inspired from shop-app before It was 2.x and I will try to convert it 3.0 version
– HakanC
Nov 20 at 18:23




1




1




@PatrickCornelissen If you serve each services with esm, everything should work fine with dynamic import. If you have to transpile it to non-module for support old browser, you have to separate build self-contained for each services then import it with dynamic import as usual. You can use url like http://repo.../dist/index.js or use some prefix like /mod then proxy it from nginx or whatever. You can do integration test as usual but IDE support it will be impossible.
– User 28
Nov 21 at 2:27






@PatrickCornelissen If you serve each services with esm, everything should work fine with dynamic import. If you have to transpile it to non-module for support old browser, you have to separate build self-contained for each services then import it with dynamic import as usual. You can use url like http://repo.../dist/index.js or use some prefix like /mod then proxy it from nginx or whatever. You can do integration test as usual but IDE support it will be impossible.
– User 28
Nov 21 at 2:27














2 Answers
2






active

oldest

votes


















1














Here below is I think a good example of your requirement. Modules will be loaded with page properties. As page property is depended on iron-page, selected='{{page}}' when page value has been changed with iron-page's name properties, its observer loads the that page's modules. :



static get properties() { return {
page: {
type: String,
reflectToAttribute: true,
observer: '_pageChanged'
},
.......

_pageChanged(page, oldPage) {
if (page != null) {
let cb = this._pageLoaded.bind(this, Boolean(oldPage));

// HERE BELOW YOUR PAGE NAMES
switch (page) {
case 'list':
import('./shop-list.js').then(cb);
break;
case 'detail':
import('./shop-detail.js').then(cb);
break;
case 'cart':
import('./shop-cart.js').then(cb);
break;
case 'checkout':
import('./shop-checkout.js').then(cb);
break;
default:
this._pageLoaded(Boolean(oldPage));
}


here above cb is a function which is loading lazy modules but needs to load immediately after the first render. Which is minimum required files.



_pageLoaded(shouldResetLayout) {
this._ensureLazyLoaded();

}


Here the full code's link of the above. Hope this helps In case of any question I will try to reply. https://github.com/Polymer/shop/blob/master/src/shop-app.js






share|improve this answer





















  • Thank you, I had a look at the shop example before, as I wrote these examples only work because the whole shop is built in one directory and depencencies are all resolved at build time. I think that web-components aren't ready yet for a truely distributed deployment due to (presumably) the missing feature to resolve the dependencies to modules at runtime.
    – Patrick Cornelissen
    Nov 21 at 8:38



















0














It seems like Polymer 3 is not yet ready for distributed locations of webcomponents.



There are github issues at the W3C which may solve these problems:





  • https://github.com/w3c/webcomponents/issues/716
    Web component registries for really distributed component development without clashes due to namespaced component registration


  • https://github.com/domenic/import-maps
    introduces a mapping from "nopm module names" to locations, which enables runtime binding much easier


For now I will switch my development model, so the microservices provide one or more webcomponents to my npm repo in nexus and the admin app has build time dependencies to them and builds the whole app in one go and there I can use the lazy loading approach that the shop demo also promotes/shows.



For a decent development experience with webcomponents from multiple sources, you should have a look at "npm link".



Feel free to add another solution for the problem or a real solution as soon as the technology and standards caught up.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386050%2flazy-load-web-components-from-other-services-in-polymer-3%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Here below is I think a good example of your requirement. Modules will be loaded with page properties. As page property is depended on iron-page, selected='{{page}}' when page value has been changed with iron-page's name properties, its observer loads the that page's modules. :



    static get properties() { return {
    page: {
    type: String,
    reflectToAttribute: true,
    observer: '_pageChanged'
    },
    .......

    _pageChanged(page, oldPage) {
    if (page != null) {
    let cb = this._pageLoaded.bind(this, Boolean(oldPage));

    // HERE BELOW YOUR PAGE NAMES
    switch (page) {
    case 'list':
    import('./shop-list.js').then(cb);
    break;
    case 'detail':
    import('./shop-detail.js').then(cb);
    break;
    case 'cart':
    import('./shop-cart.js').then(cb);
    break;
    case 'checkout':
    import('./shop-checkout.js').then(cb);
    break;
    default:
    this._pageLoaded(Boolean(oldPage));
    }


    here above cb is a function which is loading lazy modules but needs to load immediately after the first render. Which is minimum required files.



    _pageLoaded(shouldResetLayout) {
    this._ensureLazyLoaded();

    }


    Here the full code's link of the above. Hope this helps In case of any question I will try to reply. https://github.com/Polymer/shop/blob/master/src/shop-app.js






    share|improve this answer





















    • Thank you, I had a look at the shop example before, as I wrote these examples only work because the whole shop is built in one directory and depencencies are all resolved at build time. I think that web-components aren't ready yet for a truely distributed deployment due to (presumably) the missing feature to resolve the dependencies to modules at runtime.
      – Patrick Cornelissen
      Nov 21 at 8:38
















    1














    Here below is I think a good example of your requirement. Modules will be loaded with page properties. As page property is depended on iron-page, selected='{{page}}' when page value has been changed with iron-page's name properties, its observer loads the that page's modules. :



    static get properties() { return {
    page: {
    type: String,
    reflectToAttribute: true,
    observer: '_pageChanged'
    },
    .......

    _pageChanged(page, oldPage) {
    if (page != null) {
    let cb = this._pageLoaded.bind(this, Boolean(oldPage));

    // HERE BELOW YOUR PAGE NAMES
    switch (page) {
    case 'list':
    import('./shop-list.js').then(cb);
    break;
    case 'detail':
    import('./shop-detail.js').then(cb);
    break;
    case 'cart':
    import('./shop-cart.js').then(cb);
    break;
    case 'checkout':
    import('./shop-checkout.js').then(cb);
    break;
    default:
    this._pageLoaded(Boolean(oldPage));
    }


    here above cb is a function which is loading lazy modules but needs to load immediately after the first render. Which is minimum required files.



    _pageLoaded(shouldResetLayout) {
    this._ensureLazyLoaded();

    }


    Here the full code's link of the above. Hope this helps In case of any question I will try to reply. https://github.com/Polymer/shop/blob/master/src/shop-app.js






    share|improve this answer





















    • Thank you, I had a look at the shop example before, as I wrote these examples only work because the whole shop is built in one directory and depencencies are all resolved at build time. I think that web-components aren't ready yet for a truely distributed deployment due to (presumably) the missing feature to resolve the dependencies to modules at runtime.
      – Patrick Cornelissen
      Nov 21 at 8:38














    1












    1








    1






    Here below is I think a good example of your requirement. Modules will be loaded with page properties. As page property is depended on iron-page, selected='{{page}}' when page value has been changed with iron-page's name properties, its observer loads the that page's modules. :



    static get properties() { return {
    page: {
    type: String,
    reflectToAttribute: true,
    observer: '_pageChanged'
    },
    .......

    _pageChanged(page, oldPage) {
    if (page != null) {
    let cb = this._pageLoaded.bind(this, Boolean(oldPage));

    // HERE BELOW YOUR PAGE NAMES
    switch (page) {
    case 'list':
    import('./shop-list.js').then(cb);
    break;
    case 'detail':
    import('./shop-detail.js').then(cb);
    break;
    case 'cart':
    import('./shop-cart.js').then(cb);
    break;
    case 'checkout':
    import('./shop-checkout.js').then(cb);
    break;
    default:
    this._pageLoaded(Boolean(oldPage));
    }


    here above cb is a function which is loading lazy modules but needs to load immediately after the first render. Which is minimum required files.



    _pageLoaded(shouldResetLayout) {
    this._ensureLazyLoaded();

    }


    Here the full code's link of the above. Hope this helps In case of any question I will try to reply. https://github.com/Polymer/shop/blob/master/src/shop-app.js






    share|improve this answer












    Here below is I think a good example of your requirement. Modules will be loaded with page properties. As page property is depended on iron-page, selected='{{page}}' when page value has been changed with iron-page's name properties, its observer loads the that page's modules. :



    static get properties() { return {
    page: {
    type: String,
    reflectToAttribute: true,
    observer: '_pageChanged'
    },
    .......

    _pageChanged(page, oldPage) {
    if (page != null) {
    let cb = this._pageLoaded.bind(this, Boolean(oldPage));

    // HERE BELOW YOUR PAGE NAMES
    switch (page) {
    case 'list':
    import('./shop-list.js').then(cb);
    break;
    case 'detail':
    import('./shop-detail.js').then(cb);
    break;
    case 'cart':
    import('./shop-cart.js').then(cb);
    break;
    case 'checkout':
    import('./shop-checkout.js').then(cb);
    break;
    default:
    this._pageLoaded(Boolean(oldPage));
    }


    here above cb is a function which is loading lazy modules but needs to load immediately after the first render. Which is minimum required files.



    _pageLoaded(shouldResetLayout) {
    this._ensureLazyLoaded();

    }


    Here the full code's link of the above. Hope this helps In case of any question I will try to reply. https://github.com/Polymer/shop/blob/master/src/shop-app.js







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 20 at 18:53









    HakanC

    1,9173713




    1,9173713












    • Thank you, I had a look at the shop example before, as I wrote these examples only work because the whole shop is built in one directory and depencencies are all resolved at build time. I think that web-components aren't ready yet for a truely distributed deployment due to (presumably) the missing feature to resolve the dependencies to modules at runtime.
      – Patrick Cornelissen
      Nov 21 at 8:38


















    • Thank you, I had a look at the shop example before, as I wrote these examples only work because the whole shop is built in one directory and depencencies are all resolved at build time. I think that web-components aren't ready yet for a truely distributed deployment due to (presumably) the missing feature to resolve the dependencies to modules at runtime.
      – Patrick Cornelissen
      Nov 21 at 8:38
















    Thank you, I had a look at the shop example before, as I wrote these examples only work because the whole shop is built in one directory and depencencies are all resolved at build time. I think that web-components aren't ready yet for a truely distributed deployment due to (presumably) the missing feature to resolve the dependencies to modules at runtime.
    – Patrick Cornelissen
    Nov 21 at 8:38




    Thank you, I had a look at the shop example before, as I wrote these examples only work because the whole shop is built in one directory and depencencies are all resolved at build time. I think that web-components aren't ready yet for a truely distributed deployment due to (presumably) the missing feature to resolve the dependencies to modules at runtime.
    – Patrick Cornelissen
    Nov 21 at 8:38













    0














    It seems like Polymer 3 is not yet ready for distributed locations of webcomponents.



    There are github issues at the W3C which may solve these problems:





    • https://github.com/w3c/webcomponents/issues/716
      Web component registries for really distributed component development without clashes due to namespaced component registration


    • https://github.com/domenic/import-maps
      introduces a mapping from "nopm module names" to locations, which enables runtime binding much easier


    For now I will switch my development model, so the microservices provide one or more webcomponents to my npm repo in nexus and the admin app has build time dependencies to them and builds the whole app in one go and there I can use the lazy loading approach that the shop demo also promotes/shows.



    For a decent development experience with webcomponents from multiple sources, you should have a look at "npm link".



    Feel free to add another solution for the problem or a real solution as soon as the technology and standards caught up.






    share|improve this answer


























      0














      It seems like Polymer 3 is not yet ready for distributed locations of webcomponents.



      There are github issues at the W3C which may solve these problems:





      • https://github.com/w3c/webcomponents/issues/716
        Web component registries for really distributed component development without clashes due to namespaced component registration


      • https://github.com/domenic/import-maps
        introduces a mapping from "nopm module names" to locations, which enables runtime binding much easier


      For now I will switch my development model, so the microservices provide one or more webcomponents to my npm repo in nexus and the admin app has build time dependencies to them and builds the whole app in one go and there I can use the lazy loading approach that the shop demo also promotes/shows.



      For a decent development experience with webcomponents from multiple sources, you should have a look at "npm link".



      Feel free to add another solution for the problem or a real solution as soon as the technology and standards caught up.






      share|improve this answer
























        0












        0








        0






        It seems like Polymer 3 is not yet ready for distributed locations of webcomponents.



        There are github issues at the W3C which may solve these problems:





        • https://github.com/w3c/webcomponents/issues/716
          Web component registries for really distributed component development without clashes due to namespaced component registration


        • https://github.com/domenic/import-maps
          introduces a mapping from "nopm module names" to locations, which enables runtime binding much easier


        For now I will switch my development model, so the microservices provide one or more webcomponents to my npm repo in nexus and the admin app has build time dependencies to them and builds the whole app in one go and there I can use the lazy loading approach that the shop demo also promotes/shows.



        For a decent development experience with webcomponents from multiple sources, you should have a look at "npm link".



        Feel free to add another solution for the problem or a real solution as soon as the technology and standards caught up.






        share|improve this answer












        It seems like Polymer 3 is not yet ready for distributed locations of webcomponents.



        There are github issues at the W3C which may solve these problems:





        • https://github.com/w3c/webcomponents/issues/716
          Web component registries for really distributed component development without clashes due to namespaced component registration


        • https://github.com/domenic/import-maps
          introduces a mapping from "nopm module names" to locations, which enables runtime binding much easier


        For now I will switch my development model, so the microservices provide one or more webcomponents to my npm repo in nexus and the admin app has build time dependencies to them and builds the whole app in one go and there I can use the lazy loading approach that the shop demo also promotes/shows.



        For a decent development experience with webcomponents from multiple sources, you should have a look at "npm link".



        Feel free to add another solution for the problem or a real solution as soon as the technology and standards caught up.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 at 14:49









        Patrick Cornelissen

        5,72123562




        5,72123562






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386050%2flazy-load-web-components-from-other-services-in-polymer-3%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Paul Cézanne

            UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

            Angular material date-picker (MatDatepicker) auto completes the date on focus out