@qwik.dev/router 2.0.0-beta.27 → 2.0.0-beta.29

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.
Files changed (42) hide show
  1. package/lib/adapters/azure-swa/vite/index.mjs +31 -36
  2. package/lib/adapters/bun-server/vite/index.mjs +0 -3
  3. package/lib/adapters/cloud-run/vite/index.mjs +0 -3
  4. package/lib/adapters/cloudflare-pages/vite/index.mjs +15 -9
  5. package/lib/adapters/deno-server/vite/index.mjs +7 -5
  6. package/lib/adapters/netlify-edge/vite/index.mjs +13 -23
  7. package/lib/adapters/node-server/vite/index.mjs +0 -3
  8. package/lib/adapters/shared/vite/index.d.ts +1 -7
  9. package/lib/adapters/shared/vite/index.mjs +171 -157
  10. package/lib/adapters/ssg/vite/index.mjs +3 -4
  11. package/lib/adapters/vercel-edge/vite/index.mjs +25 -9
  12. package/lib/chunks/error-handler.mjs +26 -26
  13. package/lib/chunks/fs.mjs +28 -138
  14. package/lib/chunks/http-error.qwik.mjs +27 -0
  15. package/lib/chunks/not-found-wrapper.qwik.mjs +25 -0
  16. package/lib/chunks/pathname.mjs +105 -0
  17. package/lib/chunks/routing.qwik.mjs +592 -216
  18. package/lib/chunks/system.mjs +328 -0
  19. package/lib/chunks/use-functions.qwik.mjs +35 -0
  20. package/lib/chunks/worker-thread.mjs +271 -0
  21. package/lib/index.d.ts +136 -102
  22. package/lib/index.qwik.mjs +699 -751
  23. package/lib/middleware/aws-lambda/index.mjs +7 -1
  24. package/lib/middleware/azure-swa/index.mjs +7 -2
  25. package/lib/middleware/bun/index.mjs +24 -8
  26. package/lib/middleware/cloudflare-pages/index.mjs +10 -3
  27. package/lib/middleware/deno/index.mjs +23 -8
  28. package/lib/middleware/netlify-edge/index.mjs +10 -3
  29. package/lib/middleware/node/index.mjs +10 -14
  30. package/lib/middleware/request-handler/index.d.ts +82 -12
  31. package/lib/middleware/request-handler/index.mjs +661 -524
  32. package/lib/middleware/vercel-edge/index.mjs +10 -3
  33. package/lib/modules.d.ts +7 -4
  34. package/lib/ssg/index.d.ts +48 -16
  35. package/lib/ssg/index.mjs +320 -7
  36. package/lib/vite/index.d.ts +6 -0
  37. package/lib/vite/index.mjs +1106 -630
  38. package/modules.d.ts +7 -4
  39. package/package.json +9 -9
  40. package/lib/chunks/format-error.mjs +0 -137
  41. package/lib/chunks/index.mjs +0 -884
  42. package/lib/chunks/types.qwik.mjs +0 -22
@@ -2,51 +2,6 @@ import { join, resolve, dirname, basename } from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { g as getErrorHtml } from '../../../chunks/error-handler.mjs';
4
4
 
