惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
L
LINUX DO - 最新话题
P
Proofpoint News Feed
Cyberwarzone
Cyberwarzone
Know Your Adversary
Know Your Adversary
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
Lohrmann on Cybersecurity
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Security Latest
Security Latest
T
The Exploit Database - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy & Cybersecurity Law Blog
K
Kaspersky official blog
The Last Watchdog
The Last Watchdog
Webroot Blog
Webroot Blog
Scott Helme
Scott Helme
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
WordPress大学
WordPress大学
L
LINUX DO - 热门话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
V
Visual Studio Blog
O
OpenAI News
AI
AI
Hacker News: Ask HN
Hacker News: Ask HN
V2EX - 技术
V2EX - 技术
GbyAI
GbyAI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Simon Willison's Weblog
Simon Willison's Weblog
S
Schneier on Security
Spread Privacy
Spread Privacy
Y
Y Combinator Blog
I
InfoQ
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
F
Fortinet All Blogs
C
CERT Recently Published Vulnerability Notes
T
The Blog of Author Tim Ferriss
C
Check Point Blog
Apple Machine Learning Research
Apple Machine Learning Research
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
N
News and Events Feed by Topic
Project Zero
Project Zero
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
B
Blog
G
Google Developers Blog

Kent C. Dodds Blog

Implementing Hybrid Semantic + Lexical Search Simplifying Containers with Cloudflare Sandboxes Offloading FFmpeg with Cloudflare Building Semantic Search on my Content Helping YOU ask ME questions with AI How I used Cursor to Migrate Frameworks The Dow's Start on the Covenant Path 2025 in Review The next chapter: EpicAI.pro AI is taking your job How I increased my visibility Launching Epic Web 2023 in Review Stop Being a Junior RSC with Dan Abramov and Joe Savona Live Stream Fixing a Memory Leak in a Production Node.js App 2022 in Review My Car Accident I Migrated from a Postgres Cluster to Distributed SQLite with LiteFS I'm building EpicWeb.dev A review of my time at Remix Remix: The Yang to React's Yin How I help you build better websites Why I Love Remix The State Initializer Pattern How to React ⚛️ Get a catch block error message with TypeScript Building an awesome image loading experience How Remix makes CSS clashes predictable Introducing the new kentcdodds.com How I built a modern website in 2021 How to use React Context effectively Static vs Unit vs Integration vs E2E Testing for Frontend Apps The Testing Trophy and Testing Classifications Array reduce vs chaining vs for loop Don't Solve Problems, Eliminate Them Super Simple Start to Remix Super Simple Start to ESModules in Node.js JavaScript Pass By Value Function Parameters How to write a Constrained Identity Function (CIF) in TypeScript How to optimize your context value How to write a React Component in TypeScript TypeScript Function Syntaxes Listify a JavaScript Array Build vs Buy: Component Libraries edition Using fetch with TypeScript Wrapping React.useState with TypeScript Define function overload types with TypeScript 2020 in Review Business and Engineering alignment Hi, thanks for reaching out to me 👋 useEffect vs useLayoutEffect Super simple start to Firebase functions Super simple start to Netlify functions Super Simple Start to css variables Favor Progress Over Pride in Open Source Testing Implementation Details How getting into Open Source has been awesome for me useState lazy initialization and function updates Use ternaries rather than && in JSX Application State Management with React Use react-error-boundary to handle errors in React JavaScript to Know for React How I structure Express apps What open source project should I contribute to? When I follow TDD AHA Programming 💡 How I Record Educational Videos Should I write a test or fix a bug? Stop mocking fetch Intentional Career Building Improve test error messages of your abstractions Tracing user interactions with React Eliminate an entire category of bugs with a few simple tools Common mistakes with React Testing Library Super Simple Start to React Stop using client-side route redirects The State Reducer Pattern with React Hooks Function forms Replace axios with a simple custom fetch wrapper How to test custom React hooks React Production Performance Monitoring Should I useState or useReducer? Stop using isLoading booleans Make Your Test Fail Make your own DevTools An Argument for Automation Fix the "not wrapped in act(...)" warning Super Simple Start to ESModules in the Browser Implementing a simple state machine library in JavaScript 2010s Decade in Review Why users care about how you write code Why I avoid nesting closures Don't call a React function component Why your team needs TestingJavaScript.com Inversion of Control Understanding React's key prop How to Enable React Concurrent Mode How to add testing to an existing project Profile a React App for Performance
Migrating to Workspaces and Nx
2026-03-10 · via Kent C. Dodds Blog

For a while, kentcdodds.com had two separate deployable things living in the same git repo:

  • The main site (React Router, Remix before that, SQLite, deployed to Fly)
  • An OAuth worker (Cloudflare Worker)

Then yesterday, I added two more deployable things:

  • A Call Kent audio worker (Cloudflare Worker)
  • A Call Kent audio container (separate Docker container)

Each of them had their own package.json, their own lockfile, their own tsconfig.json, and their own idea of how things should be wired together. The root package.json belonged to the site and treated everything else as optional siblings. The monorepo structure existed in the folder tree but not in the package manager.

That wasn't catastrophic. But it was annoying and I knew I really should just embrace the monorepo. The repo already was a monorepo. The layout just hadn't caught up.

What we changed

The migration had a single structural rule: everything runnable lives under services/*.

services/
  site/                       ← the main app
  oauth/                      ← Cloudflare OAuth worker
  call-kent-audio-worker/     ← Cloudflare audio worker
  call-kent-audio-container/  ← Docker audio container

The root package.json became a thin orchestration layer. It owns the workspace declaration, Nx, and convenience scripts that forward into the site workspace:

{
	"name": "kcd-workspace",
	"private": true,
	"workspaces": ["services/*"],
	"scripts": {
		"dev": "npm run dev --workspace kentcdodds.com",
		"build": "npm run build --workspace kentcdodds.com",
		"typecheck": "npm run typecheck --workspace kentcdodds.com",
		"typecheck:all": "nx run-many -t typecheck"
	},
	"devDependencies": {
		"nx": "^22.5.4"
	}
}

The real app scripts stayed in services/site/package.json, where they belong. ci:verify, test:browser, build, postinstall - all of it lives there, scoped to the thing that actually needs it.

Three old nested lockfiles (call-kent-audio-container/package-lock.json, call-kent-audio-worker/package-lock.json, oauth/package-lock.json) were deleted and replaced by one root lockfile. That made the raw diff stat look alarming (726 files, 21,000 deletions) but the bulk of it was three lockfiles evaporating. The actual logic changes were modest.

How Nx fits in

We kept Nx intentionally minimal. There's one nx.json at the root with caching defaults and package-script inference:

{
	"namedInputs": {
		"sharedGlobals": [
			"{workspaceRoot}/package-lock.json",
			"{workspaceRoot}/tsconfig.base.json",
			"{workspaceRoot}/nx.json"
		]
	},
	"targetDefaults": {
		"build": { "cache": true, "inputs": ["production", "^production"] },
		"lint": { "cache": true, "inputs": ["default", "^default"] },
		"typecheck": { "cache": true, "inputs": ["default", "^default"] },
		"test": { "cache": true, "inputs": ["default", "^default"] }
	}
}

No hand-authored project.json files. No plugin configuration beyond what Nx infers. The payoff came from the structure itself, not from the tool.

What the services/* constraint exposed

This is the part worth actually talking about.

When you enforce that every runnable thing has its own package under services/*, you immediately learn which assumptions your code was making about where it was running from. We found three categories of breakage.

1. Package import aliases stopped working

The site had a #other/* import alias defined in the root package.json. Once the site became services/site and got its own package boundary, Node rejected any import that pointed outside that boundary:

ERR_INVALID_PACKAGE_TARGET: Package subpath '#other/semantic-search/...'
is not defined in "services/site/package.json"

The alias #other/* resolved to ./other/* relative to the package root, but from services/site, other/ is two levels up and outside the package. Node refuses that. The fix was mechanical but educational: replace the aliases with explicit relative paths:

- } from '#other/semantic-search/ignore-list-patterns.ts'
+ } from '../../../../other/semantic-search/ignore-list-patterns.ts'

Not pretty, but I only have two of these so I don't really care much (I'm barely looking at the code anymore anyway).

2. Production went down because content moved

This one stung.

The site fetches blog posts, talks, testimonials, and other content from GitHub via the API at runtime. That code had a hardcoded path prefix:

const mdxFileOrDirectory = `content/${relativeMdxFileOrDirectory}`

After the migration, the content was at services/site/content/ in the repo, not content/. The GitHub API was dutifully returning 404s for everything. Production was down.

The fix was to centralize all content path logic in a new utility:

// services/site/app/utils/github-content-paths.server.ts
export const GITHUB_CONTENT_PATH = 'services/site/content'

export function getGitHubContentPath(relativePath: string): string {
	return `${GITHUB_CONTENT_PATH}/${relativePath}`
}

And then use it at every callsite:

- const mdxFileOrDirectory = `content/${relativeMdxFileOrDirectory}`
+ const mdxFileOrDirectory = getGitHubContentPath(relativeMdxFileOrDirectory)

The lesson here is don't merge a 726-file structural refactor from your phone while you're away from home without pulling it down and running it locally 😆. Honestly, I'm not sure even that would have been enough. The Cursor Cloud Agent had a working demo. The problem was the GitHub API mock I had for local development and testing handled the path change fine, but not the actual implementation 🙈

Once the path was fixed, I also made the site more resilient to future GitHub API failures. Rather than crashing or returning empty pages when content can't be fetched, each relevant route now returns a graceful fallback with a message and a direct link to the GitHub repo. So at least users have somewhere to go if the integration is broken. Better late than never.

3. Docker stages have their own dependency graph

After moving the site to services/site, the Dockerfile was updated to build from the new path. The production-deps stage copied services/site/package.json but not services/site/prisma/. Two other stages actually need the Prisma schema:

  • The deps stage runs npm install, which triggers postinstall: prisma generate
  • The build stage runs npx prisma generate explicitly before building the app

The production-deps stage doesn't run either of those, so it's not entirely clear which stage the failure manifested in. But the schema was missing where it was needed, and the fix was two lines:

ADD services/site/package.json /app/services/site/package.json
+ ADD services/site/prisma /app/services/site/prisma
+ ADD services/site/prisma.config.ts /app/services/site/prisma.config.ts
  ADD services/oauth/package.json /app/services/oauth/package.json

The reason this one wasn't caught is because Cursor Cloud Agent's don't have support for building Docker images (which is surprising to me, maybe I'm doing something wrong?). So when I asked it to build the Docker image to make sure things would work, it just said it couldn't but it was "confident" 😆 And my hubris was my demise 💀

CI got restructured around the actual workload

Before the migration, CI ran a workspace-wide install and then ran everything. That was fine when there was effectively one package. With real service boundaries, it made more sense to optimize around the actual usage pattern.

The site changes roughly much more often than the workers do. So site CI now does a site-only install:

- name: 📥 Install site deps
  run: npm ci --workspace=kentcdodds.com

Rather than pulling the full dependency graph. The worker pipelines mirror this: each one installs only its own workspace when they need to run.

The other meaningful CI change: browser tests were always part of ci:verify, but the Playwright browser binaries were never installed in the gate job. It worked before because the old CI didn't include browser tests in the gate. After the migration restructured the gate job, that assumption surfaced immediately as a CI failure:

browserType.launch: Executable doesn't exist

Fixed by adding a cached Playwright browser install step before ci:verify:

- name: 🧰 Cache Playwright browsers
  id: playwright-cache
  uses: actions/cache@v5
  with:
    path: ~/.cache/ms-playwright
    key: playwright-${{ runner.os }}-node${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}

- name: 🌐 Install Playwright browsers
  if: steps.playwright-cache.outputs.cache-hit != 'true'
  run: npm run test:e2e:install --workspace kentcdodds.com

What I'd take away from this

Don't ask an agent how confident it is that something won't break. Make it prove it to you. If it's not able to, then give it the tools it needs to do that or pull it down and verify things locally yourself.

For my website, it's not a huge deal if the site goes down for half an hour or something, so I'm generally pretty lax on things with my website. In a production application with millions of users, I would definitely be more careful about this, and we'd have staging environments or at least preview deploys and stuff to avoid production downtime.

Nx was useful mostly for caching. The services are technically inter-dependant, but they don't really share code or have hard dev dependencies on each other. The structure was the actual win.