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

Issues with using component libraries in sveltejs/kit #885

Closed
henryennis opened this issue Apr 5, 2021 · 2 comments
Closed

Issues with using component libraries in sveltejs/kit #885

henryennis opened this issue Apr 5, 2021 · 2 comments

Comments

@henryennis
Copy link

henryennis commented Apr 5, 2021

SSR is disabled inline, which bypasses the components not being SSR incompatible.

The node module clipboard-copy is used in the UI library as a depend

This is the error I am getting in my sveltekit page.

500
The requested module '/node_modules/clipboard-copy/index.js?v=3f0aa85f' does not provide an export named 'default'

SyntaxError: The requested module '/node_modules/clipboard-copy/index.js?v=3f0aa85f' does not provide an export named 'default'

Index.svelte

<script context="module">
	export const ssr = false;
</script>


<script>
	import { Button } from "carbon-components-svelte";
  </script>
  
  <Button>Primary button</Button>
@henryennis henryennis changed the title Issue with using carbon components svelte UI kit Issues with using component libraries in sveltejs/kit Apr 5, 2021
@GrygrFlzr
Copy link
Member

Please use the discord for support.

carbon-components-svelte is not SSR-incompatible.

<!-- src/$layout.svelte -->
<script>
  import 'carbon-components-svelte/css/g100.css';
  import '../app.css';
</script>

<slot />
<!-- src/routes/index.svelte -->
<script>
  import { Accordion, AccordionItem } from 'carbon-components-svelte';
</script>

<!-- ... -->
// svelte.config.cjs
// ...
module.exports = {
  kit: {
    // ...
    vite: {
      // ...
      optimizeDeps: {
        include: ['carbon-components-svelte', 'clipboard-copy']
      }
    }
  }
};

@henryennis
Copy link
Author

@GrygrFlzr Thank you for this, I was just reading the vite docs and figured I needed to use these params.

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