@jay-framework/production-server 0.18.0 → 0.18.2
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.d.ts +2 -2
- package/dist/index.js +33 -8
- package/dist/{init-services-BKVwxzYb.js → init-services-F6Svgfm9.js} +5 -2
- package/dist/{serve-index-9aAW1pbg.d.ts → serve-index-GLq2Yw4z.d.ts} +2 -0
- package/dist/serve-index.d.ts +1 -1
- package/dist/serve-index.js +1 -1
- package/package.json +12 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BuildOptions, R as RouteManifest, a as RouteEntry } from './serve-index-
|
|
2
|
-
export { A as ActionEntry, e as ArtifactStore, c as BuildMetadata, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, d as PageModule, P as PluginEntry, n as PreImportedPlugin, b as RouteSegment, S as ServerElementModule, g as fetchActionRequest, f as fetchPageRequest, j as fetchStaticFile, k as initializeServices, l as initializeServicesFromModules, i as isActionRequest, m as matchRequest, r as registerActionsFromManifest, h as registerActionsFromModules } from './serve-index-
|
|
1
|
+
import { B as BuildOptions, R as RouteManifest, a as RouteEntry } from './serve-index-GLq2Yw4z.js';
|
|
2
|
+
export { A as ActionEntry, e as ArtifactStore, c as BuildMetadata, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, d as PageModule, P as PluginEntry, n as PreImportedPlugin, b as RouteSegment, S as ServerElementModule, g as fetchActionRequest, f as fetchPageRequest, j as fetchStaticFile, k as initializeServices, l as initializeServicesFromModules, i as isActionRequest, m as matchRequest, r as registerActionsFromManifest, h as registerActionsFromModules } from './serve-index-GLq2Yw4z.js';
|
|
3
3
|
import '@jay-framework/ssr-runtime';
|
|
4
4
|
import '@jay-framework/stack-server-runtime';
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -6,14 +6,15 @@ import path from "node:path";
|
|
|
6
6
|
import fs from "node:fs/promises";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
import { DevSlowlyChangingPhase, slowRenderInstances, scanPlugins, runLoadParams, parseCookies } from "@jay-framework/stack-server-runtime";
|
|
9
|
-
import { l as loadProductionPageParts, g as buildPagePartsConfig, d as initializeServices, r as registerActionsFromManifest, i as isActionRequest, a as fetchActionRequest, c as fetchStaticFile, m as matchRequest, f as fetchPageRequest, F as FilesystemArtifactStore } from "./init-services-
|
|
10
|
-
import { e, b } from "./init-services-
|
|
9
|
+
import { l as loadProductionPageParts, g as buildPagePartsConfig, d as initializeServices, r as registerActionsFromManifest, i as isActionRequest, a as fetchActionRequest, c as fetchStaticFile, m as matchRequest, f as fetchPageRequest, F as FilesystemArtifactStore } from "./init-services-F6Svgfm9.js";
|
|
10
|
+
import { e, b } from "./init-services-F6Svgfm9.js";
|
|
11
11
|
import crypto from "node:crypto";
|
|
12
12
|
import fs$1 from "node:fs";
|
|
13
13
|
import { jayRuntime } from "@jay-framework/vite-plugin";
|
|
14
14
|
import { injectHeadfullFSTemplates, JAY_IMPORT_RESOLVER, parseJayFile, generateElementHydrateFile, generateServerElementFile } from "@jay-framework/compiler-jay-html";
|
|
15
15
|
import { checkValidationErrors, RuntimeMode } from "@jay-framework/compiler-shared";
|
|
16
16
|
import { parse } from "node-html-parser";
|
|
17
|
+
import { transform } from "esbuild";
|
|
17
18
|
import http from "node:http";
|
|
18
19
|
import { Readable } from "node:stream";
|
|
19
20
|
import { isJayWebhook } from "@jay-framework/fullstack-component";
|
|
@@ -507,7 +508,7 @@ function resolvePluginModule(pluginPath) {
|
|
|
507
508
|
}
|
|
508
509
|
return path.join(pluginPath, "dist", "index.js");
|
|
509
510
|
}
|
|
510
|
-
async function compileServerElement(jayHtmlContent, jayHtmlFilename, jayHtmlDir, outputPath, projectRoot, tsConfigFilePath, sourceDir) {
|
|
511
|
+
async function compileServerElement(jayHtmlContent, jayHtmlFilename, jayHtmlDir, outputPath, projectRoot, tsConfigFilePath, sourceDir, minifyCss = true) {
|
|
511
512
|
const jayFile = await parseJayFile(
|
|
512
513
|
jayHtmlContent,
|
|
513
514
|
jayHtmlFilename,
|
|
@@ -545,17 +546,24 @@ async function compileServerElement(jayHtmlContent, jayHtmlFilename, jayHtmlDir,
|
|
|
545
546
|
});
|
|
546
547
|
await fs.rm(tsPath, { force: true });
|
|
547
548
|
let cssFile;
|
|
549
|
+
let cssImports;
|
|
548
550
|
const css = parsedJayFile.css;
|
|
549
551
|
if (css) {
|
|
552
|
+
cssImports = extractCssImportUrls(css);
|
|
550
553
|
const cssFilename = path.basename(outputPath, ".server-element.js") + ".css";
|
|
551
554
|
const cssPath = path.join(outputDir, cssFilename);
|
|
552
|
-
|
|
555
|
+
if (minifyCss) {
|
|
556
|
+
const minified = await transform(css, { loader: "css", minify: true });
|
|
557
|
+
await fs.writeFile(cssPath, minified.code, "utf-8");
|
|
558
|
+
} else {
|
|
559
|
+
await fs.writeFile(cssPath, css, "utf-8");
|
|
560
|
+
}
|
|
553
561
|
cssFile = cssFilename;
|
|
554
562
|
}
|
|
555
563
|
getLogger().info(`[Build] Compiled server element: ${path.basename(outputPath)}`);
|
|
556
|
-
return { cssFile };
|
|
564
|
+
return { cssFile, cssImports };
|
|
557
565
|
}
|
|
558
|
-
async function compileRouteServerElement(jayHtmlPath, outputPath, projectRoot, tsConfigFilePath) {
|
|
566
|
+
async function compileRouteServerElement(jayHtmlPath, outputPath, projectRoot, tsConfigFilePath, minifyCss = true) {
|
|
559
567
|
const jayHtmlContent = await fs.readFile(jayHtmlPath, "utf-8");
|
|
560
568
|
const sourceDir = path.dirname(jayHtmlPath);
|
|
561
569
|
const outputDir = path.dirname(outputPath);
|
|
@@ -568,7 +576,8 @@ async function compileRouteServerElement(jayHtmlPath, outputPath, projectRoot, t
|
|
|
568
576
|
outputPath,
|
|
569
577
|
projectRoot,
|
|
570
578
|
tsConfigFilePath,
|
|
571
|
-
sourceDir
|
|
579
|
+
sourceDir,
|
|
580
|
+
minifyCss
|
|
572
581
|
);
|
|
573
582
|
}
|
|
574
583
|
async function compileRouteHydrateScript(jayHtmlPath, outputDir, projectRoot, tsConfigFilePath, minify = true) {
|
|
@@ -655,6 +664,18 @@ function resolveJayHtmlPaths(html, sourceDir, targetDir) {
|
|
|
655
664
|
}
|
|
656
665
|
return root.toString();
|
|
657
666
|
}
|
|
667
|
+
function extractCssImportUrls(css) {
|
|
668
|
+
const imports = [];
|
|
669
|
+
const re = /@import\s*(?:url\(\s*['"]?([^'")]+)['"]?\s*\)|['"]([^'"]+)['"])/g;
|
|
670
|
+
let match;
|
|
671
|
+
while ((match = re.exec(css)) !== null) {
|
|
672
|
+
const url = match[1] || match[2];
|
|
673
|
+
if (url.startsWith("https://")) {
|
|
674
|
+
imports.push(url);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return imports;
|
|
678
|
+
}
|
|
658
679
|
async function generateRouteHydrationEntry(options) {
|
|
659
680
|
const {
|
|
660
681
|
hydrateImport,
|
|
@@ -1130,7 +1151,8 @@ async function buildVersion(options) {
|
|
|
1130
1151
|
route.jayHtmlPath,
|
|
1131
1152
|
serverElementPath,
|
|
1132
1153
|
options.projectRoot,
|
|
1133
|
-
options.tsConfigFilePath
|
|
1154
|
+
options.tsConfigFilePath,
|
|
1155
|
+
options.minify ?? true
|
|
1134
1156
|
);
|
|
1135
1157
|
entry.serverElementPath = path.relative(backendDir, serverElementPath);
|
|
1136
1158
|
if (seResult.cssFile) {
|
|
@@ -1144,6 +1166,9 @@ async function buildVersion(options) {
|
|
|
1144
1166
|
}
|
|
1145
1167
|
entry.routeCssPath = path.relative(frontendDir, dstCss);
|
|
1146
1168
|
}
|
|
1169
|
+
if (seResult.cssImports?.length) {
|
|
1170
|
+
entry.cssImports = seResult.cssImports;
|
|
1171
|
+
}
|
|
1147
1172
|
logger.important(`[Build] Route server element: ${routeDir}`);
|
|
1148
1173
|
} catch (err) {
|
|
1149
1174
|
logger.error(`[Build] Route server element FAILED ${route.rawRoute}: ${err.message}`);
|
|
@@ -436,7 +436,10 @@ async function fetchPageRequest(match, manifest, requestUrl, artifacts, staticBa
|
|
|
436
436
|
importMap["jay-route-hydrate"] = `${staticBaseUrl}${route.routeHydratePath}`;
|
|
437
437
|
}
|
|
438
438
|
const modulePreloads = Object.values(importMap).map((url) => ` <link rel="modulepreload" href="${url}" />`).join("\n");
|
|
439
|
-
const
|
|
439
|
+
const cssUrl = instance.clientCssPath ? `${staticBaseUrl}${instance.clientCssPath}` : "";
|
|
440
|
+
const cssPreload = cssUrl ? ` <link rel="preload" href="${cssUrl}" as="style" />` : "";
|
|
441
|
+
const cssLink = cssUrl ? ` <link rel="stylesheet" href="${cssUrl}" />` : "";
|
|
442
|
+
const cssImportPreloads = (route.cssImports ?? []).map((url) => ` <link rel="preload" href="${url}" as="style" />`).join("\n");
|
|
440
443
|
const encoder = new TextEncoder();
|
|
441
444
|
const stream = new ReadableStream({
|
|
442
445
|
async start(controller) {
|
|
@@ -447,7 +450,7 @@ async function fetchPageRequest(match, manifest, requestUrl, artifacts, staticBa
|
|
|
447
450
|
<head>
|
|
448
451
|
<meta charset="UTF-8" />
|
|
449
452
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
450
|
-
<script type="importmap">${JSON.stringify({ imports: importMap })}<\/script>
|
|
453
|
+
${[cssPreload, cssImportPreloads].filter(Boolean).map((l) => l + "\n").join("")} <script type="importmap">${JSON.stringify({ imports: importMap })}<\/script>
|
|
451
454
|
${headParts}
|
|
452
455
|
</head>
|
|
453
456
|
<body>
|
|
@@ -30,6 +30,8 @@ interface RouteEntry {
|
|
|
30
30
|
routeHydratePath?: string;
|
|
31
31
|
/** Per-route client bundle path (DL#144). Entry that imports route hydrate script. */
|
|
32
32
|
routeClientBundlePath?: string;
|
|
33
|
+
/** External @import URLs extracted from CSS at build time (DL#146). Used for preload hints. */
|
|
34
|
+
cssImports?: string[];
|
|
33
35
|
instances: InstanceEntry[];
|
|
34
36
|
isPlugin?: boolean;
|
|
35
37
|
pluginName?: string;
|
package/dist/serve-index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { e as ArtifactStore, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, n as PreImportedPlugin, a as RouteEntry, R as RouteManifest, S as ServerElementModule, g as fetchActionRequest, f as fetchPageRequest, j as fetchStaticFile, k as initializeServices, l as initializeServicesFromModules, i as isActionRequest, m as matchRequest, r as registerActionsFromManifest, h as registerActionsFromModules } from './serve-index-
|
|
1
|
+
export { e as ArtifactStore, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, n as PreImportedPlugin, a as RouteEntry, R as RouteManifest, S as ServerElementModule, g as fetchActionRequest, f as fetchPageRequest, j as fetchStaticFile, k as initializeServices, l as initializeServicesFromModules, i as isActionRequest, m as matchRequest, r as registerActionsFromManifest, h as registerActionsFromModules } from './serve-index-GLq2Yw4z.js';
|
|
2
2
|
import '@jay-framework/ssr-runtime';
|
|
3
3
|
import '@jay-framework/stack-server-runtime';
|
package/dist/serve-index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/production-server",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"test:watch": "vitest"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@jay-framework/compiler-jay-html": "^0.18.
|
|
34
|
-
"@jay-framework/compiler-jay-stack": "^0.18.
|
|
35
|
-
"@jay-framework/compiler-shared": "^0.18.
|
|
36
|
-
"@jay-framework/fullstack-component": "^0.18.
|
|
37
|
-
"@jay-framework/logger": "^0.18.
|
|
38
|
-
"@jay-framework/ssr-runtime": "^0.18.
|
|
39
|
-
"@jay-framework/stack-route-scanner": "^0.18.
|
|
40
|
-
"@jay-framework/stack-server-runtime": "^0.18.
|
|
41
|
-
"@jay-framework/view-state-merge": "^0.18.
|
|
42
|
-
"@jay-framework/vite-plugin": "^0.18.
|
|
33
|
+
"@jay-framework/compiler-jay-html": "^0.18.2",
|
|
34
|
+
"@jay-framework/compiler-jay-stack": "^0.18.2",
|
|
35
|
+
"@jay-framework/compiler-shared": "^0.18.2",
|
|
36
|
+
"@jay-framework/fullstack-component": "^0.18.2",
|
|
37
|
+
"@jay-framework/logger": "^0.18.2",
|
|
38
|
+
"@jay-framework/ssr-runtime": "^0.18.2",
|
|
39
|
+
"@jay-framework/stack-route-scanner": "^0.18.2",
|
|
40
|
+
"@jay-framework/stack-server-runtime": "^0.18.2",
|
|
41
|
+
"@jay-framework/view-state-merge": "^0.18.2",
|
|
42
|
+
"@jay-framework/vite-plugin": "^0.18.2",
|
|
43
43
|
"vite": "^5.0.11"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@jay-framework/dev-environment": "^0.18.
|
|
46
|
+
"@jay-framework/dev-environment": "^0.18.2",
|
|
47
47
|
"@types/node": "^22.15.21",
|
|
48
48
|
"rimraf": "^5.0.5",
|
|
49
49
|
"tsup": "^8.0.1",
|