Fix incorrect module specifiers in polymer-3-element init template.#366
Fix incorrect module specifiers in polymer-3-element init template.#366
Conversation
We always need to use bare module specifiers, not relative URLs, when we refer to our dependencies. That means using inline scripts with `import` statements, and not external script tags. In this case it caused some Polymer modules to be loaded twice, once from "/components/<element>/node_modules/@polymer/..." and again from "/components/node_modules/@polymer/...". Also bump the minimum version of iron-demo-helpers, since I was getting an old version of prism-element that had a missing "prism-theme-default.js". Fixes #365
But we can't do this for classic scripts, right? https://github.com/Polymer/tools/pull/366/files#diff-59d2389829a2bc107f1def84055d9db2R9 Didn't we decide that we don't want to serve from |
|
Oh, is this causing a problem when testing through WCT? |
See #365. If you init
Right, it only works with modules.
Yeah, but we still print it out when you run serve. It's still needed for 2.x use-cases, which we still support, so maybe we need to do something smart to detect what URL to suggest people visit. I think we should make sure the /components/ directory works for now, though. |
| <script type="module" src="../node_modules/@polymer/iron-demo-helpers/demo-pages-shared-styles.js"></script> | ||
| <script type="module" src="../node_modules/@polymer/iron-demo-helpers/demo-snippet.js"></script> | ||
| <script type="module"> | ||
| import '@polymer/iron-demo-helpers/demo-pages-shared-styles'; |
There was a problem hiding this comment.
The .js isn't actually needed, node resolution includes adding a .js. Have we typically been including them anyway?
There was a problem hiding this comment.
I think so (modulizer doesn't remove them, fwiw) but it doesn't seem like we're totally consistent since some of our projects make use of node's main field: https://github.com/Polymer/pwa-starter-kit/blob/8da3dcc42472e99fa22d0a996362828d31dc70bb/src/components/my-app.js#L11-L13
There was a problem hiding this comment.
IMO, we shouldn't have allowed these kinds of special behaviors from Node.js' specifier resolution in polyserve's rewriting and really hope this gets dropped in spec land.
We always need to use bare module specifiers, not relative URLs, when we refer to our dependencies. That means using inline scripts with
importstatements, and not external script tags. In this case it caused some Polymer modules to be loaded twice, once from "/components/my-element/node_modules/@polymer/..." and again from "/components/node_modules/@polymer/...".Also bump the minimum version of iron-demo-helpers, since I was getting an old version of prism-element that had a missing "prism-theme-default.js".
Fixes #365