Files
deepseek-harness/packages/client/web/tests/source-static-modules.client.ts
imccyu 6480899de0 feat(client): load three Client packages as immediately dynamic plugins
ui-slots, ui-primitives and ui-dockkit stop being statically linked into
the Web shell. Each becomes a dynamic plugin package with
`immediately: true`, like ui-renderer: src/client/index.ts builds
lib/client.js, the ./client export, whose apply registers nothing, and
the web-app composition lists the three rows by package name, so they
register before other plugins and any bundle can require their exports.
Their /client entries still export values, a historical exception that
will be reduced over time. Dynamic bundles keep leaving the three names
to the module table without declaring them.

client-store is unchanged: it stays a staticLinked library that the Web
shell seeds, and ui-slots and ui-primitives keep importing it by package
root, which their dynamic bundles leave to the module table.

For compatibility with code outside the repository, the package root's
runtime is the hand-written Host entry src/index.js with the empty
apply, built to lib/index.js, and its types reuse the ./client
declarations, which check-workspace-constraints accepts. src/index.ts
is gone; the tsconfig path of the root already maps to the src
directory, where tsx finds index.js.

Gates follow the Host entry without a src/index.ts: the dependency and
config-catalog scans resolve ./src/index.js to its source module,
verify-cordis-config accepts a configured root that resolves under src/,
and verify-client-packages accepts a workspace PLATFORM_MODULES name
supplied by an immediately row of the same name, while a seeded
workspace module still has to use the staticLinked preset. The benchmark
workers read the workspace manifests and bundle from source the /client
subpath of each package that declares dsh.client, because its built
lib/client.js registers with a browser module loader; every other
@deepseek-ai specifier, client-store and token-meter/client included,
stays on its built entry. Generated catalogs and the lockfile are
refreshed.
2026-11-28 02:28:52 +08:00

38 lines
1.7 KiB
TypeScript

/**
* Source-only platform registrations for in-process browser assembly tests: the modules the shell seeds. Dynamic
* Client packages are absent: a page that resolves them through the module table registers their rows, as production
* does.
*
* `apps/web/tests/source-static-modules.client.ts` holds an identical copy:
* a TypeScript test project cannot include a file outside its `rootDir`, so the `apps/web` project and
* the package test projects each need their own. Change both together.
*/
import * as React from 'react'
import * as ReactJsxRuntime from 'react/jsx-runtime'
import * as ReactDom from 'react-dom'
import * as ReactDomClient from 'react-dom/client'
import * as Cordis from '@deepseek-ai/cordis'
import * as Zod from 'zod'
import * as ReactVirtual from '@tanstack/react-virtual'
import * as ClientStore from '@deepseek-ai/dsh-client-store'
import type { ClientModuleCreateOptions } from '@deepseek-ai/dsh-client-modules/client'
import type { PlatformModule } from '@deepseek-ai/dsh-client-web/src/platform.ts'
/**
* Adapt source namespaces to the module registration protocol without compiled metadata.
* @returns Registrations retaining the real source module namespace identities.
*/
export function getStaticModules(): ClientModuleCreateOptions['staticModules'] {
const sources = {
'react': React,
'react/jsx-runtime': ReactJsxRuntime,
'react-dom': ReactDom,
'react-dom/client': ReactDomClient,
'@deepseek-ai/cordis': Cordis,
'zod': Zod,
'@tanstack/react-virtual': ReactVirtual,
'@deepseek-ai/dsh-client-store': ClientStore,
} satisfies Partial<Record<PlatformModule, Record<string, unknown>>>
return Object.entries(sources).map(([id, exports]) => ({ id, factory: () => exports }))
}