-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
[vite-plugin-svelte] prebundle libraries / ssr compile stats show large numbers #1561
Comments
It may be worth thinking about how |
carbon icons are also available via unplugin-icons, so if you can build a config for that that works out to a similar interface as the current carbon-icons-svelte package, carbon-icons-svelte would no longer be needed as a separate package and instead users projects would only compile/bundle the icons they actually use. Kind of like deep imports without the extra package. // vite.config.js
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte' // or sveltekit
import Icons from 'unplugin-icons/vite'
export default defineConfig({
plugins: [
svelte(), // or sveltekit
Icons({
compiler: 'svelte',
// TODO: add extra config here so compiled icon is similar to what carbon-icons-svelte has now
}),
],
}) <script>
import IconAccessibility from '~icons/carbon/accessibility'
</script>
<IconAccessibility/> |
I'm not a big fan of the |
you don't. you add a dependency on an iconify library, basically a json file with all svgs. it's just a bit clever glue to turn that json into a svelte component on demand |
I ran some somewhat-scientific tests and here is what I've uncovered:
This is concerning since Carbon v11's de facto styles involve SCSS exclusively. I haven't measured Carbon v11 React, so I'm unsure how things perform there. Below are my test results. There were some inconsistencies:
Test project: https://stackblitz.com/edit/sveltejs-kit-template-default-upbce6?file=src%2Fapp.scss,src%2Froutes%2F%2Bpage.svelte On Stackblitz
Locally on 2015 Macbook Pro, on battery
Is there a way for us to improve performance when SCSS is involved? Perhaps there's a more efficient usage of SCSS that I've overlooked in the test project linked above. |
@theetrain would it be possible for you to preprocess the library and distribute just CSS? That's what we typically recommend svelte libraries to do and I believe if you use |
This is not a bug in carbon-components-svelte, posting here for visibility and as a heads-up for the maintainers and users.
In version 1.3.0 , vite-plugin-svelte is going to enable prebundling for svelte dependencies during dev by default.
Alongside, it is going to log compile statistics so users can understand where time is spent.
For a sveltekit application with
carbon-components-svelte
andcarbon-icons-svelte
this can look likeand delay initial page load of the dev-server by multiple seconds.
Using the optimizeImports preprocessor in combination with prebundling can make it a lot worse even.
For using carbon with vite-plugin-svelte 1.3+ it is recommended to either not use
optimizeImports
and stick to one import style or exclude carbon from optimizeDeps as described in the vite-plugin-svelte FAQThe text was updated successfully, but these errors were encountered: