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

svelte:options customElement #56

Open
BigBuckBunny opened this issue Oct 10, 2023 · 9 comments
Open

svelte:options customElement #56

BigBuckBunny opened this issue Oct 10, 2023 · 9 comments

Comments

@BigBuckBunny
Copy link

Hi,

A compile error is generated with version 11:

[vite-plugin-svelte] /node_modules/@beyonk/gdpr-cookie-consent-banner/src/lib/Ba
nner.svelte:1:16 The 'customElement' option is used when generating a custom element. Did you forget the 'customElement: true' compile option
?
1: <svelte:options customElement="cookie-consent-banner" />

To resolve this, I had to include in my svelte.config.js the following:

compilerOptions: {
customElement: true,
},

It does not seem right that I have to mod my config to compile.

Thanks,

Pierre

@antony
Copy link
Member

antony commented Oct 10, 2023

is it an error or a warning?

a bit annoying, but if we want to publish the banner as a WebComponent too, we need to include that. I'm not sure there is a way around it.

@BigBuckBunny
Copy link
Author

Hi,

Sorry it was a warning.

Might I suggest appending to your Svelte example the modification to svelte.config.js in the Readme.md.

Thanks for the update,

Pierre

@antony
Copy link
Member

antony commented Oct 12, 2023

It says in the warning what you need to do, so not sure this is necessary.

I feel like this is an issue within the way Svelte works, since you don't actually want custom element output in a regular svelte project.

the compiler should know that you're seeing the options tag in a project dependency, not the main project, and not warn.

i'll raise an issue with Svelte (or you can)

@stalkerg
Copy link

stalkerg commented Nov 5, 2023

@antony did you make an issue?

@antony
Copy link
Member

antony commented Nov 5, 2023 via email

@Cayllen
Copy link

Cayllen commented Nov 28, 2023

Not sure if this is related but I cannot use the cookie banner because of the following issue:
image

@Cayllen
Copy link

Cayllen commented Nov 28, 2023

Actually solved, seems I used an old version of sveltekit

@belte42
Copy link

belte42 commented Feb 12, 2024

Still shows an error on latest sveltekit "@sveltejs/kit": "^2.5.0".
The problem with this is once I add

compilerOptions: {
customElement: true,
},

pre-rendering with static adapter kit breaks and CSS is no longer loaded from Svelte pages and components.

@antony
Copy link
Member

antony commented Feb 12, 2024

@belte42 because you're trying to mark your entire project as a custom element, which won't work. The "did you forget to add" customElement: true warning is just a warning, and can be safely ignored.

If it bothers you a lot, please raise a SvelteKit issue and I'll discuss it with the others and see if I can implement a fix - but at the moment, I don't have time to do it.

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

5 participants