The CustomElementRegistry already contains an entry with the same name

Hi all,

when I try to integrate the Spectrum Web Component “Toast”, I get the following error message. I also had this with “Tags”.

uxp://uxp-internal/domjs_scripts.js:2 
Uncaught r_message: "The CustomElementRegistry already contains an entry with the same name."
_name: "NotSupportedError"code: (...)message: (...)name: (...)stack: "NotSupportedError: The CustomElementRegistry already contains an entry with the same name.\n    at uxp://uxp-internal/domjs_scripts.js:2:61780\n    at u (uxp://uxp-internal/domjs_scripts.js:2:61882)\n    at Object.define (uxp://uxp-internal/domjs_scripts.js:2:62442)\n    at node_modules/@spectrum-web-components/icons-ui/icons/sp-icon-cross75.js (./main.js:10471:20)\n    at __init (./main.js:9:56)\n    at node_modules/@swc-uxp-internal/toast/node_modules/@spectrum-web-components/button/src/CloseButton.js (./main.js:10644:5)\n    at __init (./main.js:9:56)\n    at node_modules/@swc-uxp-internal/toast/node_modules/@spectrum-web-components/button/sp-close-button.js (./main.js:10697:5)\n    at __init (./main.js:9:56)\n    at node_modules/@swc-uxp-internal/toast/src/Toast.js (./main.js:11104:5)"[[Prototype]]: Error

Imported Spectrum Web Compontents:

require("@spectrum-web-components/theme/sp-theme.js");
require("@spectrum-web-components/theme/src/themes.js");
require("@swc-uxp-wrappers/action-button/sp-action-button.js");
require("@swc-uxp-wrappers/toast/sp-toast.js");

Node modules:

According to the documentation, sp-toast should be fully supported in InDesign: https://developer.adobe.com/indesign/uxp/reference/uxp-api/reference-spectrum/swc/

How does this name conflict come about? Does anyone have any idea why?

Roland

Have had a similar problem. In my case, it happened when I was installing with npm even though yarn is recommended.

Once removed the node_modules folder and re-installed everything with yarn, it worked fine.

1 Like

Thanks for the tip! I will try yarn and give feedback.

Roland

1 Like

With yarn, different versions of the SWC are imported in some cases. Unfortunately, it still does not work.

This is probably due to the icons. If I comment out the lines with e.g. customElements.define(“sp-icon-cross75”, IconCross75) in the bundled script, the error disappears. They are registered twice with the same name. But that is not a solution either.

Roland

1 Like

Unfortunately that is all the solution I know.