vike-lite 1.13.4 → 1.14.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.
@@ -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 getAssets(route, nonce) {
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: [...cssFiles].map((href) => `<link rel="stylesheet" href="${withBase(href)}"${nonceAttr}>`).join(""),
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(manifest[virtualEntryClientKey].file)
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) {
@@ -94,14 +92,14 @@ async function buildPageContext(urlPathname, urlOriginal, isJsonRequest) {
94
92
  if (dataMod) try {
95
93
  pageContext.data = await (dataMod.data ?? dataMod.default)(pageContext);
96
94
  } catch (error) {
97
- console.error("+data hook failed at:", urlPathname);
95
+ if (!(error instanceof AbortRedirect || error instanceof AbortRender)) console.error("+data hook failed at:", urlPathname);
98
96
  throw error;
99
97
  }
100
98
  if (titleMod) try {
101
99
  const titleFn = titleMod.title ?? titleMod.default;
102
100
  pageContext.title = typeof titleFn === "function" ? titleFn(pageContext) : titleFn;
103
101
  } catch (error) {
104
- console.error("+title hook failed at:", urlPathname);
102
+ if (!(error instanceof AbortRedirect || error instanceof AbortRender)) console.error("+title hook failed at:", urlPathname);
105
103
  throw error;
106
104
  }
107
105
  return {
@@ -116,7 +114,6 @@ async function renderErrorPage(req, status, urlPathname, error, nonce) {
116
114
  let errorMessage;
117
115
  let is500;
118
116
  if (status === 500) {
119
- console.error(`[vike-lite] Server Error:`, error);
120
117
  errorMessage = isProd ? "Internal Server Error" : error instanceof Error ? error.message : "Unknown error";
121
118
  is500 = true;
122
119
  } else is500 = false;
package/dist/server.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as renderPage } from "./server-GrGbl23a.mjs";
1
+ import { t as renderPage } from "./server-BkIWABsi.mjs";
2
2
  export { renderPage };
package/dist/vite.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as renderPage } from "./server-GrGbl23a.mjs";
1
+ import { t as renderPage } from "./server-BkIWABsi.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 = ["solid"];
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,21 +109,21 @@ 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}`]));
119
123
  return {
120
124
  name: "vike-lite",
121
125
  config(config, { mode }) {
122
- const envVariables = loadEnv(mode, config.envDir || process.cwd());
126
+ const envVariables = loadEnv(mode, config.envDir || process.cwd(), "");
123
127
  for (const key in envVariables) if (process.env[key] === void 0) process.env[key] = envVariables[key];
124
128
  outDir = config.build?.outDir ?? "dist";
125
129
  const { emptyOutDir, minify = true, cssMinify = true, sourcemap } = config.build || {};
@@ -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|@solidjs)[\\/]|^\0virtual:vike-lite/,
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
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike-lite",
3
- "version": "1.13.4",
3
+ "version": "1.14.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",