Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions apps/sim/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -150,16 +160,22 @@ 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',
'@radix-ui/react-dropdown-menu',
'@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',
Expand All @@ -186,7 +202,6 @@ const nextConfig: NextConfig = {
],
}),
transpilePackages: [
'prettier',
'@react-email/components',
'@react-email/render',
'@t3-oss/env-nextjs',
Expand Down Expand Up @@ -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
Expand Down
Loading