Banno / polymer-webpack-loader

WebPack Loader for Polymer Web Components
MIT License
192 stars 48 forks source link

Using rel=lazy-import not working ... #79

Closed ruud closed 6 years ago

ruud commented 6 years ago

We are using the https://github.com/Polymer/lazy-imports in our application. We also would like to use webpack for our build. How would you suggest using these two together?

ChadKillingsworth commented 6 years ago

Polymer's lazy imports are not supported by the loader. Loaders are restricted to transforming a single file at a time and the HTML and JS for a component can be in separate files.

Instead, use this style syntax to support lazy loading:

Promise.all([
  import('./path/to/component1.html'),
  import('./path/to/component2.html')
]).then(() => {
  // components are loaded - use them
});

Webpack automatically recognizes this style of import as a split point and will move component1 and 2 into a separate bundle which is loaded on demand.

ruud commented 6 years ago

Thanks for your reply!

related issue: https://github.com/Polymer/lazy-imports/issues/46