Repository navigation
fix: keep server-only AI/code-mode out of app client bundles (fixes base e2e) - #70
Merged
Merged
Conversation
…gression) The capability-seams change injected `ai.runtime`/`interfaces.runtime` as static top-level imports in base/prm's isomorphic `cms.config` (pulled into the client via `import './cms.config'` in router.tsx). That dragged `@tanstack/ai` into the client, whose transitive `partial-json` has a bad named export — crashing the /setup page's JS so the owner-setup form never rendered (the "flaky" base e2e was actually this deterministic crash). - core: `ai.runtime` and `interfaces.runtime` now accept a server-only provider (`() => Runtime | Promise<Runtime>`); cmsTools / interfaceRuntime resolve it. New CmsAiRuntimeInput / InterfaceRuntimeInput types. - base/prm configs: provide the runtimes via `createServerOnlyFn` / a dynamic import so the opt-in entries load only on the server. - base e2e: health-gated globalSetup warms SSR routes + retries:2 on CI, as defense-in-depth against cold-compile. base e2e 12/12 green; core 661; prm 10; interface tests 17+4. oxlint clean. Known follow-up: the `storage: createPgliteStorage` static import still bloats client bundles with PGlite (imports cleanly, doesn't crash) — needs a server-only storage injection path (sync resolveStorageAdapter complicates it). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a regression from the capability-seams change (#68) and the base e2e flake it caused.
Root cause (not a flake — a deterministic crash)
#68 injected
ai.runtime/interfaces.runtimeas static top-level imports inapp/baseandapp/prm'scms.config.ts. That config is isomorphic —router.tsxdoesimport './cms.config', so it's in the client bundle. The staticimport … from '@tanstack/cms-core/interfaces-quickjs'(and/ai) pulled@tanstack/aiinto the client, whose transitivepartial-json@0.1.7has a bad named export → the/setuppage's JS threwSyntaxErrorat module eval → React never rendered the owner-setup form →locator.filltimed out at 90s. Vite's dep-optimizer cache made it look intermittent.Fix
ai.runtimeandinterfaces.runtimenow accept a server-only provider (() => Runtime | Promise<Runtime>) in addition to a value.cmsToolsandinterfaceRuntime()resolve it. NewCmsAiRuntimeInput/InterfaceRuntimeInput.createServerOnlyFn/ a dynamic import, so the opt-in entries (and their@tanstack/ai/ QuickJS deps) load only on the server.globalSetupwarms the SSR routes +retries: 2on CI — defense-in-depth against genuine cold-compile.Verification
base e2e 12/12 (was timing out) · core 661 · prm 10 · interface tests 17+4 · oxlint clean · core/api/base/prm typecheck.
Known follow-up (not in this PR)
storage: createPgliteStorageis still a static import in the isomorphic configs, so PGlite is bundled client-side. It imports cleanly (no crash, so CI is green), but it's bloat. A server-only storage injection path is more involved (resolveStorageAdapteris sync); worth a dedicated change — likely wiringsetDefaultStorageFactory(createPgliteStorage)in each app's server entry instead of the isomorphic config.🤖 Generated with Claude Code