Skip to content

Commit 9e7c380

Browse files
committed
fix(config): drop three dead next.config entries and correct two stale comments
`optimizePackageImports` is not a no-op under Turbopack, despite what the Next docs say. In 16.2.11 the list feeds `side_effect_free_packages` and is force-appended to `transpiledPackages`, which also removes each entry from the server externals set — and it overrides each listed package's own `sideEffects` declaration rather than hinting. So a stale entry is not free. Two entries are provably dead: `lodash` has zero import sites repo-wide and is not a dependency of any package here (Next also already applies a `lodash -> lodash/{{member}}` modularizeImports rule unconditionally), and `@radix-ui/react-accordion`'s only occurrence in the repo was this line. `prettier` in `transpilePackages` is dead for a different reason: nothing imports it, it is in no package.json, and the repo formats with Biome. It sits in node_modules only as a transitive dep. `transpilePackages` matches on modules already in the graph, so this entry was transpiling nothing. Also corrects two comments that claimed more than the code does: - the `.map` header rule said it blocks access to sourcemaps; it only sets `noindex` and a TTL. The maps ship publicly in the production image. - the minimal-registry comment's numbers were badly stale (~247 tools -> 4,351; ~2,074 modules -> ~5,907) and its framing wrong: blocks are not a co-equal cost, and the tool registry is reached through four redundant client edges, not just providers/utils — which is why cutting only that one edge buys a single module. No behavior change intended: the removed entries were inert. Kept `zod`, `reactflow`, `framer-motion`, and `streamdown`, which are real barrels with real import sites — removing those changes tree-shaking hints and needs a bundle-size measurement, not a guess.
1 parent 998fd5a commit 9e7c380

1 file changed

Lines changed: 28 additions & 10 deletions

File tree

apps/sim/next.config.ts

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,22 @@ import {
1111
/**
1212
* Dev-only escape hatch: when `SIM_DEV_MINIMAL_REGISTRY=1` (`bun run dev:minimal`),
1313
* swap the heavy block and tool registries for tiny curated variants via a
14-
* Turbopack/webpack resolve alias. The shared workspace layout drags the
15-
* ~247-tool registry (~2,074 modules) into every route via providers/utils →
16-
* tools/params, and the editor/executor pull all ~268 block configs; aliasing
17-
* both to minimal variants stops Turbopack from compiling those graphs, cutting
18-
* dev compile-time RAM (e.g. /logs ~16GB → ~5GB, 4.9min → ~15s). Only the
19-
* curated core blocks/tools work in this mode. Never enabled in production.
14+
* Turbopack/webpack resolve alias.
15+
*
16+
* The tool registry (4,351 entries across 261 service dirs) pulls ~5,907 modules
17+
* and is 68-78% of every workspace route's module graph; aliasing it away takes
18+
* `app/workspace/layout.tsx` from 5,916 modules to 1,255. Blocks are NOT a
19+
* co-equal cost - `blocks/registry-maps` alone accounts for ~349 modules and
20+
* mostly rides in behind the tool registry.
21+
*
22+
* It is reached through ONE choke point (`tools/utils.ts` → `@/tools/registry`)
23+
* fed by four redundant client-reachable edges: providers/utils → tools/params,
24+
* lib/workflows/blocks/block-outputs, lib/workflows/sanitization/validation, and
25+
* serializer/index. All four must be severed for any of them to matter, which is
26+
* why cutting only the providers/utils edge buys a single module.
27+
*
28+
* Only the curated core blocks/tools work in this mode. Never enabled in
29+
* production - the minimal variants genuinely drop ~250 services and ~280 blocks.
2030
*/
2131
const useMinimalRegistry = isDev && process.env.SIM_DEV_MINIMAL_REGISTRY === '1'
2232
const minimalRegistryAlias: Record<string, string> = useMinimalRegistry
@@ -150,16 +160,22 @@ const nextConfig: NextConfig = {
150160
*/
151161
turbopackFileSystemCacheForBuild: process.env.NEXT_TURBOPACK_BUILD_CACHE === '1',
152162
preloadEntriesOnStart: false,
163+
/**
164+
* Under Turbopack this is not a no-op: the list feeds
165+
* `side_effect_free_packages` and is force-appended to `transpiledPackages`,
166+
* which also removes each entry from the server externals set. Entries here
167+
* must be real barrel packages that are actually imported - a stale entry
168+
* costs transform work and overrides that package's own `sideEffects`
169+
* declaration.
170+
*/
153171
optimizePackageImports: [
154-
'lodash',
155172
'framer-motion',
156173
'reactflow',
157174
'@radix-ui/react-dialog',
158175
'@radix-ui/react-dropdown-menu',
159176
'@radix-ui/react-popover',
160177
'@radix-ui/react-select',
161178
'@radix-ui/react-tabs',
162-
'@radix-ui/react-accordion',
163179
'@radix-ui/react-checkbox',
164180
'@radix-ui/react-switch',
165181
'@radix-ui/react-slider',
@@ -186,7 +202,6 @@ const nextConfig: NextConfig = {
186202
],
187203
}),
188204
transpilePackages: [
189-
'prettier',
190205
'@react-email/components',
191206
'@react-email/render',
192207
'@t3-oss/env-nextjs',
@@ -259,7 +274,10 @@ const nextConfig: NextConfig = {
259274
},
260275
],
261276
},
262-
// Block access to sourcemap files (defense in depth). The trailing
277+
// Keeps sourcemap files out of search indexes. This does NOT block
278+
// access to them - `productionBrowserSourceMaps` is on and the `.map`
279+
// files ship publicly in the production image; nothing here restricts
280+
// who can fetch one. The trailing
263281
// `$` this rule previously ended with is not a regex anchor in Next's
264282
// `source` matcher (path-to-regexp syntax, not raw regex) - it matched
265283
// a literal `$` character, so this rule never actually fired against

0 commit comments

Comments
 (0)