Skip to content

Commit 6892e3b

Browse files
authored
feat: hot path 🔥🦆 (#637)
1 parent ab71c44 commit 6892e3b

12 files changed

Lines changed: 944 additions & 0 deletions

book/online-book/.vitepress/config/en.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,32 @@ export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
394394
text: "Appendix",
395395
collapsed: false,
396396
items: [
397+
{
398+
text: "Hot Paths",
399+
collapsed: false,
400+
items: [
401+
{
402+
text: "Overview",
403+
link: "/bonus/hot-paths/",
404+
},
405+
{
406+
text: "Beginner 30-minute hands-on",
407+
link: "/bonus/hot-paths/beginner-30-min-hands-on",
408+
},
409+
{
410+
text: "Beginner 60-minute hands-on",
411+
link: "/bonus/hot-paths/beginner-60-min-hands-on",
412+
},
413+
{
414+
text: "Intermediate 60-minute hands-on",
415+
link: "/bonus/hot-paths/intermediate-60-min-hands-on",
416+
},
417+
{
418+
text: "Advanced 30-minute summary",
419+
link: "/bonus/hot-paths/advanced-30-min-summary",
420+
},
421+
],
422+
},
397423
{
398424
text: "Writing Vue.js in 15 minutes.",
399425
collapsed: false,

book/online-book/.vitepress/config/ja.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,32 @@ export const jaConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
391391
text: "付録",
392392
collapsed: false,
393393
items: [
394+
{
395+
text: "Hot Paths",
396+
collapsed: false,
397+
items: [
398+
{
399+
text: "概要",
400+
link: "/ja/bonus/hot-paths/",
401+
},
402+
{
403+
text: "初心者向け 30 分ハンズオン",
404+
link: "/ja/bonus/hot-paths/beginner-30-min-hands-on",
405+
},
406+
{
407+
text: "初心者向け 1 時間ハンズオン",
408+
link: "/ja/bonus/hot-paths/beginner-60-min-hands-on",
409+
},
410+
{
411+
text: "中級者向け 1 時間ハンズオン",
412+
link: "/ja/bonus/hot-paths/intermediate-60-min-hands-on",
413+
},
414+
{
415+
text: "上級者向け 30 分サマリ",
416+
link: "/ja/bonus/hot-paths/advanced-30-min-summary",
417+
},
418+
],
419+
},
394420
{
395421
text: "15 分で Vue を作る",
396422
collapsed: false,
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Advanced 30-minute summary
2+
3+
::: warning AI-generated appendix
4+
This appendix was drafted with GPT-5.5 from the original chibivue book content. Treat this route as a guided learning path; the original chapters and implementation code remain the source of truth.
5+
:::
6+
7+
This is a compressed map for readers who want the whole book in one pass before reading source code. Spend about one minute per checkpoint. If a checkpoint is obvious, move on. If it is fuzzy, open the linked chapter.
8+
9+
## 30 checkpoints
10+
11+
1. [The book starts from one line of rendering](/00-introduction/010-about): the point is not to clone Vue perfectly, but to rebuild the ideas by hand.
12+
2. [Vue's core pieces](/00-introduction/030-vue-core-components): runtime, renderer, reactivity, compiler, and SFC tooling are separate concerns.
13+
3. [Project setup](/00-introduction/040-setup-project): package boundaries make the learning path visible.
14+
4. [createApp](/10-minimum-example/010-create-app-api): the app API wraps mounting and gives users one entry point.
15+
5. [Package architecture](/10-minimum-example/015-package-architecture): runtime-core stays platform-neutral; runtime-dom owns browser operations.
16+
6. [h and VNode](/10-minimum-example/020-simple-h-function): render output is a data structure, not DOM.
17+
7. [Events and attributes](/10-minimum-example/025-event-handler-and-attrs): DOM patching needs platform-specific prop handling.
18+
8. [Minimum reactivity](/10-minimum-example/035-try-implementing-a-minimum-reactivity-system): Proxy read means track; Proxy write means trigger.
19+
9. [Minimum Virtual DOM](/10-minimum-example/040-minimum-virtual-dom): patch compares old and new VNodes to update the DOM.
20+
10. [Minimum components](/10-minimum-example/050-minimum-component): a component VNode mounts by creating an instance and running render.
21+
11. [Props](/10-minimum-example/051-component-props): parent data crosses into child components through normalized inputs.
22+
12. [Emits](/10-minimum-example/052-component-emits): child events are just conventionally named parent handlers.
23+
13. [Template compiler overview](/10-minimum-example/060-template-compiler): templates become render functions.
24+
14. [Compiler implementation](/10-minimum-example/061-template-compiler-impl): parse, transform, and codegen form the core compiler pipeline.
25+
15. [Template binding](/10-minimum-example/080-template-binding): compiler output must read values from render context.
26+
16. [SFC parse](/10-minimum-example/091-parse-sfc): `.vue` files are split into script, template, and style blocks.
27+
17. [SFC template/script/style](/10-minimum-example/092-compile-sfc-template): a Vite plugin wires SFC transforms into development.
28+
18. [Keyed patching](/20-basic-virtual-dom/010-patch-keyed-children): stable keys let the renderer move and reuse children.
29+
19. [Shape flags](/20-basic-virtual-dom/020-bit-flags): bit flags make repeated type checks cheap.
30+
20. [Scheduler](/20-basic-virtual-dom/030-scheduler): reactive changes enqueue work so repeated updates can be batched.
31+
21. [ref, computed, watch](/30-basic-reactivity-system/010-ref-api): reactivity grows from objects into value containers and user-facing effects.
32+
22. [Reactive proxy handlers](/30-basic-reactivity-system/030-reactive-proxy-handlers): collections, refs, readonly values, and shallow values need handler nuance.
33+
23. [Effect cleanup and scope](/30-basic-reactivity-system/040-effect-scope): effects need lifecycle management, not just reruns.
34+
24. [Component lifecycle](/40-basic-component-system/010-lifecycle-hooks): component instances give the runtime places to call user hooks.
35+
25. [Provide/Inject and setup context](/40-basic-component-system/020-provide-inject): component trees need structured dependency and context channels.
36+
26. [Slots](/40-basic-component-system/040-component-slot): children can be passed as lazy render functions.
37+
27. [Template transforms](/50-basic-template-compiler/010-transform): directives are compiler plugins that turn syntax into VNode data.
38+
28. [Structural directives](/50-basic-template-compiler/040-v-if-and-structural-directive): `v-if`, `v-for`, fragments, comments, and slots shape the generated tree.
39+
29. [SFC compiler macros](/60-basic-sfc-compiler/010-script-setup): `script setup`, `defineProps`, `defineEmits`, scoped CSS, and type-based macros are compile-time conveniences.
40+
30. [Application essentials and optimizations](/90-web-application-essentials/010-plugins/010-router): router, store, SSR, built-ins, static hoisting, patch flags, tree flattening, and Vapor Mode show how the same core ideas scale.
41+
42+
## After the summary
43+
44+
Read one source path without stopping:
45+
46+
```txt
47+
packages/reactivity -> packages/runtime-core -> packages/runtime-dom -> packages/compiler-core -> packages/compiler-sfc
48+
```
49+
50+
Then read [Debugging the original source code](/bonus/debug-vuejs-core) and compare chibivue's simplified choices with `vuejs/core`.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Beginner 30-minute hands-on
2+
3+
::: warning AI-generated appendix
4+
This appendix was drafted with GPT-5.5 from the original chibivue book content. Treat this route as a guided learning path; the original chapters and implementation code remain the source of truth.
5+
:::
6+
7+
This route is for getting one small, satisfying loop: create an app, render a button, update state, and see why a compiler is useful. It follows the spirit of [Writing Vue.js in 15 minutes](/bonus/hyper-ultimate-super-extreme-minimal-vue/) but gives you more breathing room.
8+
9+
## Goal
10+
11+
By the end, you should be able to explain this chain:
12+
13+
```txt
14+
createApp -> render function -> VNode -> patch -> reactive state -> effect -> rerender
15+
```
16+
17+
You do not need to understand every edge case. The goal is to see the moving parts touch each other.
18+
19+
## 0-5 min: prepare the tiny mental model
20+
21+
Read:
22+
23+
- [chibivue, isn't it small...?](/bonus/hyper-ultimate-super-extreme-minimal-vue/)
24+
- [Project Setup](/bonus/hyper-ultimate-super-extreme-minimal-vue/15-min-impl#project-setup-0-5-min)
25+
26+
Do:
27+
28+
- Create or open a chibivue playground project.
29+
- Find the file that exports the tiny Vue-like API, usually `packages/index.ts`.
30+
- Keep one rule in mind: every feature in this route can be intentionally naive.
31+
32+
Checkpoint:
33+
34+
- You know where the public API, renderer, reactivity, and compiler code will live, even if they are all in one file.
35+
36+
## 5-10 min: createApp and h
37+
38+
Read:
39+
40+
- [createApp](/bonus/hyper-ultimate-super-extreme-minimal-vue/15-min-impl#createapp-1-min)
41+
- [h Function and Virtual DOM](/bonus/hyper-ultimate-super-extreme-minimal-vue/15-min-impl#h-function-and-virtual-dom-0-5-min)
42+
- Optional deeper chapter: [First Rendering and the createApp API](/10-minimum-example/010-create-app-api)
43+
44+
Do:
45+
46+
- Write or inspect a `createApp` function that accepts `setup` and `render`.
47+
- Write or inspect an `h` function that returns a plain object.
48+
- Make sure the VNode includes only what the demo needs: tag, event, and children.
49+
50+
Checkpoint:
51+
52+
- You can say why Vue renders an object first instead of directly writing DOM code everywhere.
53+
54+
## 10-17 min: patch the VNode into the DOM
55+
56+
Read:
57+
58+
- [patch rendering](/bonus/hyper-ultimate-super-extreme-minimal-vue/15-min-impl#patch-rendering-2-min)
59+
- Optional deeper chapter: [A Minimal Virtual DOM](/10-minimum-example/040-minimum-virtual-dom)
60+
61+
Do:
62+
63+
- Turn the VNode into an actual DOM element.
64+
- Attach a click handler.
65+
- Insert the element into the container selected by `mount`.
66+
67+
Checkpoint:
68+
69+
- A render function can produce a VNode, and `patch` can make that VNode visible in the browser.
70+
71+
## 17-23 min: make state reactive
72+
73+
Read:
74+
75+
- The reactivity section in [Implement](/bonus/hyper-ultimate-super-extreme-minimal-vue/15-min-impl)
76+
- Optional deeper chapter: [Try Implementing a Small Reactivity System](/10-minimum-example/035-try-implementing-a-minimum-reactivity-system)
77+
78+
Do:
79+
80+
- Inspect the dependency store: which effect depends on which property?
81+
- Update state from the click handler.
82+
- Confirm that the render effect runs again when state changes.
83+
84+
Checkpoint:
85+
86+
- You can describe `track` as "remember who read this" and `trigger` as "rerun who cared about this."
87+
88+
## 23-28 min: replace manual render with template
89+
90+
Read:
91+
92+
- The compiler and SFC sections in [Implement](/bonus/hyper-ultimate-super-extreme-minimal-vue/15-min-impl)
93+
- Optional deeper chapters: [Understanding the Template Compiler](/10-minimum-example/060-template-compiler), [Parse SFC](/10-minimum-example/091-parse-sfc)
94+
95+
Do:
96+
97+
- Inspect how a tiny template becomes a render function.
98+
- Keep the compiler intentionally narrow: one button, one event, one interpolation is enough.
99+
100+
Checkpoint:
101+
102+
- You can explain that the compiler is not a separate magic system. It creates the render function that the runtime already knows how to run.
103+
104+
## 28-30 min: close the loop
105+
106+
Answer these aloud or in notes:
107+
108+
- What object does `h` return?
109+
- Who calls `patch`?
110+
- What makes `render` run again?
111+
- Why does SFC support need a Vite plugin in this tiny implementation?
112+
113+
Next path:
114+
115+
- If this felt good, continue with [Beginner 60-minute hands-on](./beginner-60-min-hands-on).
116+
- If the code felt too dense, read [First Rendering and the createApp API](/10-minimum-example/010-create-app-api) slowly before continuing.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Beginner 60-minute hands-on
2+
3+
::: warning AI-generated appendix
4+
This appendix was drafted with GPT-5.5 from the original chibivue book content. Treat this route as a guided learning path; the original chapters and implementation code remain the source of truth.
5+
:::
6+
7+
This route walks through the original Minimum Example without trying to absorb every explanation. You will touch the main shape of a Vue-like framework: application API, renderer, reactivity, components, template compiler, and SFC support.
8+
9+
## Goal
10+
11+
By the end, you should understand why chibivue is split into packages and how a `.vue` file eventually becomes DOM updates.
12+
13+
## 0-8 min: project shape
14+
15+
Read:
16+
17+
- [Approach in This Book and Setting Up the Environment](/00-introduction/040-setup-project)
18+
- [Package Architecture](/10-minimum-example/015-package-architecture)
19+
20+
Do:
21+
22+
- Locate `packages/runtime-core`, `packages/runtime-dom`, `packages/reactivity`, `packages/compiler-core`, `packages/compiler-dom`, and `packages/compiler-sfc` in an implementation snapshot under `book/impls`.
23+
- Write down one sentence for each package: what problem does it own?
24+
25+
Checkpoint:
26+
27+
- You can tell runtime code apart from compiler code.
28+
29+
## 8-18 min: first render
30+
31+
Read:
32+
33+
- [First Rendering and the createApp API](/10-minimum-example/010-create-app-api)
34+
- [Let's Enable Rendering HTML Elements](/10-minimum-example/020-simple-h-function)
35+
- [Let's work on supporting event handlers and attributes.](/10-minimum-example/025-event-handler-and-attrs)
36+
37+
Do:
38+
39+
- Follow how `createApp(...).mount(...)` reaches the renderer.
40+
- Find where an element is created.
41+
- Find where props or event handlers are applied.
42+
43+
Checkpoint:
44+
45+
- You can trace one button from render function to real DOM.
46+
47+
## 18-28 min: first reactivity
48+
49+
Read:
50+
51+
- [Prerequisite Knowledge for the Reactivity System](/10-minimum-example/030-prerequisite-knowledge-for-the-reactivity-system)
52+
- [Try Implementing a Small Reactivity System](/10-minimum-example/035-try-implementing-a-minimum-reactivity-system)
53+
54+
Do:
55+
56+
- Identify where an active effect is stored.
57+
- Identify where property reads are tracked.
58+
- Identify where property writes trigger effects.
59+
60+
Checkpoint:
61+
62+
- You understand why reactive state needs both a Proxy and an effect function.
63+
64+
## 28-40 min: VNode and components
65+
66+
Read:
67+
68+
- [A Minimal Virtual DOM](/10-minimum-example/040-minimum-virtual-dom)
69+
- [Aspiring for Component-Oriented Development](/10-minimum-example/050-minimum-component)
70+
- [Component Props](/10-minimum-example/051-component-props)
71+
- [Component Emit](/10-minimum-example/052-component-emits)
72+
73+
Do:
74+
75+
- Compare an element VNode with a component VNode.
76+
- Find where component `setup` is called.
77+
- Find how props enter a component and how emit leaves it.
78+
79+
Checkpoint:
80+
81+
- You can explain why components are also represented as VNodes.
82+
83+
## 40-52 min: template compiler
84+
85+
Read:
86+
87+
- [Understanding the Template Compiler](/10-minimum-example/060-template-compiler)
88+
- [Implementing the Template Compiler](/10-minimum-example/061-template-compiler-impl)
89+
- [Data Binding](/10-minimum-example/080-template-binding)
90+
91+
Do:
92+
93+
- Trace the pipeline: template string, parse result, generated render function.
94+
- Find where interpolation like `{{ count }}` becomes code.
95+
96+
Checkpoint:
97+
98+
- You can say what the compiler produces and why the runtime can execute it.
99+
100+
## 52-60 min: SFC support
101+
102+
Read:
103+
104+
- [Developing with SFC (Peripheral Knowledge)](/10-minimum-example/090-prerequisite-knowledge-for-the-sfc)
105+
- [Parse SFC](/10-minimum-example/091-parse-sfc)
106+
- [SFC template block](/10-minimum-example/092-compile-sfc-template)
107+
- [SFC script block](/10-minimum-example/093-compile-sfc-script)
108+
- [SFC style block](/10-minimum-example/094-compile-sfc-style)
109+
110+
Do:
111+
112+
- Identify the three blocks of an SFC.
113+
- Find which block becomes render code.
114+
- Find which block becomes component options.
115+
- Find which block becomes CSS.
116+
117+
Checkpoint:
118+
119+
- You can describe `.vue` as a convenient authoring format that is split and transformed before the runtime sees it.
120+
121+
## Stop here
122+
123+
You now have the skeleton. The best next move is not to rush into every advanced feature. Pick one part that felt most surprising and read its full original chapter again.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Hot Paths
2+
3+
::: warning AI-generated appendix
4+
This appendix was drafted with GPT-5.5 from the original chibivue book content. Treat these routes as guided learning paths; the original chapters and implementation code remain the source of truth.
5+
:::
6+
7+
chibivue is intentionally incremental, but that also makes it large. This appendix gives you shorter routes through the book when you want to learn the core ideas before reading everything in order.
8+
9+
Each route tells you what to read, what to implement or inspect, and when to stop. If a route feels too fast, jump to the linked original chapter and come back when the missing piece clicks.
10+
11+
## Routes
12+
13+
| Route | Time | Audience | You will understand |
14+
| --- | --- | --- | --- |
15+
| [Beginner 30-minute hands-on](./beginner-30-min-hands-on) | 30 min | First-time readers who want the smallest possible win | How `createApp`, VNode rendering, reactivity, and a tiny compiler connect |
16+
| [Beginner 60-minute hands-on](./beginner-60-min-hands-on) | 60 min | Beginners who can spend one focused session | The full Minimum Example flow, from first render to SFC |
17+
| [Intermediate 60-minute hands-on](./intermediate-60-min-hands-on) | 60 min | Readers who already know Vue or TypeScript | The runtime and compiler paths that make component updates work |
18+
| [Advanced 30-minute summary](./advanced-30-min-summary) | 30 min | Readers who want a compressed map before source reading | The whole book as 30 checkpoints |
19+
20+
## How to use these paths
21+
22+
1. Keep the original chapter open beside the route.
23+
2. Time-box each section. Finishing the whole route matters less than preserving the big picture.
24+
3. Use the implementation snapshots under `book/impls` when you want to compare your mental model with working code.
25+
4. After a route, choose one original chapter and read it slowly. The hot path is the map, not the territory.
26+
27+
## Source sections covered
28+
29+
- [Getting Started](/00-introduction/010-about)
30+
- [Minimum Example](/10-minimum-example/010-create-app-api)
31+
- [Basic Virtual DOM](/20-basic-virtual-dom/010-patch-keyed-children)
32+
- [Basic Reactivity System](/30-basic-reactivity-system/005-reactivity-optimization)
33+
- [Basic Component System](/40-basic-component-system/010-lifecycle-hooks)
34+
- [Basic Template Compiler](/50-basic-template-compiler/010-transform)
35+
- [Basic SFC Compiler](/60-basic-sfc-compiler/010-script-setup)
36+
- [Web Application Essentials](/90-web-application-essentials/010-plugins/010-router)
37+
- [Writing Vue.js in 15 minutes](/bonus/hyper-ultimate-super-extreme-minimal-vue/)

0 commit comments

Comments
 (0)