5
- async function postBuild(clientOutDir, serverOutDir, pathName, userStaticPaths, cleanStatic) {
6
- if (pathName && !pathName.endsWith("/")) {
7
- pathName += "/";
8
- }
9
- const ignorePathnames = /* @__PURE__ */ new Set([
10
- pathName + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
11
- pathName + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
12
- ]);
13
- const staticPaths = new Set(userStaticPaths.map(normalizeTrailingSlash));
14
- const notFounds = [];
15
- const loadItem = async (fsDir, fsName, pathname) => {
16
- pathname = normalizeTrailingSlash(pathname);
17
- if (ignorePathnames.has(pathname)) {
18
- return;
19
- }
20
- const fsPath = join(fsDir, fsName);
21
- if (fsName === "index.html" || fsName === "q-data.json") {
22
- if (!staticPaths.has(pathname) && cleanStatic) {
23
- await fs.promises.unlink(fsPath);
24
- }
25
- return;
26
- }
27
- if (fsName === "404.html") {
28
- const notFoundHtml = await fs.promises.readFile(fsPath, "utf-8");
29
- notFounds.push([pathname, notFoundHtml]);
30
- return;
31
- }
32
- const stat = await fs.promises.stat(fsPath);
33
- if (stat.isDirectory()) {
34
- await loadDir(fsPath, pathname + fsName + "/");
35
- } else if (stat.isFile()) {
36
- staticPaths.add(pathname + fsName);
37
- }
38
- };
39
- const loadDir = async (fsDir, pathname) => {
40
- const itemNames = await fs.promises.readdir(fsDir);
41
- await Promise.all(itemNames.map((i) => loadItem(fsDir, i, pathname)));
42
- };
43
- if (fs.existsSync(clientOutDir)) {
44
- await loadDir(clientOutDir, pathName);
45
- }
46
- const notFoundPathsCode = createNotFoundPathsCode(pathName, notFounds);
47
- const staticPathsCode = createStaticPathsCode(staticPaths);
48
- await injectStatics(staticPathsCode, notFoundPathsCode, serverOutDir);
49
- }
50
5
  function normalizeTrailingSlash(pathname) {
51
6
  if (!pathname.endsWith("/")) {
52
7
  return pathname + "/";
@@ -71,7 +26,10 @@ function createNotFoundPathsCode(basePathname, notFounds) {
71
26
  });
72
27
  if (!notFounds.some((r) => r[0] === basePathname)) {
73
28
  const html = getErrorHtml(404, "Resource Not Found");
74
- notFounds.push([basePathname, html]);
29
+ notFounds.push([
30
+ basePathname,
31
+ html
32
+ ]);
75
33
  }
76
34
  return JSON.stringify(notFounds, null, 2).slice(1, -1);
77
35
  }
