Skip to content

Commit

Permalink
docs: convert png diagrams to svg (#9208)
Browse files Browse the repository at this point in the history
  • Loading branch information
tony19 committed Jul 21, 2022
1 parent fa97bf3 commit 6adb906
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 4 deletions.
22 changes: 22 additions & 0 deletions docs/.vitepress/theme/components/SvgImage.vue
@@ -0,0 +1,22 @@
<script setup lang="ts">
defineProps<{ svg: string }>()
</script>

<template>
<figure class="svg-image-root" v-html="svg" />
</template>

<style>
.svg-image-root {
background-color: #eee;
border-radius: 8px;
padding: 1ch;
margin: 1ch 0;
}
html.dark .svg-image-root {
background-color: #313641;
}
.svg-image-root svg text {
font-family: var(--vp-font-family-base);
}
</style>
4 changes: 4 additions & 0 deletions docs/.vitepress/theme/index.ts
Expand Up @@ -3,6 +3,7 @@ import Theme from 'vitepress/theme'
import './styles/vars.css'
import HomeSponsors from './components/HomeSponsors.vue'
import AsideSponsors from './components/AsideSponsors.vue'
import SvgImage from './components/SvgImage.vue'

export default {
...Theme,
Expand All @@ -11,5 +12,8 @@ export default {
'home-features-after': () => h(HomeSponsors),
'aside-ads-before': () => h(AsideSponsors)
})
},
enhanceApp({ app }) {
app.component('SvgImage', SvgImage)
}
}
5 changes: 4 additions & 1 deletion docs/guide/features.md
Expand Up @@ -538,7 +538,10 @@ Vite automatically generates `<link rel="modulepreload">` directives for entry c

In real world applications, Rollup often generates "common" chunks - code that is shared between two or more other chunks. Combined with dynamic imports, it is quite common to have the following scenario:

![graph](/images/graph.png)
<script setup>
import graphSvg from '../images/graph.svg?raw'
</script>
<svg-image :svg="graphSvg" />

In the non-optimized scenarios, when async chunk `A` is imported, the browser will have to request and parse `A` before it can figure out that it also needs the common chunk `C`. This results in an extra network roundtrip:

Expand Down
9 changes: 6 additions & 3 deletions docs/guide/why.md
Expand Up @@ -24,9 +24,12 @@ Vite improves the dev server start time by first dividing the modules in an appl

Vite serves source code over [native ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). This is essentially letting the browser take over part of the job of a bundler: Vite only needs to transform and serve source code on demand, as the browser requests it. Code behind conditional dynamic imports is only processed if actually used on the current screen.

![bundler based dev server](/images/bundler.png)

![esm based dev server](/images/esm.png)
<script setup>
import bundlerSvg from '../images/bundler.svg?raw'
import esmSvg from '../images/esm.svg?raw'
</script>
<svg-image :svg="bundlerSvg" />
<svg-image :svg="esmSvg" />

### Slow Updates

Expand Down
Binary file removed docs/images/bundler.png
Binary file not shown.
37 changes: 37 additions & 0 deletions docs/images/bundler.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/diagrams.fig
Binary file not shown.
Binary file removed docs/images/esm.png
Binary file not shown.
51 changes: 51 additions & 0 deletions docs/images/esm.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/graph.png
Binary file not shown.
16 changes: 16 additions & 0 deletions docs/images/graph.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6adb906

Please sign in to comment.