@jay-framework/jay-stack-cli 0.16.1 → 0.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,8 @@ A plugin provides headless components (data + interactions, no UI) that project
13
13
  3. **Define actions** with `.jay-action` metadata
14
14
  4. **Optionally add routes** — pages for admin tools and dashboards
15
15
  5. **Set up `plugin.yaml`** — list contracts, actions, services, contexts, routes
16
- 6. **Validate** with `jay-stack validate-plugin`
16
+ 6. **Configure build** dual entry points (server + client), vite.config.ts, package.json exports
17
+ 7. **Validate** with `jay-stack validate-plugin`
17
18
 
18
19
  ## Guides
19
20
 
@@ -161,22 +161,101 @@ my-project/
161
161
 
162
162
  See `examples/jay-stack/fake-shop` for a working example.
163
163
 
164
+ ## Dual Entry Points
165
+
166
+ Jay plugins are fullstack — they run on both server and client. The build produces two bundles:
167
+
168
+ - **Server** (`dist/index.js`) — actions, services, SSR rendering, `init()`. Built with `vite build --ssr`.
169
+ - **Client** (`dist/index.client.js`) — components for hydration, context tokens, `init()`. Built with `vite build`.
170
+
171
+ Create two entry files:
172
+
173
+ | File | Exports |
174
+ | --------------------- | ---------------------------------------------------------- |
175
+ | `lib/index.ts` | Actions, services, components (SSR), init, service markers |
176
+ | `lib/index.client.ts` | Components (hydration), context markers, init |
177
+
178
+ Actions and service providers are server-only. Components appear in **both** entries.
179
+
180
+ ## Build Scripts
181
+
182
+ ```json
183
+ {
184
+ "scripts": {
185
+ "build": "npm run clean && npm run definitions && npm run build:client && npm run build:server && npm run build:copy-assets && npm run build:types && npm run validate",
186
+ "definitions": "jay-cli definitions lib",
187
+ "build:client": "vite build",
188
+ "build:server": "vite build --ssr",
189
+ "build:copy-assets": "cp lib/*.jay-contract* dist/",
190
+ "build:types": "tsup lib/index.ts lib/index.client.ts --dts-only --format esm",
191
+ "validate": "jay-stack-cli validate-plugin",
192
+ "clean": "rimraf dist"
193
+ }
194
+ }
195
+ ```
196
+
197
+ The `vite.config.ts` uses `isSsrBuild` to switch entry points:
198
+
199
+ ```typescript
200
+ import { resolve } from 'path';
201
+ import { defineConfig } from 'vite';
202
+ import { jayStackCompiler } from '@jay-framework/compiler-jay-stack';
203
+
204
+ const jayOptions = { tsConfigFilePath: resolve(__dirname, 'tsconfig.json'), outputDir: 'build' };
205
+
206
+ export default defineConfig(({ isSsrBuild }) => ({
207
+ plugins: [...jayStackCompiler(jayOptions)],
208
+ build: {
209
+ minify: false,
210
+ ssr: isSsrBuild,
211
+ emptyOutDir: false,
212
+ lib: {
213
+ entry: isSsrBuild
214
+ ? { index: resolve(__dirname, 'lib/index.ts') }
215
+ : { 'index.client': resolve(__dirname, 'lib/index.client.ts') },
216
+ formats: ['es'],
217
+ },
218
+ rollupOptions: {
219
+ external: [
220
+ '@jay-framework/component',
221
+ '@jay-framework/fullstack-component',
222
+ '@jay-framework/stack-client-runtime',
223
+ '@jay-framework/stack-server-runtime',
224
+ '@jay-framework/reactive',
225
+ '@jay-framework/runtime',
226
+ ],
227
+ },
228
+ },
229
+ }));
230
+ ```
231
+
164
232
  ## package.json Exports
165
233
 
166
- For NPM packages, declare exports so the framework can resolve the plugin:
234
+ For NPM packages, declare exports for both server and client entry points:
167
235
 
168
236
  ```json
169
237
  {
170
238
  "name": "@my-org/my-plugin",
171
239
  "type": "module",
240
+ "main": "dist/index.js",
172
241
  "exports": {
173
- ".": "./dist/index.js",
174
- "./plugin.yaml": "./plugin.yaml"
242
+ ".": {
243
+ "types": "./dist/index.d.ts",
244
+ "default": "./dist/index.js"
245
+ },
246
+ "./client": {
247
+ "types": "./dist/index.client.d.ts",
248
+ "default": "./dist/index.client.js"
249
+ },
250
+ "./plugin.yaml": "./plugin.yaml",
251
+ "./my-contract.jay-contract": "./dist/my-contract.jay-contract"
175
252
  },
176
- "files": ["dist", "plugin.yaml", "lib/contracts", "lib/actions"]
253
+ "files": ["dist", "plugin.yaml"]
177
254
  }
178
255
  ```
179
256
 
257
+ The `./client` export is required — the framework uses it for browser-side hydration code. The `.` export handles server-side rendering and action execution.
258
+
180
259
  ## Plugin-Contributed Agent-Kit Guides
181
260
 
182
261
  A plugin can include guides that are merged into the project's agent-kit during `jay-stack agent-kit`. Create an `agent-kit/` folder with subfolders for each role:
package/dist/index.js CHANGED
@@ -3452,6 +3452,14 @@ async function validatePackageJson(context, result) {
3452
3452
  suggestion: 'Add "." export for the main module entry'
3453
3453
  });
3454
3454
  }
3455
+ if (!packageJson.exports["./client"]) {
3456
+ result.warnings.push({
3457
+ type: "export-mismatch",
3458
+ message: 'package.json exports missing "./client" entry point',
3459
+ location: packageJsonPath,
3460
+ suggestion: 'Add "./client": "./dist/index.client.js" to exports. The client bundle provides components for hydration and client-side contexts. Build with: vite build (client) + vite build --ssr (server)'
3461
+ });
3462
+ }
3455
3463
  if (context.manifest.contracts) {
3456
3464
  for (const contract of context.manifest.contracts) {
3457
3465
  const contractExport = "./" + contract.contract;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/jay-stack-cli",
3
- "version": "0.16.1",
3
+ "version": "0.16.3",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,14 +24,14 @@
24
24
  "test:watch": "vitest"
25
25
  },
26
26
  "dependencies": {
27
- "@jay-framework/compiler-jay-html": "^0.16.1",
28
- "@jay-framework/compiler-shared": "^0.16.1",
29
- "@jay-framework/dev-server": "^0.16.1",
30
- "@jay-framework/editor-server": "^0.16.1",
31
- "@jay-framework/fullstack-component": "^0.16.1",
32
- "@jay-framework/logger": "^0.16.1",
33
- "@jay-framework/plugin-validator": "^0.16.1",
34
- "@jay-framework/stack-server-runtime": "^0.16.1",
27
+ "@jay-framework/compiler-jay-html": "^0.16.3",
28
+ "@jay-framework/compiler-shared": "^0.16.3",
29
+ "@jay-framework/dev-server": "^0.16.3",
30
+ "@jay-framework/editor-server": "^0.16.3",
31
+ "@jay-framework/fullstack-component": "^0.16.3",
32
+ "@jay-framework/logger": "^0.16.3",
33
+ "@jay-framework/plugin-validator": "^0.16.3",
34
+ "@jay-framework/stack-server-runtime": "^0.16.3",
35
35
  "chalk": "^4.1.2",
36
36
  "commander": "^14.0.0",
37
37
  "express": "^5.0.1",
@@ -42,7 +42,7 @@
42
42
  "yaml": "^2.3.4"
43
43
  },
44
44
  "devDependencies": {
45
- "@jay-framework/dev-environment": "^0.16.1",
45
+ "@jay-framework/dev-environment": "^0.16.3",
46
46
  "@types/express": "^5.0.2",
47
47
  "@types/node": "^22.15.21",
48
48
  "nodemon": "^3.0.3",