Pedro Cattori · @pcattori
Legendary DX
The Quest for
<Link to="the past"/>
🤩
Browser
📚
html, css, js
🫥
📚
🫥
📚
📚
🫥
📚
📚
🤩
📚
📁
Source code
ESM
📁
Source code
ESM
📁
Source code
🤓
Compiler
🫥
🤓
📁
🤓
📁
🫥
📚
🫥
📚
🤓
📁
📚
🫥
📚
📚
🤓
📁
🤩
📚
🤓
📁
🤩
📚
✍️
🤓
📁
👀
📁
🤩
📚
✍️
✍️
🤓
📁
🤩
📚
✍️
✍️
🤓
📁
🤩
📚
✍️
✍️
🤩
📚
✍️
🤓
📁
👀
📁
🤩
📚
✍️
✍️
🤓
📁
🤩
📚
✍️
✍️
🔁
🤩
📚
🤓
📁
🤓
📁
🔁
✍️
✍️
🔁
📚
🤓
📁
🤓
📁
✍️
✍️
🫥
📚
🤓
📁
🤓
📁
📚
✍️
✍️
🫥
📚
🤓
📁
🤓
📁
📚
🤩
📚
🤓
📁
🤓
📁
✍️
🤠
hot-swap.js
🤠
hot-swap.js
(aka HMR runtime)
🫥
🤓
📁
🤓
📁
🫥
📚
🤠
🫥
📚
🤓
📁
📚
🤠
🤠
🫥
📚
📚
🤓
📁
🤠
🤠
🤩
📚
🤓
📁
🤠
🤠
🤩
📚
✍️
🤓
📁
🤠
🤠
👀
📁
🤩
📚
✍️
✍️
🤠
🤠
🤓
📁
🤩
📚
✍️
✍️
✍️
🤠
🤠
🤩
📚
🤓
📁
🤓
📁
✍️
✍️
✍️
🤠
🤠
🤩
📚
🤓
📁
🤓
📁
✍️
✍️
✍️
🔁
🤠
🤩
📚
🤓
📁
🤓
📁
✍️
✍️
✍️
🤠
🤠
😎
App Server
📙
server.js
🤓
🫥
📁
🤓
🫥
📁
📚
📙
🤠
🤓
🫥
📁
📚
📙
🤠
🏃♂️
📙
🤓
🫥
📁
📚
📙
🤠
🏃♂️
📙
🤓
🫥
📁
📚
📙
🤠
😎
localhost:3000
🤓
🫥
📁
📚
📙
🤠
😎
🤓
🫥
📁
📚
📙
🤠
😎
📚
🤠
🤓
🫥
📁
📚
📙
🤠
😎
📚
🤠
{"place": "world"}
🤓
🫥
📁
📚
📙
🤠
😎
📚
🤠
{"place": "world"}
🤓
🤩
📁
📚
📙
🤠
😎
🤠
🌇
{"place": "world"}
import { json } from "@remix-run/node"
import { useLoaderData } from "@remix-run/react"
export let loader = () => {
return json({ place: "world" })
}
export default Component() {
let { place } = useLoaderData<typeof loader>()
return (
<main>
<h1>Hey there, Remix Conf 👋</h1>
<h2>And hello, {place}!</h2>
</main>
)
}
✍️
import { json } from "@remix-run/node"
import { useLoaderData } from "@remix-run/react"
export let loader = () => {
return json({ place: "world" })
}
export default Component() {
let { place } = useLoaderData<typeof loader>()
return (
<main>
<h1>Hey there, friends 👋</h1>
<h2>And hello, {place}!</h2>
</main>
)
}
✍️
import { json } from "@remix-run/node"
import { useLoaderData } from "@remix-run/react"
export let loader = () => {
return json({ location: "Salt Lake City" })
}
export default Component() {
let { place } = useLoaderData<typeof loader>()
return (
<main>
<h1>Hey there, friends 👋</h1>
<h2>And hello, {place}!</h2>
</main>
)
}
✍️
import { json } from "@remix-run/node"
import { useLoaderData } from "@remix-run/react"
export let loader = () => {
return json({ location: "Salt Lake City" })
}
export default Component() {
let { location } = useLoaderData<typeof loader>()
return (
<main>
<h1>Hey there, friends 👋</h1>
<h2>And hello, {location}!</h2>
</main>
)
}
✍️
SAVE
✍️
import { json } from "@remix-run/node"
import { useLoaderData } from "@remix-run/react"
export let loader = () => {
return json({ location: "Salt Lake City" })
}
export default Component() {
let { location } = useLoaderData<typeof loader>()
return (
<main>
<h1>Hey there, friends 👋</h1>
<h2>And hello, {location}!</h2>
</main>
)
}
🤓
🤩
📁
📚
📙
🤠
😎
🤠
🌇
✍️
{"place": "world"}
👀
🤩
📁
📚
📙
🤠
😎
🤠
🌇
✍️
✍️
✍️
{"place": "world"}
🤓
🤩
📁
📚
📙
🤠
😎
🤠
🌇
✍️
✍️
✍️
✍️
{"place": "world"}
🤓
🤩
📁
📚
📙
🤠
😎
🤠
🌇
✍️
✍️
✍️
✍️
{"place": "world"}
🤓
🤩
📁
📚
📙
🤠
😎
🔁
🌇
✍️
✍️
✍️
✍️
{"place": "world"}
🤓
🤯
📁
📚
📙
🤠
😎
🤠
✍️
✍️
✍️
✍️
{"place": "world"}
let { location } =
🤓
😎
🥸
🥸
😎
🥸
😎
🐞
🐛
🥸
😎
🐞
🐛
🐰
🐆
🥸
😎
❌
🥸
😎
🥸
😎
🥸
😎
❌
💡
💡
🤓
👂
📣
😎
"Ready!"
fetch
🤓
🤩
📁
😎
🤓
🤩
📁
😎
💪
🤓
🫥
📁
📚
📙
🤠
🤓
🫥
📁
📚
📙
🤠
📙
🏃♂️
🤓
🫥
📁
📚
📙
🤠
📙
🏃♂️
🤓
🫥
📁
📚
📙
🤠
😎
🤠
📚
🤓
🫥
📁
📚
📙
🤠
😎
🤠
📚
🤓
🫥
📁
📚
📙
🤠
😎
🤠
📚
📚
🤓
🫥
📁
📚
📙
🤠
😎
🤠
📚
📚
🤓
🤩
📁
📚
📙
🤠
😎
🤠
📚
🤓
🤩
📁
📚
📙
🤠
😎
🤠
📚
✍️
👀
🤩
📁
📚
📙
🤠
😎
🤠
📚
✍️
✍️
✍️
🤓
🤩
📁
📚
📙
🤠
😎
🤠
📚
✍️
✍️
✍️
🤓
🤩
📁
📚
📙
🤠
😎
🤠
📚
✍️
✍️
✍️
⏳
👂
🤓
🤩
📁
📚
📙
🤠
👀
🤠
📚
✍️
✍️
✍️
⏳
👂
🤓
🤩
📁
📚
📙
🤠
💀
🤠
📚
✍️
✍️
✍️
⏳
👂
🤓
🤩
📁
📚
🤠
🏃♂️
🤠
📚
✍️
✍️
⏳
👂
✍️
📙
📙
✍️
🤓
🤩
📁
📚
🤠
😎
🤠
📚
✍️
✍️
⏳
👂
✍️
📙
✍️
✅
🤓
🤩
📁
📚
🤠
😎
🤠
📚
✍️
✍️
⏳
👂
✍️
📙
✍️
✅
🤓
🤩
📁
📚
🤠
😎
🤠
📚
✍️
✍️
✍️
📙
✍️
✍️
🤓
🤩
📁
📚
🤠
😎
🤠
📚
✍️
✍️
✍️
📙
✍️
✍️
🤓
🤩
📁
📚
🤠
😎
⏳
📚
✍️
✍️
✍️
📙
✍️
✍️
{"location": "world"}
🤓
🤩
📁
📚
🤠
😎
🔁
📚
✍️
✍️
✍️
📙
✍️
{"location": "world"}
✍️
🤓
🤩
📁
📚
🤠
😎
🔁
📚
✍️
✍️
✍️
📙
✍️
{"location": "world"}
✍️
🤓
🤩
📁
📚
🤠
😎
🤠
📚
✍️
✍️
✍️
📙
✍️
✍️
let { location } =
{"location": "world"}
🔥
🔥
😎
💀
🏃♂️
😎
✍️
😎
💀
🏃♂️
😎
✍️
downtime
😎
💀
🏃♂️
😎
✍️
downtime
👎
😎
😎
✍️
💀
🏃♂️
🤠
hot-swap-server.js
😎
🤠
📙
😎
🤠
📙
✍️
😎
👀
📙
✍️
✍️
😎
🤠
📙
✍️
✍️
😎
🔁
📙
✍️
✍️
😎
🤠
📙
✍️
✍️
const BUILD_PATH = path.resolve(__dirname, "build");
function purgeRequireCache() {
for (const key in require.cache) {
if (key.startsWith(BUILD_DIR)) {
delete require.cache[key];
}
}
}
const watcher = chokidar.watch(BUILD_PATH);
watcher.on("all", () => {
// 1. purge require cache
purgeRequireCache();
// 2. load updated server build
const build = require(BUILD_PATH);
// 3. tell dev server that this app server is now ready
broadcastDevReady(build);
});
let createDevRequestHandler = (req, res, next) => {
return createRequestHandler({
build: require(BUILD_DIR),
mode: "development",
})(req, res, next);
}
CJS
function createDevRequestHandler() {
let devBuild = build;
const watcher = chokidar.watch(BUILD_PATH, { ignoreInitial: true });
watcher.on("all", async () => {
// 1. purge require cache && load updated server build
const stat = fs.statSync(BUILD_PATH);
devBuild = import(BUILD_PATH + "?t=" + stat.mtimeMs);
// 2. tell dev server that this app server is now ready
broadcastDevReady(await devBuild);
});
return async (req, res, next) => {
return createRequestHandler({
build: await devBuild,
mode: "development",
})(req, res, next);
};
}
ESM
🤓
🤩
😎
🤓
🤩
😎
🤓
🤩
😎
🤓
🤩
😎
🤓
🤩
😎
🤓
🤩
😎
https://remix.run/blog/remix-data-flow
🤓
🤩
😎
https://redux.js.org/tutorials/fundamentals/part-2-concepts-data-flow
🤓
🤩
😎
🤓
🤩
😎
🤓
🤩
😎