Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

polymer-starter-kit-2 template includes views as both lazy imports and explicit fragments #2443

Open graynorton opened 7 years ago

graynorton commented 7 years ago

The polymer-starter-kit-2 template in polymer-cli 1.0.0 includes the application views as both lazy imports declared in my-app.html and as fragments explicitly specified in polymer.json.

It seems that this is a mistake; I assume the intention was to include them as lazy imports only.

stramel commented 7 years ago

TL;DR This is intentional.

The lazy-imports included in my-app.html are really a stop-gap to fix some lint errors.

I have a PR out to properly handle lazy-imports. https://github.com/PolymerElements/polymer-starter-kit/pull/998

For reference, the components that are defined as lazy-imports should also be declared in the polymer.json as fragments. This ensures that the bundling properly leaves those out for importing at a later point.

graynorton commented 7 years ago

Hi, @stramel.

@justinfagnani can confirm, but arguably the main benefit of lazy imports is that they enable the tools to discover fragments via <link rel="lazy-import" ...> tags, eliminating the need to specify them separately in polymer.json. I don't think you'd hurt anything by including them anyway, but it's not the intended usage.

usergenic commented 7 years ago

@stramel @graynorton The bundler code should discover the lazy-imports as long as they are in the transitive dependency graph of something that is specified as a fragment, in this case the shell.html includes the lazy-import links, so bundler should identify them as a fragment wrt to bundling.

You can see the logic for this here in bundler: https://github.com/Polymer/polymer-bundler/blob/master/src/deps-index.ts#L99

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.