Skip to content

svelte rollup plugin generates multiple customelement definitions #1884

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

Closed
GeorgeTailorZooPlus opened this issue Dec 19, 2018 · 1 comment
Closed

Comments

@GeorgeTailorZooPlus
Copy link

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.

@Rich-Harris
Copy link
Member

Thanks. I'm going to close this in favour of #2417 — I don't think it's helpful to silently fail to register an element if the same tag has already been used, so it this is happening then a better solution is to give app authors the ability to choose tags at runtime.

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