vike-lite 1.13.4 → 1.14.0
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.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/server/store.d.ts
|
|
2
2
|
interface VikeState {
|
|
3
|
-
routes: typeof import('virtual:routes')['routes'];
|
|
4
|
-
errorRoute: typeof import('virtual:routes')['errorRoute'] | null;
|
|
5
|
-
config: typeof import('virtual:routes')['config'] | null;
|
|
6
|
-
manifest: typeof import('virtual:client-manifest')['default'] | null;
|
|
3
|
+
routes: typeof import('virtual:vike-lite/routes')['routes'];
|
|
4
|
+
errorRoute: typeof import('virtual:vike-lite/routes')['errorRoute'] | null;
|
|
5
|
+
config: typeof import('virtual:vike-lite/routes')['config'] | null;
|
|
6
|
+
manifest: typeof import('virtual:vike-lite/client-manifest')['default'] | null;
|
|
7
7
|
}
|
|
8
8
|
declare const store: VikeState;
|
|
9
9
|
declare function setVikeState(newState: Partial<VikeState>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/__internal/shared/matchRoute.d.ts
|
|
2
|
-
declare function matchRoute(urlPathname: string, routes: typeof import('virtual:routes').routes): {
|
|
2
|
+
declare function matchRoute(urlPathname: string, routes: typeof import('virtual:vike-lite/routes').routes): {
|
|
3
3
|
route: any;
|
|
4
4
|
routeParams: Record<string, string>;
|
|
5
5
|
} | null;
|
|
@@ -21,27 +21,7 @@ function withBase(file) {
|
|
|
21
21
|
return `${BASE_URL === "/" ? "" : BASE_URL.endsWith("/") ? BASE_URL.slice(0, -1) : BASE_URL}${file.startsWith("/") ? file : `/${file}`}`;
|
|
22
22
|
}
|
|
23
23
|
const assetsCache = /* @__PURE__ */ new WeakMap();
|
|
24
|
-
function
|
|
25
|
-
if (!isProd) return computeAssets(route, nonce);
|
|
26
|
-
const nonceKey = nonce || "";
|
|
27
|
-
let routeCache = assetsCache.get(route);
|
|
28
|
-
if (!routeCache) {
|
|
29
|
-
routeCache = /* @__PURE__ */ new Map();
|
|
30
|
-
assetsCache.set(route, routeCache);
|
|
31
|
-
}
|
|
32
|
-
let assets = routeCache.get(nonceKey);
|
|
33
|
-
if (!assets) {
|
|
34
|
-
assets = computeAssets(route, nonce);
|
|
35
|
-
routeCache.set(nonceKey, assets);
|
|
36
|
-
}
|
|
37
|
-
return assets;
|
|
38
|
-
}
|
|
39
|
-
function computeAssets(route, nonce) {
|
|
40
|
-
if (!isProd) return {
|
|
41
|
-
cssLinks: "",
|
|
42
|
-
jsPreloads: "",
|
|
43
|
-
entryClient: withBase("@id/virtual:entry-client")
|
|
44
|
-
};
|
|
24
|
+
function computeAssetFiles(route) {
|
|
45
25
|
const cssFiles = /* @__PURE__ */ new Set();
|
|
46
26
|
const jsFiles = /* @__PURE__ */ new Map();
|
|
47
27
|
const { manifest } = store;
|
|
@@ -68,11 +48,29 @@ function computeAssets(route, nonce) {
|
|
|
68
48
|
const criticalJs = [];
|
|
69
49
|
const sharedJs = [];
|
|
70
50
|
for (const [file, isCritical] of jsFiles) (isCritical ? criticalJs : sharedJs).push(file);
|
|
51
|
+
return {
|
|
52
|
+
cssFiles: [...cssFiles],
|
|
53
|
+
criticalJs,
|
|
54
|
+
sharedJs,
|
|
55
|
+
entryClientFile: manifest[virtualEntryClientKey].file
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function getAssets(route, nonce) {
|
|
59
|
+
if (!isProd) return {
|
|
60
|
+
cssLinks: "",
|
|
61
|
+
jsPreloads: "",
|
|
62
|
+
entryClient: withBase("@id/virtual:vike-lite/entry-client")
|
|
63
|
+
};
|
|
64
|
+
let files = assetsCache.get(route);
|
|
65
|
+
if (!files) {
|
|
66
|
+
files = computeAssetFiles(route);
|
|
67
|
+
assetsCache.set(route, files);
|
|
68
|
+
}
|
|
71
69
|
const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
|
|
72
70
|
return {
|
|
73
|
-
cssLinks:
|
|
74
|
-
jsPreloads: [...criticalJs.map((href) => `<link rel="modulepreload" href="${withBase(href)}" crossorigin fetchpriority="high"${nonceAttr}>`), ...sharedJs.map((href) => `<link rel="modulepreload" href="${withBase(href)}" crossorigin${nonceAttr}>`)].join(""),
|
|
75
|
-
entryClient: withBase(
|
|
71
|
+
cssLinks: files.cssFiles.map((href) => `<link rel="stylesheet" href="${withBase(href)}"${nonceAttr}>`).join(""),
|
|
72
|
+
jsPreloads: [...files.criticalJs.map((href) => `<link rel="modulepreload" href="${withBase(href)}" crossorigin fetchpriority="high"${nonceAttr}>`), ...files.sharedJs.map((href) => `<link rel="modulepreload" href="${withBase(href)}" crossorigin${nonceAttr}>`)].join(""),
|
|
73
|
+
entryClient: withBase(files.entryClientFile)
|
|
76
74
|
};
|
|
77
75
|
}
|
|
78
76
|
async function buildPageContext(urlPathname, urlOriginal, isJsonRequest) {
|
package/dist/server.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as renderPage } from "./server-
|
|
1
|
+
import { t as renderPage } from "./server-CTx_3HFS.mjs";
|
|
2
2
|
export { renderPage };
|
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as renderPage } from "./server-
|
|
1
|
+
import { t as renderPage } from "./server-CTx_3HFS.mjs";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { Readable } from "node:stream";
|
|
@@ -96,7 +96,11 @@ async function injectFOUCStyles(server, html) {
|
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region src/config.ts
|
|
99
|
-
const SUPPORTED_RENDERERS = [
|
|
99
|
+
const SUPPORTED_RENDERERS = [
|
|
100
|
+
"react",
|
|
101
|
+
"solid",
|
|
102
|
+
"vue"
|
|
103
|
+
];
|
|
100
104
|
//#endregion
|
|
101
105
|
//#region src/vite/index.ts
|
|
102
106
|
function vikeLite({ pagesDir = "pages", serverEntry = "server/index", apiPrefix = "/api", prerender = false } = {}) {
|
|
@@ -105,14 +109,14 @@ function vikeLite({ pagesDir = "pages", serverEntry = "server/index", apiPrefix
|
|
|
105
109
|
let outDir;
|
|
106
110
|
let hasAnyPrerender;
|
|
107
111
|
const VIRTUAL = {
|
|
108
|
-
routes: "virtual:routes",
|
|
109
|
-
manifest: "virtual:client-manifest",
|
|
112
|
+
routes: "virtual:vike-lite/routes",
|
|
113
|
+
manifest: "virtual:vike-lite/client-manifest",
|
|
110
114
|
client: "virtual:vike-lite/client",
|
|
111
115
|
server: "virtual:vike-lite/server",
|
|
112
116
|
setup: "virtual:vike-lite/setup",
|
|
113
|
-
entryClient: "virtual:entry-client",
|
|
114
|
-
entryServer: "virtual:entry-server",
|
|
115
|
-
entryPrerender: "virtual:entry-prerender"
|
|
117
|
+
entryClient: "virtual:vike-lite/entry-client",
|
|
118
|
+
entryServer: "virtual:vike-lite/entry-server",
|
|
119
|
+
entryPrerender: "virtual:vike-lite/entry-prerender"
|
|
116
120
|
};
|
|
117
121
|
const VIRTUAL_VALUES = new Set(Object.values(VIRTUAL));
|
|
118
122
|
const RESOLVED = Object.fromEntries(Object.entries(VIRTUAL).map(([k, v]) => [k, `\0${v}`]));
|
|
@@ -151,7 +155,7 @@ function vikeLite({ pagesDir = "pages", serverEntry = "server/index", apiPrefix
|
|
|
151
155
|
codeSplitting: { groups: [
|
|
152
156
|
{
|
|
153
157
|
name: "framework",
|
|
154
|
-
test: /[\\/]vike-lite(?:-\w+)?[\\/]|[\\/](?:solid-js|@
|
|
158
|
+
test: /[\\/]vike-lite(?:-\w+)?[\\/]|[\\/](?:solid-js|vue|@vue|react|react-dom)[\\/]|^\0virtual:vike-lite\/(setup|renderer)$/,
|
|
155
159
|
priority: 30
|
|
156
160
|
},
|
|
157
161
|
{
|