Expected Behaviour
I should be able to use SWC in two different javascript bundles from a single page.
Actual Behaviour
We get errors when customElements.define is called and I cannot see any way around it.
Reproduce Scenario (including but not limited to)
Build two different code bundles that include SWC components. Try to load them into the same page.
Steps to Reproduce
Unpack the sample code below and then do:
yarn install
yarn build
open index.html
Platform and Version
Sample Code that illustrates the problem
swc-collision.zip
Logs taken while reproducing problem
Console logs:
Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': the name "sp-icon" has already been used with this registry
at eval (webpack:///./node_modules/@spectrum-web-components/icon/sp-icon.js?:15:16)
at Module../node_modules/@spectrum-web-components/icon/sp-icon.js (file:///Users/mitaylor/Scratch/swc-collision/dist/library_b.js:889:1)
at __webpack_require__ (file:///Users/mitaylor/Scratch/swc-collision/dist/library_b.js:20:30)
at eval (webpack:///./node_modules/@spectrum-web-components/dropdown/src/Dropdown.js?:13:98)
at Module../node_modules/@spectrum-web-components/dropdown/src/Dropdown.js (file:///Users/mitaylor/Scratch/swc-collision/dist/library_b.js:865:1)
at __webpack_require__ (file:///Users/mitaylor/Scratch/swc-collision/dist/library_b.js:20:30)
at eval (webpack:///./node_modules/@spectrum-web-components/dropdown/sp-dropdown.js?:2:74)
at Module../node_modules/@spectrum-web-components/dropdown/sp-dropdown.js (file:///Users/mitaylor/Scratch/swc-collision/dist/library_b.js:853:1)
at __webpack_require__ (file:///Users/mitaylor/Scratch/swc-collision/dist/library_b.js:20:30)
at eval (webpack:///./library_b.js?:3:103)
Expected Behaviour
I should be able to use SWC in two different javascript bundles from a single page.
Actual Behaviour
We get errors when
customElements.defineis called and I cannot see any way around it.Reproduce Scenario (including but not limited to)
Build two different code bundles that include SWC components. Try to load them into the same page.
Steps to Reproduce
Unpack the sample code below and then do:
Platform and Version
Sample Code that illustrates the problem
swc-collision.zip
Logs taken while reproducing problem
Console logs: