-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
Sveltekit integration: is not a valid SSR component #595
Comments
Try installing it as a direct dependency, not a development dependency. |
Interesting. Add it as direct dependency now leads to below error: But if I build and start (npm run ...), then solution works..??!! |
You might need to clear the cache (rm -rf .svelte build) and restart the |
So I removed cache but error still happened.
|
@myangga Perfect, thank you – I was able to reproduce the error. It appears that Therefore, you will need to instruct vite to pre-bundle it. In your svelte.config.js, can you add // svelte.config.cjs
const node = require('@sveltejs/adapter-node');
const pkg = require('./package.json');
module.exports = {
kit: {
adapter: node(),
target: '#svelte',
vite: {
+ optimizeDeps: {
+ include: ['clipboard-copy']
+ },
ssr: {
noExternal: Object.keys(pkg.dependencies || {})
}
}
}
};
|
Awesome! Many thanks @metonym it works. |
I included some more details about this in vitejs/vite#3024 |
Thank you so much @metonym you saved my day! :D |
It is no longer necessary to instruct vite to optimize The Instead, Note: the Overriding default copy behaviorOverride the default functionality through the <script>
import copy from "clipboard-copy";
import { CopyButton } from "carbon-components-svelte";
</script>
<CopyButton text="hello" copy={text => copy(text)} /> Preventing default copy behaviorPass a "no-op" empty function to prevent the component from copying text at all. <script>
import { CopyButton } from "carbon-components-svelte";
</script>
<CopyButton text="hello" copy={() => {}} /> |
I still see this same error, with Sapper and Carbon components svelte version 0.39. It works with 0.26. I've removed the dev dependency and re-added carbon 0.39 as direct dependency, but the problem persists. As dev dependency: |
@benbucksch Can you provide the following so that I can reproduce the error?
|
We got <Seo /> is not a valid SSR component. carbon-design-system/carbon-components-svelte#595
Juts started new project with Sveltekit, then installed Carbon components with
npm i -D carbon-components-svelte --save
Then started to code header
Then run the project and get:
Error: <Header> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules
Of course I kept node adapter on vite config.
Should I use static only?
The text was updated successfully, but these errors were encountered: