Version
@netscript/sdk@0.0.5, Deno 2.9.5.
Problem
defineServices is exported only from the SDK root, but importing that root in browser-shared code also imports src/cache/mod.ts, whose top-level setCacheProvider(cacheQuery) registers the server KV cache provider. queryOptions() then sees hasCacheProvider() === true, takes the server cache path, and KvCacheStore dynamically imports @netscript/kv in a browser bundle.
Focused query imports do not have this side effect.
Minimal reproduction
deno eval --no-config --no-lock "import { hasCacheProvider } from 'jsr:@netscript/sdk@0.0.5'; console.log(hasCacheProvider())"
# true
deno eval --no-config --no-lock "import { hasCacheProvider } from 'jsr:@netscript/sdk@0.0.5/query'; console.log(hasCacheProvider())"
# false
The published package has no browser-safe ./presets/defineServices subpath.
Exact source chain
- root
mod.ts exports both defineServices and ./src/cache/mod.ts;
src/cache/mod.ts performs top-level setCacheProvider(cacheQuery);
src/query/query-factory.ts chooses its server cache path when hasCacheProvider() is true;
KvCacheStore.resolve() dynamically imports @netscript/kv.
Consumer impact
A consumer following the service-preset API in a dashboard/shared module silently changes query execution semantics and pulls a server KV adapter toward the client build. EIS-Chat must keep separate focused @netscript/sdk/client and /query imports instead of adopting the intended defineServices seam.
Expected
- Export
defineServices from a browser-safe, side-effect-free subpath; or make the SDK root side-effect-free.
- Server bootstrap should explicitly opt into cache-provider registration.
- Browser
queryOptions() should use the typed client directly and never load @netscript/kv.
Acceptance
Version
@netscript/sdk@0.0.5, Deno 2.9.5.Problem
defineServicesis exported only from the SDK root, but importing that root in browser-shared code also importssrc/cache/mod.ts, whose top-levelsetCacheProvider(cacheQuery)registers the server KV cache provider.queryOptions()then seeshasCacheProvider() === true, takes the server cache path, andKvCacheStoredynamically imports@netscript/kvin a browser bundle.Focused query imports do not have this side effect.
Minimal reproduction
The published package has no browser-safe
./presets/defineServicessubpath.Exact source chain
mod.tsexports bothdefineServicesand./src/cache/mod.ts;src/cache/mod.tsperforms top-levelsetCacheProvider(cacheQuery);src/query/query-factory.tschooses its server cache path whenhasCacheProvider()is true;KvCacheStore.resolve()dynamically imports@netscript/kv.Consumer impact
A consumer following the service-preset API in a dashboard/shared module silently changes query execution semantics and pulls a server KV adapter toward the client build. EIS-Chat must keep separate focused
@netscript/sdk/clientand/queryimports instead of adopting the intendeddefineServicesseam.Expected
defineServicesfrom a browser-safe, side-effect-free subpath; or make the SDK root side-effect-free.queryOptions()should use the typed client directly and never load@netscript/kv.Acceptance
defineServicesentry leaveshasCacheProvider()false.queryOptions().queryFn()calls an injected typed client and never loads@netscript/kv.defineFreshApp/server bootstrap still registers the provider explicitly.