~/talk

Build your own Svelte

Talkat Conf42 JavaScript 2022 · on Thursday, 2022-11-17· [compilers-and-language-design, javascript]
slides:none on file

Builds a tiny Svelte compiler end-to-end in ~40 minutes that turns app.svelte into app.js by parsing the template to an AST with a hand‑written parser, using acorn for JavaScript parsing, periscopic for scope analysis, estree-walker for traversal and escodegen to emit JS. Outputs lifecycle objects with .create/.update/.destroy that mount elements, attach click handlers and update text nodes; demo counter runs in the browser and the generator omits update code for unused values. Code: Mini Svelte on GitHub.

AI-written summary · about

  1. 0:00Introduction
  2. 1:10Speaker introduction
  3. 3:16From jQuery to React and Svelte
  4. 5:01Build your own Svelte
  5. 5:44What is a compiler
  6. 7:30Simplified Svelte output
  7. 9:14Compiler process visualization
  8. 12:23Parsing code to AST
  9. 13:05Syntax with Backus-Naur form
  10. 15:55Parser structure
  11. 17:41Helper functions for parsing
  12. 20:12Parsing script tags and elements
  13. 22:40Parsing attributes and expressions
  14. 24:25Parsing text nodes and AST
  15. 25:29Generating and inspecting AST
  16. 26:33Analyzing variable scopes
  17. 28:41Scope analysis with Periscopic
  18. 30:25Traversing AST with ESTree
  19. 32:29Identifying changing variables
  20. 33:33Tracking template variables
  21. 34:39Analysis and review results
  22. 36:05Generating optimized JavaScript
  23. 37:29Traversing nodes for codegen
  24. 38:13Handling text nodes and attributes
  25. 39:35Processing expressions and updates
  26. 40:38Finalizing generated code
  27. 41:19Dynamic lifecycle updates
  28. 42:24AST to JavaScript conversion
  29. 43:05Testing in browser
  30. 43:48Optimization demo
  31. 45:59Summary
  32. 46:20Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.