How misterxiaotan/vue3-lesson works
Project type and purpose
• This is a monorepo library/tooling project that incrementally re-implements Vue 3.4’s reactivity system.
• Its focus is on core Vue features (reactive, ref, watch, watchEffect) in a monorepo structure, bundled via esbuild for in-browser demos.
File structure
• Top-level:
• pnpm-workspace.yaml & pnpm-lock.yaml → pnpm monorepo setup
• package.json & .npmrc → root dependencies/config
• tsconfig.json → shared TS settings
• scripts/dev.js → development server / build script using esbuild
• packages/
• reactivity/
– src/… (baseHandler.ts, effect.ts, reactive.ts, ref.ts, track.ts, notify.ts) → core reactive engine
– dist/… (built html, js, maps) → output artifacts
– package.json → declares the reactivity package
• shared/
– src/index.ts → utility code shared across packages
– package.json
• node_modules/ → installed dependencies for workspace
README
• Describes project goal (incrementally implement Vue 3.4 features)
• Lists v0.1.0 scope: reactive, ref, watch, watchEffect
• Startup: pnpm dev → runs scripts/dev.js (esbuild with HMR) → outputs to each package’s dist → demo HTML
Main components
a. Development & build layer
• scripts/dev.js
• esbuild (watch + HMR)
b. Monorepo workspace
• packages/shared (utilities)
• packages/reactivity (core reactivity engine)
c. Build output
• dist/ (per-package demo HTML + bundled JS)
d. Runtime (browser)
• Demo HTML loads bundled JS → user invokes reactive APIs
e. External tools
• pnpm (workspace management)
• TypeScript compiler (via tsconfig)
Relationships & data flow
• File change → scripts/dev.js → esbuild rebuild → updates dist/reactivity/reactivity.js → browser HMR reload
• At runtime: user code calls reactive()/ref() → Proxy handlers (baseHandler) → track()/notify() → effect execution
• shared module exports helpers imported by reactivity
Architectural patterns & principles
• Monorepo modularization (pnpm workspaces)
• Package-per-feature (reactivity, shared, future packages)
• Layered build pipeline (TS → esbuild → dist)
• Reactive pattern: observer-subscriber via track/notify
Technologies & frameworks
• TypeScript
• esbuild (bundler + HMR)
• pnpm (monorepo)
• Native ES Proxy for reactivity
Diagramming recommendations
• Use clear labels for each component (e.g., “Reactive Engine”, “Shared Utils”, “Dev Server / esbuild”)
• File change → Dev Server → Bundler → Dist artifacts → Browser
• runtime calls: Consumer Code → reactive() → Proxy → track/notify → effect callbacks
• Blue for tooling (pnpm, esbuild, scripts)
• Green for packages/modules (shared, reactivity)
• Orange for runtime/browser