Skip to content

Commit 85e291d

Browse files
committed
fix(collab-doc): trace the full yjs/tiptap external stack into the file-doc route bundles
The seed/merge/persist internal routes run the collab-doc converter (markdown <-> Yjs via headless TipTap) server-side. Those deps are serverExternalPackages, and the standalone tracer only force-included jsdom — it does NOT follow yjs's ESM subpath imports of lib0 (lib0/logging, ...), so Docker/standalone builds shipped node_modules without them and the seed route 500'd (Cannot find module 'lib0/logging'). That left every collaborative document unseeded and permanently read-only on deployed envs. Force yjs, lib0, y-protocols, and @tiptap into the trace for all three routes.
1 parent f1d1ec0 commit 85e291d

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

apps/sim/next.config.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ import {
88
getWorkflowExecutionCSPPolicy,
99
} from './lib/core/security/csp'
1010

11+
/**
12+
* Collab-doc converter deps (markdown ⇄ Yjs via headless TipTap). They are `serverExternalPackages`, and
13+
* the standalone tracer doesn't copy them — jsdom is a lazy `require`, and yjs's ESM resolves `lib0` via
14+
* subpath exports nft misses — so force them in or the file-doc routes 500 with MODULE_NOT_FOUND.
15+
*/
16+
const COLLAB_DOC_SERVER_TRACE = [
17+
'./node_modules/jsdom/**/*',
18+
'./node_modules/yjs/**/*',
19+
'./node_modules/lib0/**/*',
20+
'./node_modules/y-protocols/**/*',
21+
'./node_modules/@tiptap/**/*',
22+
]
23+
1124
/**
1225
* Dev-only escape hatch: when `SIM_DEV_MINIMAL_REGISTRY=1` (`bun run dev:minimal`),
1326
* swap the heavy block and tool registries for tiny curated variants via a
@@ -202,13 +215,10 @@ const nextConfig: NextConfig = {
202215
],
203216
outputFileTracingIncludes: {
204217
'/api/tools/stagehand/*': ['./node_modules/ws/**/*'],
205-
// The seed, merge, and persist endpoints all lazily `require('jsdom')` (via the collab-doc
206-
// converter), which is invisible to the standalone file tracer, so force jsdom (and its transitive
207-
// deps, followed from its static requires) into the trace — otherwise a Docker/standalone build
208-
// omits it and the endpoint 500s with MODULE_NOT_FOUND.
209-
'/api/internal/file-doc/seed': ['./node_modules/jsdom/**/*'],
210-
'/api/internal/file-doc/merge': ['./node_modules/jsdom/**/*'],
211-
'/api/internal/file-doc/persist': ['./node_modules/jsdom/**/*'],
218+
// These routes run the collab-doc converter server-side; see COLLAB_DOC_SERVER_TRACE.
219+
'/api/internal/file-doc/seed': COLLAB_DOC_SERVER_TRACE,
220+
'/api/internal/file-doc/merge': COLLAB_DOC_SERVER_TRACE,
221+
'/api/internal/file-doc/persist': COLLAB_DOC_SERVER_TRACE,
212222
'/*': [
213223
'./node_modules/sharp/**/*',
214224
'./node_modules/@img/**/*',

0 commit comments

Comments
 (0)