-
Notifications
You must be signed in to change notification settings - Fork 156
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
Web Components throw exception when imported in SvelteKit #11926
Comments
Have you tried setting |
Also facing the same issue. error
+page.svelte
package.json
svelte config
vite config
|
I don't think this is an issue with this repository, but rather with how your application is resolving "@carbon/web-components/es/components/dropdown/index.js". If I modify that to a relative URL it works <script>
// import '@carbon/web-components/es/components/dropdown/index.js';
import "../../node_modules/@carbon/web-components/es/components/dropdown/index.js";
</script>
<cds-dropdown value="bar">
<cds-dropdown-item value="foo">Foo</cds-dropdown-item>
<cds-dropdown-item value="bar">Bar</cds-dropdown-item>
<cds-dropdown-item value="baz">Baz</cds-dropdown-item>
</cds-dropdown> |
Seems like adding the "alias" key to your svelte config could simplify this process as well. const config = {
kit: {
adapter: adapter(),
alias: {
"@carbon": "./node_modules/@carbon"
}
},
preprocess: vitePreprocess()
};
export default config; |
Thank you @andy-blum |
Discussed in carbon-design-system/carbon#16897
Originally posted by x80486 June 28, 2024
I'm working on a Svelte application. The issue I'm having is when I'm trying to integrate the Carbon Web Components module, not the Carbon Components Svelte.
I installed the module using
npm install --save @carbon/web-components
— and generated the SvelteKit application using the default method (npm create svelte@latest my-app
).However, I'm encountering the following error when I try to import any component:
I understand the nature of the error, but I'm almost sure I have everything configured correctly on my end. This is how I'm using/importing the components:
What else do I need to configure in the application to use ES modules with Carbon Design System components? Any help or pointers would be greatly appreciated.
The text was updated successfully, but these errors were encountered: