@jay-framework/dev-server 0.14.0 → 0.15.1
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.
- package/dist/index.js +26 -9
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -10,10 +10,11 @@ import { createRequire } from "module";
|
|
|
10
10
|
import "@jay-framework/compiler-shared";
|
|
11
11
|
import * as path from "node:path";
|
|
12
12
|
import path__default from "node:path";
|
|
13
|
-
import { parseContract, slowRenderTransform,
|
|
13
|
+
import { JAY_IMPORT_RESOLVER, injectHeadfullFSTemplates, parseContract, slowRenderTransform, discoverHeadlessInstances, resolveHeadlessInstances } from "@jay-framework/compiler-jay-html";
|
|
14
14
|
import { getLogger, getDevLogger } from "@jay-framework/logger";
|
|
15
15
|
import { createRequire as createRequire$1 } from "node:module";
|
|
16
16
|
import * as fs from "node:fs";
|
|
17
|
+
import crypto from "node:crypto";
|
|
17
18
|
import { scanRoutes, routeToExpressRoute } from "@jay-framework/stack-route-scanner";
|
|
18
19
|
import { discoverPluginsWithInit, sortPluginsByDependencies, executePluginServerInits, runInitCallbacks, actionRegistry, discoverAndRegisterActions, discoverAllPluginActions, runShutdownCallbacks, clearLifecycleCallbacks, clearServiceRegistry, clearClientInitData, DevSlowlyChangingPhase, SlowRenderCache, preparePluginClientInits, invalidateServerElementCache, getServiceRegistry, materializeContracts, loadPageParts, renderFastChangingData, generateClientScript, getClientInitData, generateSSRPageHtml, validateForEachInstances, slowRenderInstances } from "@jay-framework/stack-server-runtime";
|
|
19
20
|
import fs$1 from "node:fs/promises";
|
|
@@ -1364,6 +1365,8 @@ async function createViteServer(options) {
|
|
|
1364
1365
|
logLevel = "info",
|
|
1365
1366
|
clearScreen = true
|
|
1366
1367
|
} = options;
|
|
1368
|
+
const instanceId = crypto.randomBytes(4).toString("hex");
|
|
1369
|
+
const cacheDir = path__default.join(projectRoot, "node_modules", `.vite-${instanceId}`);
|
|
1367
1370
|
const vite = await createServer({
|
|
1368
1371
|
// Don't start HTTP server - we use middleware mode
|
|
1369
1372
|
server: { middlewareMode: true, watch: { ignored: ["**/build/**"] } },
|
|
@@ -1375,6 +1378,8 @@ async function createViteServer(options) {
|
|
|
1375
1378
|
base,
|
|
1376
1379
|
// Root directory for module resolution
|
|
1377
1380
|
root: pagesRoot,
|
|
1381
|
+
// Isolate dep optimization cache per instance
|
|
1382
|
+
cacheDir,
|
|
1378
1383
|
// SSR configuration
|
|
1379
1384
|
ssr: {
|
|
1380
1385
|
// Mark jay-framework packages as external so Vite uses Node's require
|
|
@@ -1390,6 +1395,13 @@ async function createViteServer(options) {
|
|
|
1390
1395
|
logLevel,
|
|
1391
1396
|
clearScreen
|
|
1392
1397
|
});
|
|
1398
|
+
const originalClose = vite.close.bind(vite);
|
|
1399
|
+
vite.close = async () => {
|
|
1400
|
+
await originalClose();
|
|
1401
|
+
const { rm } = await import("node:fs/promises");
|
|
1402
|
+
await rm(cacheDir, { recursive: true, force: true }).catch(() => {
|
|
1403
|
+
});
|
|
1404
|
+
};
|
|
1393
1405
|
return vite;
|
|
1394
1406
|
}
|
|
1395
1407
|
async function createViteForCli(options) {
|
|
@@ -2204,9 +2216,11 @@ async function sendResponse(vite, res, url, jayHtmlPath, sourceJayHtmlPath, page
|
|
|
2204
2216
|
let pageHtml;
|
|
2205
2217
|
const routeDir = path__default.dirname(path__default.relative(options.pagesRootFolder, sourceJayHtmlPath));
|
|
2206
2218
|
try {
|
|
2207
|
-
|
|
2219
|
+
let jayHtmlContent = preLoadedContent ?? await fs$1.readFile(jayHtmlPath, "utf-8");
|
|
2208
2220
|
const jayHtmlFilename = path__default.basename(jayHtmlPath);
|
|
2209
2221
|
const jayHtmlDir = path__default.dirname(jayHtmlPath);
|
|
2222
|
+
const sourceDir = path__default.dirname(sourceJayHtmlPath);
|
|
2223
|
+
jayHtmlContent = injectHeadfullFSTemplates(jayHtmlContent, sourceDir, JAY_IMPORT_RESOLVER);
|
|
2210
2224
|
pageHtml = await generateSSRPageHtml(
|
|
2211
2225
|
vite,
|
|
2212
2226
|
jayHtmlContent,
|
|
@@ -2284,12 +2298,18 @@ async function preRenderJayHtml(route, slowViewState, headlessContracts, headles
|
|
|
2284
2298
|
`[SlowRender] Page ${route.jayHtmlPath} has slow ViewState but no contract. Without a contract, slow bindings cannot be resolved. Move data to withFastRender or add a .jay-contract file with phase annotations.`
|
|
2285
2299
|
);
|
|
2286
2300
|
}
|
|
2287
|
-
const
|
|
2301
|
+
const sourceDir = path__default.dirname(route.jayHtmlPath);
|
|
2302
|
+
const jayHtmlWithTemplates = injectHeadfullFSTemplates(
|
|
2288
2303
|
jayHtmlContent,
|
|
2304
|
+
sourceDir,
|
|
2305
|
+
JAY_IMPORT_RESOLVER
|
|
2306
|
+
);
|
|
2307
|
+
const result = slowRenderTransform({
|
|
2308
|
+
jayHtmlContent: jayHtmlWithTemplates,
|
|
2289
2309
|
slowViewState,
|
|
2290
2310
|
contract,
|
|
2291
2311
|
headlessContracts,
|
|
2292
|
-
sourceDir
|
|
2312
|
+
sourceDir,
|
|
2293
2313
|
importResolver: JAY_IMPORT_RESOLVER
|
|
2294
2314
|
});
|
|
2295
2315
|
if (!result.val) {
|
|
@@ -2424,7 +2444,7 @@ async function mkDevServer(rawOptions) {
|
|
|
2424
2444
|
const slowlyPhase = new DevSlowlyChangingPhase();
|
|
2425
2445
|
const slowRenderCacheDir = path__default.join(buildFolder, "pre-rendered");
|
|
2426
2446
|
const slowRenderCache = new SlowRenderCache(slowRenderCacheDir, pagesRootFolder);
|
|
2427
|
-
setupSlowRenderCacheInvalidation(vite, slowRenderCache,
|
|
2447
|
+
setupSlowRenderCacheInvalidation(vite, slowRenderCache, pagesRootFolder);
|
|
2428
2448
|
const projectInit = lifecycleManager.getProjectInit() ?? void 0;
|
|
2429
2449
|
const pluginsWithInit = lifecycleManager.getPluginsWithInit();
|
|
2430
2450
|
const pluginClientInits = preparePluginClientInits(pluginsWithInit);
|
|
@@ -2483,14 +2503,13 @@ function setupActionRouter(vite) {
|
|
|
2483
2503
|
vite.middlewares.use(ACTION_ENDPOINT_BASE, createActionRouter());
|
|
2484
2504
|
getLogger().info(`[Actions] Action router mounted at ${ACTION_ENDPOINT_BASE}`);
|
|
2485
2505
|
}
|
|
2486
|
-
function setupSlowRenderCacheInvalidation(vite, cache,
|
|
2506
|
+
function setupSlowRenderCacheInvalidation(vite, cache, pagesRootFolder) {
|
|
2487
2507
|
vite.watcher.on("change", (changedPath) => {
|
|
2488
2508
|
if (!changedPath.startsWith(pagesRootFolder)) {
|
|
2489
2509
|
return;
|
|
2490
2510
|
}
|
|
2491
2511
|
if (changedPath.endsWith(".jay-html")) {
|
|
2492
2512
|
invalidateServerElementCache(changedPath);
|
|
2493
|
-
slowlyPhase.invalidateLoadParamsCache(changedPath);
|
|
2494
2513
|
cache.invalidate(changedPath).then(() => {
|
|
2495
2514
|
getLogger().info(`[SlowRender] Cache invalidated for ${changedPath}`);
|
|
2496
2515
|
});
|
|
@@ -2499,7 +2518,6 @@ function setupSlowRenderCacheInvalidation(vite, cache, slowlyPhase, pagesRootFol
|
|
|
2499
2518
|
if (changedPath.endsWith("page.ts")) {
|
|
2500
2519
|
const dir = path__default.dirname(changedPath);
|
|
2501
2520
|
const jayHtmlPath = path__default.join(dir, "page.jay-html");
|
|
2502
|
-
slowlyPhase.invalidateLoadParamsCache(jayHtmlPath);
|
|
2503
2521
|
cache.invalidate(jayHtmlPath).then(() => {
|
|
2504
2522
|
getLogger().info(
|
|
2505
2523
|
`[SlowRender] Cache invalidated for ${jayHtmlPath} (page.ts changed)`
|
|
@@ -2509,7 +2527,6 @@ function setupSlowRenderCacheInvalidation(vite, cache, slowlyPhase, pagesRootFol
|
|
|
2509
2527
|
}
|
|
2510
2528
|
if (changedPath.endsWith(".jay-contract")) {
|
|
2511
2529
|
const jayHtmlPath = changedPath.replace(".jay-contract", ".jay-html");
|
|
2512
|
-
slowlyPhase.invalidateLoadParamsCache(jayHtmlPath);
|
|
2513
2530
|
cache.invalidate(jayHtmlPath).then(() => {
|
|
2514
2531
|
getLogger().info(
|
|
2515
2532
|
`[SlowRender] Cache invalidated for ${jayHtmlPath} (contract changed)`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
"test:watch": "vitest"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@jay-framework/compiler-jay-stack": "^0.
|
|
27
|
-
"@jay-framework/compiler-shared": "^0.
|
|
28
|
-
"@jay-framework/component": "^0.
|
|
29
|
-
"@jay-framework/fullstack-component": "^0.
|
|
30
|
-
"@jay-framework/logger": "^0.
|
|
31
|
-
"@jay-framework/runtime": "^0.
|
|
32
|
-
"@jay-framework/stack-client-runtime": "^0.
|
|
33
|
-
"@jay-framework/stack-route-scanner": "^0.
|
|
34
|
-
"@jay-framework/stack-server-runtime": "^0.
|
|
35
|
-
"@jay-framework/view-state-merge": "^0.
|
|
26
|
+
"@jay-framework/compiler-jay-stack": "^0.15.1",
|
|
27
|
+
"@jay-framework/compiler-shared": "^0.15.1",
|
|
28
|
+
"@jay-framework/component": "^0.15.1",
|
|
29
|
+
"@jay-framework/fullstack-component": "^0.15.1",
|
|
30
|
+
"@jay-framework/logger": "^0.15.1",
|
|
31
|
+
"@jay-framework/runtime": "^0.15.1",
|
|
32
|
+
"@jay-framework/stack-client-runtime": "^0.15.1",
|
|
33
|
+
"@jay-framework/stack-route-scanner": "^0.15.1",
|
|
34
|
+
"@jay-framework/stack-server-runtime": "^0.15.1",
|
|
35
|
+
"@jay-framework/view-state-merge": "^0.15.1",
|
|
36
36
|
"vite": "^5.0.11"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@jay-framework/dev-environment": "^0.
|
|
40
|
-
"@jay-framework/jay-cli": "^0.
|
|
41
|
-
"@jay-framework/stack-client-runtime": "^0.
|
|
39
|
+
"@jay-framework/dev-environment": "^0.15.1",
|
|
40
|
+
"@jay-framework/jay-cli": "^0.15.1",
|
|
41
|
+
"@jay-framework/stack-client-runtime": "^0.15.1",
|
|
42
42
|
"@playwright/test": "^1.58.2",
|
|
43
43
|
"@types/express": "^5.0.2",
|
|
44
44
|
"@types/node": "^22.15.21",
|