@@ -83,19 +41,18 @@ const injectStatics = async (staticPathsCode, notFoundPathsCode, outDir) => {
83
41
  const doReplace = async (path) => {
84
42
  const code = await fs.promises.readFile(path, "utf-8");
85
43
  let replaced = false;
86
- const newCode = code.replace(
87
- /(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,
88
- (_, _quote, type) => {
89
- replaced = true;
90
- return type === "STATIC_PATHS" ? staticPathsCode : notFoundPathsCode;
91
- }
92
- );
44
+ const newCode = code.replace(/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g, (_, _quote, type) => {
45
+ replaced = true;
46
+ return type === "STATIC_PATHS" ? staticPathsCode : notFoundPathsCode;
47
+ });
93
48
  if (replaced) {
94
49
  await fs.promises.writeFile(path, newCode);
95
50
  }
96
51
  };
97
52
  const walk = async (dir) => {
98
- const entries = await fs.promises.readdir(dir, { withFileTypes: true });
53
+ const entries = await fs.promises.readdir(dir, {
54
+ withFileTypes: true
55
+ });
99
56
  for (const entry of entries) {
100
57
  if (entry.isDirectory()) {
101
58
  await walk(join(dir, entry.name));
@@ -110,14 +67,61 @@ const injectStatics = async (staticPathsCode, notFoundPathsCode, outDir) => {
110
67
  await walk(outDir);
111
68
  await Promise.all(promises);
112
69
  };
70
+ async function postBuild(clientOutDir, serverOutDir, pathName, userStaticPaths, cleanStatic) {
71
+ if (pathName && !pathName.endsWith("/")) {
72
+ pathName += "/";
73
+ }
74
+ const ignorePathnames = /* @__PURE__ */ new Set([
75
+ pathName + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
76
+ pathName + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
77
+ ]);
78
+ const staticPaths = new Set(userStaticPaths.map(normalizeTrailingSlash));
79
+ const notFounds = [];
80
+ const loadItem = async (fsDir, fsName, pathname) => {
81
+ pathname = normalizeTrailingSlash(pathname);
82
+ if (ignorePathnames.has(pathname)) {
83
+ return;
84
+ }
85
+ const fsPath = join(fsDir, fsName);
86
+ if (fsName === "index.html" || fsName === "q-data.json") {
87
+ if (!staticPaths.has(pathname) && cleanStatic) {
88
+ await fs.promises.unlink(fsPath);
89
+ }
90
+ return;
91
+ }
92
+ if (fsName === "404.html") {
93
+ const notFoundHtml = await fs.promises.readFile(fsPath, "utf-8");
94
+ notFounds.push([
95
+ pathname,
96
+ notFoundHtml
97
+ ]);
98
+ return;
99
+ }
100
+ const stat = await fs.promises.stat(fsPath);
101
+ if (stat.isDirectory()) {
102
+ await loadDir(fsPath, pathname + fsName + "/");
103
+ } else if (stat.isFile()) {
104
+ staticPaths.add(pathname + fsName);
105
+ }
106
+ };
107
+ const loadDir = async (fsDir, pathname) => {
108
+ const itemNames = await fs.promises.readdir(fsDir);
109
+ await Promise.all(itemNames.map((i) => loadItem(fsDir, i, pathname)));
110
+ };
111
+ if (fs.existsSync(clientOutDir)) {
112
+ await loadDir(clientOutDir, pathName);
113
+ }
114
+ const notFoundPathsCode = createNotFoundPathsCode(pathName, notFounds);
115
+ const staticPathsCode = createStaticPathsCode(staticPaths);
116
+ await injectStatics(staticPathsCode, notFoundPathsCode, serverOutDir);
117
+ }
113
118
 
119
+ const QWIK_SSG_ENTRY_ID = "@qwik-ssg-entry";
120
+ const QWIK_SSG_ENTRY_RESOLVED = "\0@qwik-ssg-entry";
114
121
  function viteAdapter(opts) {
115
122
  let qwikRouterPlugin = null;
116
123
  let qwikVitePlugin = null;
117
124
  let serverOutDir = null;
118
- let renderModulePath = null;
119
- let qwikRouterConfigModulePath = null;
120
- let isSsrBuild = false;
121
125
  let viteCommand;
122
126
  const outputEntries = [];
123
127
  const plugin = {
@@ -135,63 +139,96 @@ function viteAdapter(opts) {
135
139
  return config;
136
140
  },
137
141
  configResolved(config) {
138
- isSsrBuild = !!config.build.ssr;
139
142
  viteCommand = config.command;
140
- if (isSsrBuild) {
141
- qwikRouterPlugin = config.plugins.find(
142
- (p) => p.name === "vite-plugin-qwik-router"
143
- );
144
- if (!qwikRouterPlugin) {
145
- throw new Error("Missing vite-plugin-qwik-router");
146
- }
147
- qwikVitePlugin = config.plugins.find(
148
- (p) => p.name === "vite-plugin-qwik"
149
- );
150
- if (!qwikVitePlugin) {
151
- throw new Error("Missing vite-plugin-qwik");
152
- }
153
- serverOutDir = config.build.outDir;
154
- if (config.build?.ssr !== true) {
155
- throw new Error(
156
- `"build.ssr" must be set to "true" in order to use the "${opts.name}" adapter.`
157
- );
158
- }
159
- if (!config.build?.rollupOptions?.input) {
160
- throw new Error(
161
- `"build.rollupOptions.input" must be set in order to use the "${opts.name}" adapter.`
162
- );
143
+ qwikRouterPlugin = config.plugins.find((p) => p.name === "vite-plugin-qwik-router");
144
+ if (!qwikRouterPlugin) {
145
+ throw new Error("Missing vite-plugin-qwik-router");
146
+ }
147
+ qwikVitePlugin = config.plugins.find((p) => p.name === "vite-plugin-qwik");
148
+ if (!qwikVitePlugin) {
149
+ throw new Error("Missing vite-plugin-qwik");
150
+ }
151
+ serverOutDir = config.build.outDir;
152
+ },
153
+ resolveId(id) {
154
+ if (id === QWIK_SSG_ENTRY_ID) {
155
+ return QWIK_SSG_ENTRY_RESOLVED;
156
+ }
157
+ },
158
+ load(id) {
159
+ if (id !== QWIK_SSG_ENTRY_RESOLVED) {
160
+ return;
161
+ }
162
+ const { srcDir } = qwikVitePlugin.api.getOptions();
163
+ const clientPublicOutDir = qwikVitePlugin.api.getClientPublicOutDir();
164
+ const basePathname = qwikRouterPlugin.api.getBasePathname();
165
+ const rootDir = qwikVitePlugin.api.getRootDir() ?? void 0;
166
+ let ssgOrigin = opts.ssg?.origin ?? opts.origin;
167
+ if (!ssgOrigin) {
168
+ ssgOrigin = `https://yoursite.qwik.dev`;
169
+ }
170
+ if (ssgOrigin.length > 0 && !/:\/\//.test(ssgOrigin)) {
171
+ ssgOrigin = `https://${ssgOrigin}`;
172
+ }
173
+ if (ssgOrigin.startsWith("//")) {
174
+ ssgOrigin = `https:${ssgOrigin}`;
175
+ }
176
+ try {
177
+ ssgOrigin = new URL(ssgOrigin).origin;
178
+ } catch {
179
+ this.warn(`Invalid "origin" option: "${ssgOrigin}". Using default origin: "https://yoursite.qwik.dev"`);
180
+ ssgOrigin = `https://yoursite.qwik.dev`;
181
+ }
182
+ const ssgOpts = {
183
+ origin: ssgOrigin,
184
+ outDir: clientPublicOutDir,
185
+ basePathname,
186
+ rootDir,
187
+ ...opts.ssg,
188
+ maxWorkers: opts.maxWorkers
189
+ };
190
+ for (const key of Object.keys(ssgOpts)) {
191
+ if (ssgOpts[key] === void 0) {
192
+ delete ssgOpts[key];
163
193
  }
164
194
  }
195
+ return [
196
+ `import { isMainThread } from 'node:worker_threads';`,
197
+ `import render from '${srcDir}/entry.ssr';`,
198
+ `import qwikRouterConfig from '@qwik-router-config';`,
199
+ ``,
200
+ `const ssgOpts = ${JSON.stringify(ssgOpts)};`,
201
+ ``,
202
+ `if (isMainThread) {`,
203
+ ` const { runSsg } = await import('@qwik.dev/router/ssg');`,
204
+ ` await runSsg({`,
205
+ ` render,`,
206
+ ` qwikRouterConfig,`,
207
+ ` workerFilePath: new URL(import.meta.url).href,`,
208
+ ` ...ssgOpts,`,
209
+ ` });`,
210
+ `} else {`,
211
+ ` const { startWorker } = await import('@qwik.dev/router/ssg');`,
212
+ ` await startWorker({ render, qwikRouterConfig });`,
213
+ `}`
214
+ ].join("\n");
165
215
  },
166
216
  buildStart() {
167
- if (isSsrBuild && opts.ssg !== null) {
168
- const { srcDir } = qwikVitePlugin.api.getOptions();
169
- if (viteCommand === "build" && serverOutDir && srcDir) {
170
- this.emitFile({
171
- id: "@qwik-router-config",
172
- type: "chunk",
173
- fileName: "@qwik-router-config.js"
174
- });
175
- this.emitFile({
176
- id: `${srcDir}/entry.ssr`,
177
- type: "chunk",
178
- fileName: "entry.ssr.js"
179
- });
180
- }
217
+ if (this.environment.config.consumer === "server" && opts.ssg !== null && viteCommand === "build" && serverOutDir) {
218
+ this.emitFile({
219
+ id: QWIK_SSG_ENTRY_ID,
220
+ type: "chunk",
221
+ fileName: "run-ssg.js"
222
+ });
181
223
  }
182
224
  },
183
225
  generateBundle(_, bundles) {
184
- if (isSsrBuild) {
226
+ if (this.environment.config.consumer === "server") {
185
227
  outputEntries.length = 0;
186
228
  for (const fileName in bundles) {
187
229
  const chunk = bundles[fileName];
188
230
  if (chunk.type === "chunk" && chunk.isEntry) {
189
231
  outputEntries.push(fileName);
190
- if (chunk.name === "entry.ssr") {
191
- renderModulePath = join(serverOutDir, fileName);
192
- } else if (chunk.name === "@qwik-router-config") {
193
- qwikRouterConfigModulePath = join(serverOutDir, fileName);
194
- }
195
232
  }
196
233
  }
197
234
  }
@@ -199,61 +236,48 @@ function viteAdapter(opts) {
199
236
  closeBundle: {
200
237
  sequential: true,
201
238
  async handler() {
202
- if (isSsrBuild && serverOutDir && qwikRouterPlugin?.api && qwikVitePlugin?.api) {
239
+ if (this.environment.config.consumer === "server" && serverOutDir && qwikRouterPlugin?.api && qwikVitePlugin?.api) {
203
240
  const staticPaths = opts.staticPaths || [];
204
241
  const routes = qwikRouterPlugin.api.getRoutes();
205
242
  const basePathname = qwikRouterPlugin.api.getBasePathname();
206
243
  const clientOutDir = qwikVitePlugin.api.getClientOutDir();
207
244
  const clientPublicOutDir = qwikVitePlugin.api.getClientPublicOutDir();
208
245
  const assetsDir = qwikVitePlugin.api.getAssetsDir();
209
- const rootDir = qwikVitePlugin.api.getRootDir() ?? void 0;
210
- if (opts.ssg !== null && renderModulePath && qwikRouterConfigModulePath && clientOutDir && clientPublicOutDir) {
211
- let ssgOrigin = opts.ssg?.origin ?? opts.origin;
212
- if (!ssgOrigin) {
213
- ssgOrigin = `https://yoursite.qwik.dev`;
214
- }
215
- if (ssgOrigin.length > 0 && !/:\/\//.test(ssgOrigin)) {
216
- ssgOrigin = `https://${ssgOrigin}`;
217
- }
218
- if (ssgOrigin.startsWith("//")) {
219
- ssgOrigin = `https:${ssgOrigin}`;
246
+ if (opts.ssg !== null && clientOutDir && clientPublicOutDir) {
247
+ const runSsgPath = join(serverOutDir, "run-ssg.js");
248
+ const { spawn } = await import('node:child_process');
249
+ const ssgExitCode = await new Promise((resolve2, reject) => {
250
+ const child = spawn(process.execPath, [
251
+ runSsgPath
252
+ ], {
253
+ stdio: [
254
+ "ignore",
255
+ "inherit",
256
+ "inherit"
257
+ ],
258
+ env: {
259
+ ...process.env,
260
+ NODE_ENV: process.env.NODE_ENV || "production"
261
+ }
262
+ });
263
+ child.on("close", resolve2);
264
+ child.on("error", reject);
265
+ });
266
+ if (ssgExitCode !== 0) {
267
+ const err = new Error(`Error while running SSG from "${opts.name}" adapter. At least one path failed to render.`);
268
+ err.stack = void 0;
269
+ this.error(err);
220
270
  }
271
+ const fs = await import('node:fs');
272
+ const staticPathsFile = join(clientPublicOutDir, "_static-paths.json");
221
273
  try {
222
- ssgOrigin = new URL(ssgOrigin).origin;
274
+ const content = await fs.promises.readFile(staticPathsFile, "utf-8");
275
+ staticPaths.push(...JSON.parse(content));
276
+ await fs.promises.unlink(staticPathsFile);
223
277
  } catch {
224
- this.warn(
225
- `Invalid "origin" option: "${ssgOrigin}". Using default origin: "https://yoursite.qwik.dev"`
226
- );
227
- ssgOrigin = `https://yoursite.qwik.dev`;
228
278
  }
229
- const staticGenerate = await import('../../../ssg/index.mjs');
230
- const generateOpts = {
231
- maxWorkers: opts.maxWorkers,
232
- basePathname,
233
- outDir: clientPublicOutDir,
234
- rootDir,
235
- ...opts.ssg,
236
- origin: ssgOrigin,
237
- renderModulePath,
238
- qwikRouterConfigModulePath
239
- };
240
- const staticGenerateResult = await staticGenerate.generate(generateOpts);
241
- if (staticGenerateResult.errors > 0) {
242
- const err = new Error(
243
- `Error while running SSG from "${opts.name}" adapter. At least one path failed to render.`
244
- );
245
- err.stack = void 0;
246
- this.error(err);
247
- }
248
- staticPaths.push(...staticGenerateResult.staticPaths);
249
279
  }
250
- await postBuild(
251
- clientPublicOutDir,
252
- serverOutDir,
253
- assetsDir ? join(basePathname, assetsDir) : basePathname,
254
- staticPaths,
255
- !!opts.cleanStaticGenerated
256
- );
280
+ await postBuild(clientPublicOutDir, serverOutDir, assetsDir ? join(basePathname, assetsDir) : basePathname, staticPaths, !!opts.cleanStaticGenerated);
257
281
  if (typeof opts.generate === "function") {
258
282
  await opts.generate({
259
283
  outputEntries,
@@ -267,21 +291,11 @@ function viteAdapter(opts) {
267
291
  error: (message) => this.error(message)
268
292
  });
269
293
  }
270
- this.warn(
271
- `
294
+ this.warn(`
272
295
  ==============================================
273
296
  Note: Make sure that you are serving the built files with proper cache headers.
274
297
  See https://qwik.dev/docs/deployments/#cache-headers for more information.
275
- ==============================================`
276
- );
277
- if (opts.ssg !== null) {
278
- setTimeout(() => {
279
- console.warn(
280
- "SSG seems to be hanging after completion, forcing process to exit. Everything is likely fine."
281
- );
282
- process.exit(0);
283
- }, 5e3).unref();
284
- }
298
+ ==============================================`);
285
299
  }
286
300
  }
287
301
  }
@@ -1,14 +1,13 @@
1
1
  import { viteAdapter } from '../../shared/vite/index.mjs';
2
- import 'node:path';
3
- import 'node:fs';
4
- import '../../../chunks/error-handler.mjs';
5
2
 
6
3
  function ssgAdapter(opts) {
7
4
  return viteAdapter({
8
5
  name: "static-site-generation",
9
6
  origin: opts.origin,
10
7
  ssg: {
11
- include: ["/*"],
8
+ include: [
9
+ "/*"
10
+ ],
12
11
  ...opts
13
12
  }
14
13
  });
@@ -1,7 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import { join, dirname } from 'node:path';
3
3
  import { viteAdapter, getParentDir } from '../../shared/vite/index.mjs';
4
- import '../../../chunks/error-handler.mjs';
5
4
 
6
5
  function vercelEdgeAdapter(opts = {}) {
7
6
  return viteAdapter({
@@ -14,7 +13,20 @@ function vercelEdgeAdapter(opts = {}) {
14
13
  const outDir = config.build?.outDir || join(".vercel", "output", "functions", "_qwik-router.func");
15
14
  return {
16
15
  resolve: {
17
- conditions: opts.target === "node" ? ["node", "import", "module", "browser", "default"] : ["edge-light", "webworker", "worker", "browser", "module", "main"]
16
+ conditions: opts.target === "node" ? [
17
+ "node",
18
+ "import",
19
+ "module",
20
+ "browser",
21
+ "default"
22
+ ] : [
23
+ "edge-light",
24
+ "webworker",
25
+ "worker",
26
+ "browser",
27
+ "module",
28
+ "main"
29
+ ]
18
30
  },
19
31
  ssr: {
20
32
  target: opts.target === "node" ? "node" : "webworker",
@@ -38,7 +50,9 @@ function vercelEdgeAdapter(opts = {}) {
38
50
  if (opts.outputConfig !== false) {
39
51
  const vercelOutputConfig = {
40
52
  routes: [
41
- { handle: "filesystem" },
53
+ {
54
+ handle: "filesystem"
55
+ },
42
56
  {
43
57
  src: basePathname + ".*",
44
58
  dest: "/_qwik-router"
@@ -46,10 +60,7 @@ function vercelEdgeAdapter(opts = {}) {
46
60
  ],
47
61
  version: 3
48
62
  };
49
- await fs.promises.writeFile(
50
- join(vercelOutputDir, "config.json"),
51
- JSON.stringify(vercelOutputConfig, null, 2)
52
- );
63
+ await fs.promises.writeFile(join(vercelOutputDir, "config.json"), JSON.stringify(vercelOutputConfig, null, 2));
53
64
  }
54
65
  let entrypoint = opts.vcConfigEntryPoint;
55
66
  if (!entrypoint) {
@@ -71,8 +82,13 @@ function vercelEdgeAdapter(opts = {}) {
71
82
  if (basePathnameParts.length > 0) {
72
83
  vercelStaticDir = join(vercelStaticDir, ...basePathnameParts);
73
84
  }
74
- await fs.promises.rm(vercelStaticDir, { recursive: true, force: true });
75
- await fs.promises.mkdir(dirname(vercelStaticDir), { recursive: true });
85
+ await fs.promises.rm(vercelStaticDir, {
86
+ recursive: true,
87
+ force: true
88
+ });
89
+ await fs.promises.mkdir(dirname(vercelStaticDir), {
90
+ recursive: true
91
+ });
76
92
  await fs.promises.rename(clientPublicOutDir, vercelStaticDir);
77
93
  }
78
94
  });
@@ -1,14 +1,20 @@
1
- function getErrorHtml(status, e) {
2
- let message = "Server Error";
3
- if (e != null) {
4
- if (typeof e.message === "string") {
5
- message = e.message;
6
- } else {
7
- message = String(e);
1
+ const ESCAPE_HTML = /[&<>]/g;
2
+ const escapeHtml = (s) => {
3
+ return s.replace(ESCAPE_HTML, (c) => {
4
+ switch (c) {
5
+ case "&":
6
+ return "&amp;";
7
+ case "<":
8
+ return "&lt;";
9
+ case ">":
10
+ return "&gt;";
11
+ default:
12
+ return "";
8
13
  }
9
- }
10
- return `<html>` + minimalHtmlResponse(status, message) + `</html>`;
11
- }
14
+ });
15
+ };
16
+ const COLOR_400 = "#006ce9";
17
+ const COLOR_500 = "#713fc2";
12
18
  function minimalHtmlResponse(status, message) {
13
19
  if (typeof status !== "number") {
14
20
  status = 500;
@@ -36,22 +42,16 @@ function minimalHtmlResponse(status, message) {
36
42
  <body><p><strong>${status}</strong> <span>${message}</span></p></body>
37
43
  `;
38
44
  }
39
- const ESCAPE_HTML = /[&<>]/g;
40
- const escapeHtml = (s) => {
41
- return s.replace(ESCAPE_HTML, (c) => {
42
- switch (c) {
43
- case "&":
44
- return "&amp;";
45
- case "<":
46
- return "&lt;";
47
- case ">":
48
- return "&gt;";
49
- default:
50
- return "";
45
+ function getErrorHtml(status, e) {
46
+ let message = "Server Error";
47
+ if (e != null) {
48
+ if (typeof e.message === "string") {
49
+ message = e.message;
50
+ } else {
51
+ message = String(e);
51
52
  }
52
- });
53
- };
54
- const COLOR_400 = "#006ce9";
55
- const COLOR_500 = "#713fc2";
53
+ }
54
+ return `<html>` + minimalHtmlResponse(status, message) + `</html>`;
55
+ }
56
56
 
57
57
  export { getErrorHtml as g, minimalHtmlResponse as m };