Plugin Runtime/Tools Entry Split
Design Log #32 — Runtime/Tools Entry Split for Wix Plugins
Written for AI agents. See Log Methodology Note below for details.
Status: Implemented
Background
The Jay Framework landed two paired changes (framework design-log/179 and design-log/180):
- DL#179 — Compiler-free plugin runtime. A plugin package ships two kinds of code: serve-time
(headless components, server actions,
init, client bundle — loaded on the production request path, must stay compiler-free) and tools-time (validators, CLI commands, agent-kit generators,setuphandlers, dev-only route components — run only under the toolchain, may use the compiler). These must not share one module graph. The fix: a third entry per plugin —./tools(lib/tools.ts→dist/tools.js) — parallel to the existing./client. All tools-time handlers move there;index.ts(.) stays compiler-free. - DL#180 — Dev-only actions.
actions[].devOnly: truemarks a browser-callable action whose handler lives in./tools(compiler-OK) and is excluded from the production build. Enables plugin settings pages (adevOnlyroute +devOnlyactions).
The framework loaders were already updated (by the framework team): validators, commands, agent-kit,
and setup now load only from ${packageName}/tools (clean cut, no .-fallback). devOnly action
handlers and devOnly route components also resolve from ./tools.
Problem
Every wix plugin currently exports its tools-time handlers (setup, agentkit, validators,
commands) from lib/index.ts (.). Under the new framework:
- Broken loading (all plugins with a tools capability). The loaders no longer look on
.for these handlers, sosetup/agentkit/validate/commands would fail to load until each handler is exposed via./tools. - Compiler leak (wix-deploy, wix-media). Both re-export
validatefromindex.ts, and their validators value-importparseTemplatePartsfrom@jay-framework/compiler-jay-html. Soimport('<plugin>')(the serve entry) transitively loads the compiler into the BaaS deploy bundle.
Capability inventory
| Plugin | Tools-time capabilities to move to ./tools |
Compiler in dependencies? |
|---|---|---|
| wix-bookings | setup | no |
| wix-cart | — (none) | no |
| wix-data | agentkit, setup | no |
| wix-deploy | validators, commands, setup | yes (jay-html, shared) |
| wix-forms | setup | no |
| wix-media | validators, commands, agentkit, setup, 5 devOnly actions, devOnly route component | yes (jay-html, shared) |
| wix-members | validators, setup | no (type-only) |
| wix-server-client | setup | no |
| wix-stores-v1 | setup | no |
| wix-stores | agentkit, setup | no |
Compiler imports across the repo live only in validators
(wix-deploy/validators/static-filename-validator.ts,
wix-media/validators/media-validator.ts value-import compiler-jay-html;
wix-members/validators/auth-callback-validator.ts is type-only). Every other wix module is
compiler-free, so moving the validators (plus the clean-cut tools handlers) off . makes each
index.js compiler-free.
Design — per-plugin recipe
For every plugin with a tools capability (all except wix-cart):
lib/tools.ts(new) — re-export the tools-time handlers with a DL#179 header comment: validators, command handlers, agent-kit generator,setup, and (wix-media) the devOnly action handlers + devOnly route component.lib/index.ts— remove those re-exports. Keep serve-time exports (components, services, contexts,init, regular actions, types). Compiler-free.package.json:- Add
"./tools": "./dist/tools.js"toexports. build:types: appendlib/tools.tsto the tsup entry list.- Where
compiler-*is a runtimedependency(wix-deploy, wix-media), movecompiler-jay-htmlandcompiler-sharedtopeerDependencies(provided by the toolchain) + keep adevDependency.
- Add
vite.config.ts:- Add
tools: resolve(__dirname, 'lib/tools.ts')to the SSRlib.entry. - Add
/^@jay-framework\/compiler-/torollupOptions.externalso any future compiler leak into.surfaces as a literal import string indist/index.js(DL#179 leak scan).
- Add
wix-media specifics (DL#180)
- Mark the 5 settings actions
devOnly: trueinplugin.yaml(object form) so production excludes them; their handlers move to./tools. - The settings route (
/wix-media/settings) is alreadydevOnly: true; its server component (mediaSettingsPage) moves to./tools. The client hydration export stays on./client(index.client.tsunchanged). - wix-media's settings actions are compiler-free — they move for production exclusion + clean-cut, not for a compiler leak.
Implementation Plan
- Add
lib/tools.tsand trimlib/index.tsfor all 9 plugins. - Update
package.jsonexports,build:types, and compiler dep placement. - Update
vite.config.ts(tools entry + compiler external). - wix-media: mark settings actions
devOnly. - Build + type-check + plugin-validate the repo (
yarn build,yarn build:check-types).
Verification Criteria
dist/index.jsof wix-deploy and wix-media contains no@jay-framework/compiler-import (DL#179 leak scan).jay-stack-cli validate-pluginpasses for every plugin (requires./toolswhen a tools capability is declared).yarn buildandyarn build:check-typesare green across the repo.
Implementation Results
Implemented exactly as designed. All 9 tools-bearing plugins now have a ./tools entry; wix-cart
was untouched (no tools capability).
Per-plugin changes
lib/tools.tsadded to all 9 plugins, re-exporting only tools-time handlers (validators, commands, agent-kit,setup, and — wix-media — the 5 devOnly action handlers + devOnly route component). Each carries a DL#179 header comment.lib/index.tstrimmed of those re-exports in all 9; serve-time exports (components, services, contexts,init, regular actions, types) retained. wix-deployindex.tsnow exports only the compiler-freeWixDataArtifactStore(+ type). wix-mediaindex.tskeeps only compiler-free helpers (index generator, add-menu builders/writers).package.json—"./tools": "./dist/tools.js"added toexports;lib/tools.tsappended to thebuild:typestsup entry list. For wix-deploy and wix-media,compiler-jay-htmlandcompiler-sharedmoved fromdependenciestopeerDependencies(+ retained asdevDependencies).vite.config.ts—toolsadded to the SSRlib.entry;/^@jay-framework\/compiler-/added torollupOptions.external(wix-media's two explicit compiler externals were collapsed into the regex; wix-deploy's regex sits alongside itspublicDepsarray).- wix-media
plugin.yaml— the 5 settings actions converted to object form withdevOnly: true(the/wix-media/settingsroute was alreadydevOnly).
Verification
- Leak scan (DL#179):
dist/index.jscontains 0@jay-framework/compiler-imports for all 9 plugins. In wix-deploy and wix-media the compiler imports are confined todist/tools.jsas externalized import strings (wix-deploy:compiler-jay-html,compiler-shared,compiler-jay-stack,compiler-analyze-exported-types; wix-media:compiler-jay-html,compiler-shared). yarn build: 26/26 packages built successfully (10 wix packages + explorations + all example apps).jay-stack-cli validate-pluginruns inside each plugin build and passed for every plugin, confirming the loaders resolve the tools capabilities from./tools.yarn build:check-types: exit 0 across the repo.
Deviations
None. The plan was followed as written.
Log Methodology Note
Note: These design logs are written primarily for AI agents as part of the Design Log methodology and made accessible here for human readers. The language and structure are optimized for machine consumption — expect precise, specification-style prose rather than narrative documentation.