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

Polymer2 DomModule.prototype.modules is Empty #121

Open
Marshal27 opened this issue Jul 15, 2021 · 5 comments
Open

Polymer2 DomModule.prototype.modules is Empty #121

Marshal27 opened this issue Jul 15, 2021 · 5 comments

Comments

@Marshal27
Copy link

I have a business requirement to leverage lit NPM packages in a Polymer 2 application, we are purchasing an upgrade to Polymer 3 on the repo however, we have an immediate need to consume our lit npm packages in the current Polymer version.

I am attempting to leverage v2.0.3 in our current repo, have been successful in replicating the demo using ate-fns/format but unfortunately, as soon as I import my custom NPM package DomModule.prototype.modules is empty and I receive the following.

Uncaught DOMException: CustomElementRegistry.define: 'dom-module' has already been defined as a custom element dom-module.html:199

I apologize in advance for posting a support type item as an issue; this being the Polymer 2 version and the time-sensitive situation I am in, I was hoping someone here would be able to either point me in the right direction and or confirm that what I am attempting to accomplish may not be possible.

Thank you in advance for any help.

@bryandcoulter
Copy link
Collaborator

This is a bit outside of the loader but
Uncaught DOMException: CustomElementRegistry.define: 'dom-module' has already been defined as a custom element dom-module.html:199 means your app is importing 2 different version of polymer. So when you hit the second version and the first has already been defined in the customElements registry it will deny the second from being added.

@Marshal27
Copy link
Author

Marshal27 commented Jul 15, 2021

Hi Bryan, I really appreciate you taking the time to respond so quickly on this.

I did take a look at the package-lock.json file of my NPM project and there are dependencies loading "@polymer/polymer": "^3.0.0"...

again I appreciate you taking the time to respond/point me in the right direction. The underlying dependencies are too large of a refactor to confirm if that is the issue definitively, but based on your response I suspect this to be the culprit.

@bryandcoulter
Copy link
Collaborator

If you are using polymer 2 and a dependency is using polymer 3 that would cause the issue you are seeing.

@Marshal27
Copy link
Author

Marshal27 commented Jul 15, 2021

Thanks again Bryan for your help.

I was able to confirm that by modifying the src in node_modules to remove all dependencies from the package class and return a hello world template from the render function of the class... the package was imported successfully and the template was rendered.

Sorry for tying you up on this, but truly appreciate your help pinpointing the root issue.

@bryandcoulter
Copy link
Collaborator

No worries, good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants