@jay-framework/dev-server 0.15.3 → 0.15.5
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 +15 -27
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -14,7 +14,6 @@ import { JAY_IMPORT_RESOLVER, injectHeadfullFSTemplates, parseContract, slowRend
|
|
|
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";
|
|
18
17
|
import { scanRoutes, routeToExpressRoute } from "@jay-framework/stack-route-scanner";
|
|
19
18
|
import { discoverPluginsWithInit, sortPluginsByDependencies, executePluginServerInits, runInitCallbacks, actionRegistry, discoverAndRegisterActions, discoverAllPluginActions, runShutdownCallbacks, clearLifecycleCallbacks, clearServiceRegistry, clearClientInitData, DevSlowlyChangingPhase, SlowRenderCache, preparePluginClientInits, clearServerElementCache, getServiceRegistry, materializeContracts, loadPageParts, renderFastChangingData, generateClientScript, getClientInitData, generateSSRPageHtml, validateForEachInstances, slowRenderInstances } from "@jay-framework/stack-server-runtime";
|
|
20
19
|
import fs$1 from "node:fs/promises";
|
|
@@ -1366,8 +1365,6 @@ async function createViteServer(options) {
|
|
|
1366
1365
|
clearScreen = true,
|
|
1367
1366
|
httpServer
|
|
1368
1367
|
} = options;
|
|
1369
|
-
const instanceId = crypto.randomBytes(4).toString("hex");
|
|
1370
|
-
const cacheDir = path__default.join(projectRoot, "node_modules", `.vite-${instanceId}`);
|
|
1371
1368
|
const vite = await createServer({
|
|
1372
1369
|
// Don't start HTTP server - we use middleware mode
|
|
1373
1370
|
server: {
|
|
@@ -1383,8 +1380,6 @@ async function createViteServer(options) {
|
|
|
1383
1380
|
base,
|
|
1384
1381
|
// Root directory for module resolution
|
|
1385
1382
|
root: pagesRoot,
|
|
1386
|
-
// Isolate dep optimization cache per instance
|
|
1387
|
-
cacheDir,
|
|
1388
1383
|
// SSR configuration
|
|
1389
1384
|
ssr: {
|
|
1390
1385
|
// Mark jay-framework packages as external so Vite uses Node's require
|
|
@@ -1400,13 +1395,6 @@ async function createViteServer(options) {
|
|
|
1400
1395
|
logLevel,
|
|
1401
1396
|
clearScreen
|
|
1402
1397
|
});
|
|
1403
|
-
const originalClose = vite.close.bind(vite);
|
|
1404
|
-
vite.close = async () => {
|
|
1405
|
-
await originalClose();
|
|
1406
|
-
const { rm } = await import("node:fs/promises");
|
|
1407
|
-
await rm(cacheDir, { recursive: true, force: true }).catch(() => {
|
|
1408
|
-
});
|
|
1409
|
-
};
|
|
1410
1398
|
return vite;
|
|
1411
1399
|
}
|
|
1412
1400
|
async function createViteForCli(options) {
|
|
@@ -1766,6 +1754,10 @@ function createActionRouter(options) {
|
|
|
1766
1754
|
});
|
|
1767
1755
|
return;
|
|
1768
1756
|
}
|
|
1757
|
+
const timing = getDevLogger()?.startRequest(
|
|
1758
|
+
requestMethod,
|
|
1759
|
+
ACTION_ENDPOINT_BASE + "/" + actionName
|
|
1760
|
+
);
|
|
1769
1761
|
const result = await registry.execute(actionName, input);
|
|
1770
1762
|
if (requestMethod === "GET" && result.success) {
|
|
1771
1763
|
const cacheHeaders = registry.getCacheHeaders(actionName);
|
|
@@ -1785,6 +1777,7 @@ function createActionRouter(options) {
|
|
|
1785
1777
|
error: result.error
|
|
1786
1778
|
});
|
|
1787
1779
|
}
|
|
1780
|
+
timing?.end();
|
|
1788
1781
|
};
|
|
1789
1782
|
}
|
|
1790
1783
|
function getStatusCodeForError(code, isActionError) {
|
|
@@ -2081,11 +2074,13 @@ async function handlePreRenderRequest(vite, route, options, slowlyPhase, slowRen
|
|
|
2081
2074
|
timing?.end();
|
|
2082
2075
|
return;
|
|
2083
2076
|
}
|
|
2077
|
+
const partKeys = initialPartsResult.val.parts.map((p) => p.key).filter((k) => !!k);
|
|
2084
2078
|
const preRenderResult = await preRenderJayHtml(
|
|
2085
2079
|
route,
|
|
2086
2080
|
renderedSlowly.rendered,
|
|
2087
2081
|
initialPartsResult.val.headlessContracts,
|
|
2088
|
-
initialPartsResult.val.headlessInstanceComponents
|
|
2082
|
+
initialPartsResult.val.headlessInstanceComponents,
|
|
2083
|
+
partKeys
|
|
2089
2084
|
);
|
|
2090
2085
|
timing?.recordSlowRender(Date.now() - slowStart);
|
|
2091
2086
|
if (!preRenderResult) {
|
|
@@ -2204,7 +2199,7 @@ async function handleClientOnlyRequest(vite, route, options, slowlyPhase, pagePa
|
|
|
2204
2199
|
serverTrackByMap || {}
|
|
2205
2200
|
);
|
|
2206
2201
|
const fastCF = renderedFast.carryForward;
|
|
2207
|
-
const pageHtml = generateClientScript(
|
|
2202
|
+
const pageHtml = await generateClientScript(
|
|
2208
2203
|
viewState,
|
|
2209
2204
|
fastCF,
|
|
2210
2205
|
pageParts,
|
|
@@ -2262,7 +2257,7 @@ async function sendResponse(vite, res, url, jayHtmlPath, sourceJayHtmlPath, page
|
|
|
2262
2257
|
);
|
|
2263
2258
|
} catch (err) {
|
|
2264
2259
|
getLogger().warn(`[SSR] Failed, falling back to client rendering: ${err.message}`);
|
|
2265
|
-
pageHtml = generateClientScript(
|
|
2260
|
+
pageHtml = await generateClientScript(
|
|
2266
2261
|
viewState,
|
|
2267
2262
|
carryForward,
|
|
2268
2263
|
pageParts,
|
|
@@ -2289,7 +2284,7 @@ async function sendResponse(vite, res, url, jayHtmlPath, sourceJayHtmlPath, page
|
|
|
2289
2284
|
res.status(200).set({ "Content-Type": "text/html" }).send(compiledPageHtml);
|
|
2290
2285
|
timing?.end();
|
|
2291
2286
|
}
|
|
2292
|
-
async function preRenderJayHtml(route, slowViewState, headlessContracts, headlessInstanceComponents) {
|
|
2287
|
+
async function preRenderJayHtml(route, slowViewState, headlessContracts, headlessInstanceComponents, partKeys = []) {
|
|
2293
2288
|
const jayHtmlContent = await fs$1.readFile(route.jayHtmlPath, "utf-8");
|
|
2294
2289
|
const contractPath = route.jayHtmlPath.replace(".jay-html", ".jay-contract");
|
|
2295
2290
|
let contract;
|
|
@@ -2310,7 +2305,8 @@ async function preRenderJayHtml(route, slowViewState, headlessContracts, headles
|
|
|
2310
2305
|
return void 0;
|
|
2311
2306
|
}
|
|
2312
2307
|
}
|
|
2313
|
-
|
|
2308
|
+
const hasPageLevelSlowData = slowViewState && Object.keys(slowViewState).some((k) => !partKeys.includes(k));
|
|
2309
|
+
if (!contract && hasPageLevelSlowData) {
|
|
2314
2310
|
getLogger().warn(
|
|
2315
2311
|
`[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.`
|
|
2316
2312
|
);
|
|
@@ -2430,16 +2426,8 @@ async function mkDevServer(rawOptions) {
|
|
|
2430
2426
|
const options = defaults(rawOptions);
|
|
2431
2427
|
const { publicBaseUrlPath, pagesRootFolder, projectRootFolder, buildFolder, jayRollupConfig } = options;
|
|
2432
2428
|
if (buildFolder) {
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
for (const entry of entries) {
|
|
2436
|
-
if (entry !== "pre-rendered") {
|
|
2437
|
-
await fs$1.rm(path__default.join(buildFolder, entry), { recursive: true, force: true }).catch(() => {
|
|
2438
|
-
});
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
} catch {
|
|
2442
|
-
}
|
|
2429
|
+
await fs$1.rm(buildFolder, { recursive: true, force: true }).catch(() => {
|
|
2430
|
+
});
|
|
2443
2431
|
}
|
|
2444
2432
|
const viteLogLevel = options.logLevel === "silent" ? "silent" : options.logLevel === "verbose" ? "info" : "warn";
|
|
2445
2433
|
const lifecycleManager = new ServiceLifecycleManager(projectRootFolder);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/dev-server",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.5",
|
|
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.15.
|
|
27
|
-
"@jay-framework/compiler-shared": "^0.15.
|
|
28
|
-
"@jay-framework/component": "^0.15.
|
|
29
|
-
"@jay-framework/fullstack-component": "^0.15.
|
|
30
|
-
"@jay-framework/logger": "^0.15.
|
|
31
|
-
"@jay-framework/runtime": "^0.15.
|
|
32
|
-
"@jay-framework/stack-client-runtime": "^0.15.
|
|
33
|
-
"@jay-framework/stack-route-scanner": "^0.15.
|
|
34
|
-
"@jay-framework/stack-server-runtime": "^0.15.
|
|
35
|
-
"@jay-framework/view-state-merge": "^0.15.
|
|
26
|
+
"@jay-framework/compiler-jay-stack": "^0.15.5",
|
|
27
|
+
"@jay-framework/compiler-shared": "^0.15.5",
|
|
28
|
+
"@jay-framework/component": "^0.15.5",
|
|
29
|
+
"@jay-framework/fullstack-component": "^0.15.5",
|
|
30
|
+
"@jay-framework/logger": "^0.15.5",
|
|
31
|
+
"@jay-framework/runtime": "^0.15.5",
|
|
32
|
+
"@jay-framework/stack-client-runtime": "^0.15.5",
|
|
33
|
+
"@jay-framework/stack-route-scanner": "^0.15.5",
|
|
34
|
+
"@jay-framework/stack-server-runtime": "^0.15.5",
|
|
35
|
+
"@jay-framework/view-state-merge": "^0.15.5",
|
|
36
36
|
"vite": "^5.0.11"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@jay-framework/dev-environment": "^0.15.
|
|
40
|
-
"@jay-framework/jay-cli": "^0.15.
|
|
41
|
-
"@jay-framework/stack-client-runtime": "^0.15.
|
|
39
|
+
"@jay-framework/dev-environment": "^0.15.5",
|
|
40
|
+
"@jay-framework/jay-cli": "^0.15.5",
|
|
41
|
+
"@jay-framework/stack-client-runtime": "^0.15.5",
|
|
42
42
|
"@playwright/test": "^1.58.2",
|
|
43
43
|
"@types/express": "^5.0.2",
|
|
44
44
|
"@types/node": "^22.15.21",
|