mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-01 14:59:19 +08:00
fix(config): drop three dead next.config entries and correct two stale comments (#6076)
`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.
This commit is contained in:
+28
-10
@@ -11,12 +11,22 @@ import {
|
||||
/**
|
||||
* Dev-only escape hatch: when `SIM_DEV_MINIMAL_REGISTRY=1` (`bun run dev:minimal`),
|
||||
* swap the heavy block and tool registries for tiny curated variants via a
|
||||
* Turbopack/webpack resolve alias. The shared workspace layout drags the
|
||||
* ~247-tool registry (~2,074 modules) into every route via providers/utils →
|
||||
* tools/params, and the editor/executor pull all ~268 block configs; aliasing
|
||||
* both to minimal variants stops Turbopack from compiling those graphs, cutting
|
||||
* dev compile-time RAM (e.g. /logs ~16GB → ~5GB, 4.9min → ~15s). Only the
|
||||
* curated core blocks/tools work in this mode. Never enabled in production.
|
||||
* Turbopack/webpack resolve alias.
|
||||
*
|
||||
* The tool registry (4,351 entries across 261 service dirs) pulls ~5,907 modules
|
||||
* and is 68-78% of every workspace route's module graph; aliasing it away takes
|
||||
* `app/workspace/layout.tsx` from 5,916 modules to 1,255. Blocks are NOT a
|
||||
* co-equal cost - `blocks/registry-maps` alone accounts for ~349 modules and
|
||||
* mostly rides in behind the tool registry.
|
||||
*
|
||||
* It is reached through ONE choke point (`tools/utils.ts` → `@/tools/registry`)
|
||||
* fed by four redundant client-reachable edges: providers/utils → tools/params,
|
||||
* lib/workflows/blocks/block-outputs, lib/workflows/sanitization/validation, and
|
||||
* serializer/index. All four must be severed for any of them to matter, which is
|
||||
* why cutting only the providers/utils edge buys a single module.
|
||||
*
|
||||
* Only the curated core blocks/tools work in this mode. Never enabled in
|
||||
* production - the minimal variants genuinely drop ~250 services and ~280 blocks.
|
||||
*/
|
||||
const useMinimalRegistry = isDev && process.env.SIM_DEV_MINIMAL_REGISTRY === '1'
|
||||
const minimalRegistryAlias: Record<string, string> = useMinimalRegistry
|
||||
@@ -150,8 +160,15 @@ const nextConfig: NextConfig = {
|
||||
*/
|
||||
turbopackFileSystemCacheForBuild: process.env.NEXT_TURBOPACK_BUILD_CACHE === '1',
|
||||
preloadEntriesOnStart: false,
|
||||
/**
|
||||
* Under Turbopack this is not a no-op: the list feeds
|
||||
* `side_effect_free_packages` and is force-appended to `transpiledPackages`,
|
||||
* which also removes each entry from the server externals set. Entries here
|
||||
* must be real barrel packages that are actually imported - a stale entry
|
||||
* costs transform work and overrides that package's own `sideEffects`
|
||||
* declaration.
|
||||
*/
|
||||
optimizePackageImports: [
|
||||
'lodash',
|
||||
'framer-motion',
|
||||
'reactflow',
|
||||
'@radix-ui/react-dialog',
|
||||
@@ -159,7 +176,6 @@ const nextConfig: NextConfig = {
|
||||
'@radix-ui/react-popover',
|
||||
'@radix-ui/react-select',
|
||||
'@radix-ui/react-tabs',
|
||||
'@radix-ui/react-accordion',
|
||||
'@radix-ui/react-checkbox',
|
||||
'@radix-ui/react-switch',
|
||||
'@radix-ui/react-slider',
|
||||
@@ -186,7 +202,6 @@ const nextConfig: NextConfig = {
|
||||
],
|
||||
}),
|
||||
transpilePackages: [
|
||||
'prettier',
|
||||
'@react-email/components',
|
||||
'@react-email/render',
|
||||
'@t3-oss/env-nextjs',
|
||||
@@ -259,7 +274,10 @@ const nextConfig: NextConfig = {
|
||||
},
|
||||
],
|
||||
},
|
||||
// Block access to sourcemap files (defense in depth). The trailing
|
||||
// Keeps sourcemap files out of search indexes. This does NOT block
|
||||
// access to them - `productionBrowserSourceMaps` is on and the `.map`
|
||||
// files ship publicly in the production image; nothing here restricts
|
||||
// who can fetch one. The trailing
|
||||
// `$` this rule previously ended with is not a regex anchor in Next's
|
||||
// `source` matcher (path-to-regexp syntax, not raw regex) - it matched
|
||||
// a literal `$` character, so this rule never actually fired against
|
||||
|
||||
Reference in New Issue
Block a user