Description
I have many small modules which are packed as separate custom elements with svelte-rollup-plugin. Eg:
plugins: [
svelte({
skipIntroByDefault: true,
nestedTransitions: true,
dev: !production,
cascade: false,
customElement: true
}),
resolve(),
commonjs(),
production && terser()
]
Now I have a separate module for links, which contains one element Link.html
, which I planned to use as a standalone element and in other modules as well. For example (this is inside a component called Input.html
):
...
<Link text="{linktext}" target="{linktarget}" href="{linkhref}" />
...
<script>
export default {
tag: 'input-el',
...
components: {
Link: "../../link-module/src/Link.html"
}
};
</script>
Similar thing I do in other elements. Now each module is built separately, and when I import them one by one in other application, for example in my app.module.ts
in angular app:
import '../../node_modules/@company/input-module';
import '../../node_modules/@company/link-module';
I get the following error in the console:
Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry
Can someone tell me if it's a bug in svelte compiler ? I would expect those elements to check if they are not defined yet, and only then add themselves into the registry.
Btw, when testing it as if it was built as a single module it seems to work. So that's a potential workaround for now.