Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymer cannot be used with Skypack #5678

Open
Legioth opened this issue Jan 18, 2021 · 2 comments
Open

Polymer cannot be used with Skypack #5678

Legioth opened this issue Jan 18, 2021 · 2 comments
Labels

Comments

@Legioth
Copy link

Legioth commented Jan 18, 2021

Polymer cannot be used reliably from the Skypack CDN. By extension, any application that uses third party web components based on Polymer cannot use the new Streaming Imports mode introduced in Snowpack 3.

A simple example works as long as there's either only an import for the main module (@polymer/polymer) or only specific module imports (e.g. @polymer/polymer/polymer-element.js). Mixing those two modes will lead to dom-module being defined twice - once inlined into the main bundle and once as a standalone file through the other import. Consistently using only one way of importing is possible in a limited application, but typically not when using third party components (such as almost anything from Vaadin).

Fixing this would probably need a proper exports map in package.json which would let Skypack known which modules might be loaded separately and should thus not be inlined into the main bundle. I'm making this assumption based on what I read in https://docs.skypack.dev/package-authors/package-checks#export-map - I haven't tested it in practice.

Improving compatibility between Polymer and Skypack / Snowpack is mostly important because new applications started using a more modern tech stack might still want to reuse existing web components implemented using Polymer. Without a fix, they would have to find replacement components that are compatible with their tech stack.

Live Demo

https://jsbin.com/jabapumota/edit?html,console

Steps to Reproduce

  1. Import @polymer/polymer from cdn.skypack.dev
  2. Import @polymer/polymer/polymer-element.js from cdn.skypack.dev

Expected Results

No exceptions

Actual Results

Error: Failed to execute 'define' on 'CustomElementRegistry': the name "dom-module" has already been used with this registry

Versions

  • Polymer: v3.4.1
@matthewp
Copy link

Hi, I work for Skypack and I can confirm that using an export map will allow the CDN to optimize the build when multiple entrypoints are expected. If this project is now inactive then another option is for you to contribute an export map to https://github.com/snowpackjs/DefinitelyExported and we can make sure it is used in the CDN.

@stale
Copy link

stale bot commented Mar 2, 2022

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.

@stale stale bot added the wontfix label Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants