@qwik.dev/router 2.0.0-beta.39 → 2.0.0-beta.40

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 (40) hide show
  1. package/lib/adapters/azure-swa/vite/index.mjs +45 -54
  2. package/lib/adapters/bun-server/vite/index.mjs +16 -22
  3. package/lib/adapters/cloud-run/vite/index.mjs +15 -19
  4. package/lib/adapters/cloudflare-pages/vite/index.mjs +46 -67
  5. package/lib/adapters/deno-server/vite/index.mjs +25 -39
  6. package/lib/adapters/netlify-edge/vite/index.mjs +50 -76
  7. package/lib/adapters/node-server/vite/index.mjs +16 -22
  8. package/lib/adapters/shared/vite/index.mjs +271 -360
  9. package/lib/adapters/ssg/vite/index.mjs +11 -15
  10. package/lib/adapters/vercel-edge/vite/index.mjs +74 -95
  11. package/lib/chunks/dev-preloaded-route-loader.mjs +2 -3
  12. package/lib/chunks/format.mjs +16 -23
  13. package/lib/chunks/fs.mjs +93 -106
  14. package/lib/chunks/head.qwik.mjs +1174 -1382
  15. package/lib/chunks/http-error.qwik.mjs +20 -28
  16. package/lib/chunks/pathname.mjs +50 -69
  17. package/lib/chunks/request-body-limit.mjs +25 -35
  18. package/lib/chunks/request-path.mjs +44 -55
  19. package/lib/chunks/routes.mjs +20 -41
  20. package/lib/chunks/server-error.mjs +15 -18
  21. package/lib/chunks/system.mjs +258 -326
  22. package/lib/chunks/url.mjs +56 -58
  23. package/lib/chunks/user-response.mjs +1616 -1804
  24. package/lib/chunks/worker-thread.mjs +254 -307
  25. package/lib/index.qwik.mjs +1637 -1918
  26. package/lib/middleware/aws-lambda/index.mjs +44 -52
  27. package/lib/middleware/azure-swa/index.mjs +85 -94
  28. package/lib/middleware/bun/index.mjs +118 -138
  29. package/lib/middleware/cloudflare-pages/index.mjs +83 -96
  30. package/lib/middleware/deno/index.mjs +104 -125
  31. package/lib/middleware/firebase/index.mjs +21 -25
  32. package/lib/middleware/netlify-edge/index.mjs +63 -71
  33. package/lib/middleware/node/index.mjs +297 -357
  34. package/lib/middleware/request-handler/index.mjs +110 -133
  35. package/lib/middleware/vercel-edge/index.mjs +82 -98
  36. package/lib/service-worker/index.mjs +12 -3
  37. package/lib/ssg/index.mjs +249 -289
  38. package/lib/vite/index.mjs +2344 -3030
  39. package/package.json +5 -5
  40. package/lib/chunks/use-functions.qwik.mjs +0 -23
@@ -1,56 +1,47 @@
1
- import fs from 'node:fs';
2
- import { join } from 'node:path';
3
- import { viteAdapter } from '../../shared/vite/index.mjs';
4
-
5
- function azureSwaAdapter(opts = {}) {
6
- const env = process?.env;
7
- return viteAdapter({
8
- name: "azure-swa",
9
- origin: env?.ORIGIN ?? env?.URL ?? "https://yoursitename.region.2.azurestaticapps.net",
10
- ssg: opts.ssg,
11
- cleanStaticGenerated: true,
12
- async generate({ outputEntries, serverOutDir, clientPublicOutDir }) {
13
- const serverPackageJsonPath = join(serverOutDir, "package.json");
14
- const serverPackageJsonCode = `{"type":"module"}`;
15
- await fs.promises.mkdir(serverOutDir, {
16
- recursive: true
17
- });
18
- await fs.promises.writeFile(serverPackageJsonPath, serverPackageJsonCode);
19
- const azureSwaModulePath = outputEntries.find((entryName) => entryName.indexOf("entry.azure-swa") === 0);
20
- const funcJsonPath = join(serverOutDir, "function.json");
21
- const funcJson = JSON.stringify({
22
- bindings: [
23
- {
24
- authLevel: "anonymous",
25
- type: "httpTrigger",
26
- direction: "in",
27
- name: "req",
28
- methods: [
29
- "get",
30
- "head",
31
- "post",
32
- "put",
33
- "delete",
34
- "connect",
35
- "options",
36
- "trace",
37
- "patch"
38
- ]
39
- },
40
- {
41
- type: "http",
42
- direction: "out",
43
- name: "$return"
44
- }
45
- ],
46
- scriptFile: azureSwaModulePath
47
- }, null, 2);
48
- await fs.promises.writeFile(funcJsonPath, funcJson);
49
- if (!fs.existsSync(join(clientPublicOutDir, "index.html"))) {
50
- await fs.promises.writeFile(join(clientPublicOutDir, "index.html"), "");
51
- }
52
- }
53
- });
1
+ import { viteAdapter } from "../../shared/vite/index.mjs";
2
+ import fs from "node:fs";
3
+ import { join } from "node:path";
4
+ /** @public */ function azureSwaAdapter(opts = {}) {
5
+ const env = process?.env;
6
+ return viteAdapter({
7
+ name: "azure-swa",
8
+ origin: env?.ORIGIN ?? env?.URL ?? "https://yoursitename.region.2.azurestaticapps.net",
9
+ ssg: opts.ssg,
10
+ cleanStaticGenerated: true,
11
+ async generate({ outputEntries, serverOutDir, clientPublicOutDir }) {
12
+ const serverPackageJsonPath = join(serverOutDir, "package.json");
13
+ const serverPackageJsonCode = `{"type":"module"}`;
14
+ await fs.promises.mkdir(serverOutDir, { recursive: true });
15
+ await fs.promises.writeFile(serverPackageJsonPath, serverPackageJsonCode);
16
+ const azureSwaModulePath = outputEntries.find((entryName) => entryName.indexOf("entry.azure-swa") === 0);
17
+ const funcJsonPath = join(serverOutDir, "function.json");
18
+ const funcJson = JSON.stringify({
19
+ bindings: [{
20
+ authLevel: "anonymous",
21
+ type: "httpTrigger",
22
+ direction: "in",
23
+ name: "req",
24
+ methods: [
25
+ "get",
26
+ "head",
27
+ "post",
28
+ "put",
29
+ "delete",
30
+ "connect",
31
+ "options",
32
+ "trace",
33
+ "patch"
34
+ ]
35
+ }, {
36
+ type: "http",
37
+ direction: "out",
38
+ name: "$return"
39
+ }],
40
+ scriptFile: azureSwaModulePath
41
+ }, null, 2);
42
+ await fs.promises.writeFile(funcJsonPath, funcJson);
43
+ if (!fs.existsSync(join(clientPublicOutDir, "index.html"))) await fs.promises.writeFile(join(clientPublicOutDir, "index.html"), "");
44
+ }
45
+ });
54
46
  }
55
-
56
47
  export { azureSwaAdapter };
@@ -1,24 +1,18 @@
1
- import { viteAdapter } from '../../shared/vite/index.mjs';
2
-
3
- function bunServerAdapter(opts = {}) {
4
- const env = process?.env;
5
- return viteAdapter({
6
- name: opts.name || "bun-server",
7
- origin: env?.ORIGIN ?? env?.URL ?? "https://yoursitename.qwik.dev",
8
- ssg: opts.ssg,
9
- cleanStaticGenerated: true,
10
- config() {
11
- return {
12
- ssr: {
13
- target: "node"
14
- },
15
- build: {
16
- ssr: true
17
- },
18
- publicDir: false
19
- };
20
- }
21
- });
1
+ import { viteAdapter } from "../../shared/vite/index.mjs";
2
+ /** @beta */ function bunServerAdapter(opts = {}) {
3
+ const env = process?.env;
4
+ return viteAdapter({
5
+ name: opts.name || "bun-server",
6
+ origin: env?.ORIGIN ?? env?.URL ?? "https://yoursitename.qwik.dev",
7
+ ssg: opts.ssg,
8
+ cleanStaticGenerated: true,
9
+ config() {
10
+ return {
11
+ ssr: { target: "node" },
12
+ build: { ssr: true },
13
+ publicDir: false
14
+ };
15
+ }
16
+ });
22
17
  }
23
-
24
18
  export { bunServerAdapter };
@@ -1,21 +1,17 @@
1
- import { viteAdapter } from '../../shared/vite/index.mjs';
2
-
3
- function cloudRunAdapter(opts = {}) {
4
- const env = process?.env;
5
- return viteAdapter({
6
- name: "cloud-run",
7
- origin: env?.ORIGIN ?? env?.URL ?? "https://your-app-name.run.app",
8
- ssg: opts.ssg,
9
- cleanStaticGenerated: true,
10
- config() {
11
- return {
12
- build: {
13
- ssr: true
14
- },
15
- publicDir: false
16
- };
17
- }
18
- });
1
+ import { viteAdapter } from "../../shared/vite/index.mjs";
2
+ /** @public */ function cloudRunAdapter(opts = {}) {
3
+ const env = process?.env;
4
+ return viteAdapter({
5
+ name: "cloud-run",
6
+ origin: env?.ORIGIN ?? env?.URL ?? "https://your-app-name.run.app",
7
+ ssg: opts.ssg,
8
+ cleanStaticGenerated: true,
9
+ config() {
10
+ return {
11
+ build: { ssr: true },
12
+ publicDir: false
13
+ };
14
+ }
15
+ });
19
16
  }
20
-
21
17
  export { cloudRunAdapter };
@@ -1,69 +1,48 @@
1
- import fs from 'node:fs';
2
- import { join, relative } from 'node:path';
3
- import { n as normalizePathSlash } from '../../../chunks/fs.mjs';
4
- import { e as ensureSlash } from '../../../chunks/pathname.mjs';
5
- import { viteAdapter } from '../../shared/vite/index.mjs';
6
-
7
- function cloudflarePagesAdapter(opts = {}) {
8
- const env = process?.env;
9
- return viteAdapter({
10
- name: "cloudflare-pages",
11
- origin: env?.CF_PAGES_URL ?? env?.ORIGIN ?? "https://your.cloudflare.pages.dev",
12
- ssg: opts.ssg,
13
- staticPaths: opts.staticPaths,
14
- cleanStaticGenerated: true,
15
- config() {
16
- return {
17
- resolve: {
18
- conditions: [
19
- "webworker",
20
- "worker"
21
- ]
22
- },
23
- ssr: {
24
- target: "webworker",
25
- noExternal: true,
26
- external: [
27
- "node:async_hooks"
28
- ]
29
- },
30
- build: {
31
- ssr: true,
32
- rollupOptions: {
33
- output: {
34
- format: "es",
35
- hoistTransitiveImports: false
36
- }
37
- }
38
- },
39
- publicDir: false
40
- };
41
- },
42
- async generate({ clientOutDir, serverOutDir, basePathname }) {
43
- const routesJsonPath = join(clientOutDir, "_routes.json");
44
- const hasRoutesJson = fs.existsSync(routesJsonPath);
45
- if (!hasRoutesJson && opts.functionRoutes !== false) {
46
- const pathName = ensureSlash(basePathname);
47
- const routesJson = {
48
- version: 1,
49
- include: [
50
- basePathname + "*"
51
- ],
52
- exclude: [
53
- pathName + "build/*",
54
- pathName + "assets/*"
55
- ]
56
- };
57
- await fs.promises.writeFile(routesJsonPath, JSON.stringify(routesJson, void 0, 2));
58
- }
59
- const workerJsPath = join(clientOutDir, "_worker.js");
60
- const hasWorkerJs = fs.existsSync(workerJsPath);
61
- if (!hasWorkerJs) {
62
- const importPath = relative(clientOutDir, join(serverOutDir, "entry.cloudflare-pages"));
63
- await fs.promises.writeFile(workerJsPath, `import { fetch } from "${normalizePathSlash(importPath)}"; export default { fetch };`);
64
- }
65
- }
66
- });
1
+ import { t as ensureSlash } from "../../../chunks/pathname.mjs";
2
+ import { viteAdapter } from "../../shared/vite/index.mjs";
3
+ import { v as normalizePathSlash } from "../../../chunks/fs.mjs";
4
+ import fs from "node:fs";
5
+ import { join, relative } from "node:path";
6
+ /** @public */ function cloudflarePagesAdapter(opts = {}) {
7
+ const env = process?.env;
8
+ return viteAdapter({
9
+ name: "cloudflare-pages",
10
+ origin: env?.CF_PAGES_URL ?? env?.ORIGIN ?? "https://your.cloudflare.pages.dev",
11
+ ssg: opts.ssg,
12
+ staticPaths: opts.staticPaths,
13
+ cleanStaticGenerated: true,
14
+ config() {
15
+ return {
16
+ resolve: { conditions: ["webworker", "worker"] },
17
+ ssr: {
18
+ target: "webworker",
19
+ noExternal: true,
20
+ external: ["node:async_hooks"]
21
+ },
22
+ build: {
23
+ ssr: true,
24
+ rolldownOptions: { output: { format: "es" } }
25
+ },
26
+ publicDir: false
27
+ };
28
+ },
29
+ async generate({ clientOutDir, serverOutDir, basePathname }) {
30
+ const routesJsonPath = join(clientOutDir, "_routes.json");
31
+ if (!fs.existsSync(routesJsonPath) && opts.functionRoutes !== false) {
32
+ const pathName = ensureSlash(basePathname);
33
+ const routesJson = {
34
+ version: 1,
35
+ include: [basePathname + "*"],
36
+ exclude: [pathName + "build/*", pathName + "assets/*"]
37
+ };
38
+ await fs.promises.writeFile(routesJsonPath, JSON.stringify(routesJson, void 0, 2));
39
+ }
40
+ const workerJsPath = join(clientOutDir, "_worker.js");
41
+ if (!fs.existsSync(workerJsPath)) {
42
+ const importPath = relative(clientOutDir, join(serverOutDir, "entry.cloudflare-pages"));
43
+ await fs.promises.writeFile(workerJsPath, `import { fetch } from "${normalizePathSlash(importPath)}"; export default { fetch };`);
44
+ }
45
+ }
46
+ });
67
47
  }
68
-
69
48
  export { cloudflarePagesAdapter };
@@ -1,41 +1,27 @@
1
- import { viteAdapter } from '../../shared/vite/index.mjs';
2
-
3
- function denoServerAdapter(opts = {}) {
4
- const env = process?.env;
5
- return viteAdapter({
6
- name: opts.name || "deno-server",
7
- origin: env?.ORIGIN ?? env?.URL ?? "https://yoursitename.qwik.dev",
8
- ssg: opts.ssg,
9
- cleanStaticGenerated: true,
10
- config() {
11
- return {
12
- resolve: {
13
- conditions: [
14
- "webworker",
15
- "worker"
16
- ]
17
- },
18
- ssr: {
19
- target: "webworker",
20
- noExternal: true,
21
- external: [
22
- "node:async_hooks"
23
- ]
24
- },
25
- build: {
26
- ssr: true,
27
- target: "esnext",
28
- rollupOptions: {
29
- output: {
30
- format: "es",
31
- hoistTransitiveImports: false
32
- }
33
- }
34
- },
35
- publicDir: false
36
- };
37
- }
38
- });
1
+ import { viteAdapter } from "../../shared/vite/index.mjs";
2
+ /** @beta */ function denoServerAdapter(opts = {}) {
3
+ const env = process?.env;
4
+ return viteAdapter({
5
+ name: opts.name || "deno-server",
6
+ origin: env?.ORIGIN ?? env?.URL ?? "https://yoursitename.qwik.dev",
7
+ ssg: opts.ssg,
8
+ cleanStaticGenerated: true,
9
+ config() {
10
+ return {
11
+ resolve: { conditions: ["webworker", "worker"] },
12
+ ssr: {
13
+ target: "webworker",
14
+ noExternal: true,
15
+ external: ["node:async_hooks"]
16
+ },
17
+ build: {
18
+ ssr: true,
19
+ target: "esnext",
20
+ rolldownOptions: { output: { format: "es" } }
21
+ },
22
+ publicDir: false
23
+ };
24
+ }
25
+ });
39
26
  }
40
-
41
27
  export { denoServerAdapter };
@@ -1,78 +1,52 @@
1
- import fs, { existsSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { viteAdapter, getParentDir } from '../../shared/vite/index.mjs';
4
-
5
- function netlifyEdgeAdapter(opts = {}) {
6
- const env = process?.env;
7
- return viteAdapter({
8
- name: "netlify-edge",
9
- origin: env?.ORIGIN ?? env?.URL ?? "https://yoursitename.netlify.app",
10
- ssg: opts.ssg,
11
- staticPaths: opts.staticPaths,
12
- cleanStaticGenerated: true,
13
- config(config) {
14
- const outDir = config.build?.outDir || ".netlify/edge-functions/entry.netlify-edge";
15
- return {
16
- resolve: {
17
- conditions: [
18
- "webworker",
19
- "worker"
20
- ]
21
- },
22
- ssr: {
23
- target: "webworker",
24
- noExternal: true,
25
- external: [
26
- "node:async_hooks"
27
- ]
28
- },
29
- build: {
30
- ssr: true,
31
- outDir,
32
- rollupOptions: {
33
- output: {
34
- format: "es",
35
- hoistTransitiveImports: false
36
- }
37
- }
38
- },
39
- publicDir: false
40
- };
41
- },
42
- async generate({ serverOutDir, basePathname }) {
43
- if (opts.functionRoutes !== false) {
44
- const excludedPath = [];
45
- if (typeof opts.excludedPath === "string") {
46
- excludedPath.push(opts.excludedPath);
47
- } else if (Array.isArray(opts.excludedPath)) {
48
- excludedPath.push(...opts.excludedPath);
49
- } else {
50
- excludedPath.push("/build/*", "/favicon.ico", "/robots.txt", "/mainifest.json", "/~partytown/*", "/service-worker.js", "/sitemap.xml");
51
- }
52
- const netlifyEdgeManifest = {
53
- functions: [
54
- {
55
- path: basePathname + "*",
56
- function: "entry.netlify-edge",
57
- cache: "manual",
58
- excludedPath
59
- }
60
- ],
61
- version: 1
62
- };
63
- const jsPath = join(serverOutDir, "entry.netlify-edge.js");
64
- const mjsPath = join(serverOutDir, "entry.netlify-edge.mjs");
65
- if (existsSync(mjsPath)) {
66
- await fs.promises.writeFile(jsPath, [
67
- `import entry_netlifyEdge from './entry.netlify-edge.mjs';`,
68
- `export default entry_netlifyEdge;`
69
- ].join("\n"));
70
- }
71
- const netlifyEdgeFnsDir = getParentDir(serverOutDir, "edge-functions");
72
- await fs.promises.writeFile(join(netlifyEdgeFnsDir, "manifest.json"), JSON.stringify(netlifyEdgeManifest, null, 2));
73
- }
74
- }
75
- });
1
+ import { getParentDir, viteAdapter } from "../../shared/vite/index.mjs";
2
+ import fs, { existsSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ /** @public */ function netlifyEdgeAdapter(opts = {}) {
5
+ const env = process?.env;
6
+ return viteAdapter({
7
+ name: "netlify-edge",
8
+ origin: env?.ORIGIN ?? env?.URL ?? "https://yoursitename.netlify.app",
9
+ ssg: opts.ssg,
10
+ staticPaths: opts.staticPaths,
11
+ cleanStaticGenerated: true,
12
+ config(config) {
13
+ return {
14
+ resolve: { conditions: ["webworker", "worker"] },
15
+ ssr: {
16
+ target: "webworker",
17
+ noExternal: true,
18
+ external: ["node:async_hooks"]
19
+ },
20
+ build: {
21
+ ssr: true,
22
+ outDir: config.build?.outDir || ".netlify/edge-functions/entry.netlify-edge",
23
+ rolldownOptions: { output: { format: "es" } }
24
+ },
25
+ publicDir: false
26
+ };
27
+ },
28
+ async generate({ serverOutDir, basePathname }) {
29
+ if (opts.functionRoutes !== false) {
30
+ const excludedPath = [];
31
+ if (typeof opts.excludedPath === "string") excludedPath.push(opts.excludedPath);
32
+ else if (Array.isArray(opts.excludedPath)) excludedPath.push(...opts.excludedPath);
33
+ else excludedPath.push("/build/*", "/favicon.ico", "/robots.txt", "/mainifest.json", "/~partytown/*", "/service-worker.js", "/sitemap.xml");
34
+ const netlifyEdgeManifest = {
35
+ functions: [{
36
+ path: basePathname + "*",
37
+ function: "entry.netlify-edge",
38
+ cache: "manual",
39
+ excludedPath
40
+ }],
41
+ version: 1
42
+ };
43
+ const jsPath = join(serverOutDir, "entry.netlify-edge.js");
44
+ const mjsPath = join(serverOutDir, "entry.netlify-edge.mjs");
45
+ if (existsSync(mjsPath)) await fs.promises.writeFile(jsPath, [`import entry_netlifyEdge from './entry.netlify-edge.mjs';`, `export default entry_netlifyEdge;`].join("\n"));
46
+ const netlifyEdgeFnsDir = getParentDir(serverOutDir, "edge-functions");
47
+ await fs.promises.writeFile(join(netlifyEdgeFnsDir, "manifest.json"), JSON.stringify(netlifyEdgeManifest, null, 2));
48
+ }
49
+ }
50
+ });
76
51
  }
77
-
78
52
  export { netlifyEdgeAdapter };
@@ -1,24 +1,18 @@
1
- import { viteAdapter } from '../../shared/vite/index.mjs';
2
-
3
- function nodeServerAdapter(opts = {}) {
4
- const env = process?.env;
5
- return viteAdapter({
6
- name: opts.name || "node-server",
7
- origin: env?.ORIGIN ?? env?.URL ?? "https://yoursitename.qwik.dev",
8
- ssg: opts.ssg,
9
- cleanStaticGenerated: true,
10
- config() {
11
- return {
12
- ssr: {
13
- target: "node"
14
- },
15
- build: {
16
- ssr: true
17
- },
18
- publicDir: false
19
- };
20
- }
21
- });
1
+ import { viteAdapter } from "../../shared/vite/index.mjs";
2
+ /** @beta */ function nodeServerAdapter(opts = {}) {
3
+ const env = process?.env;
4
+ return viteAdapter({
5
+ name: opts.name || "node-server",
6
+ origin: env?.ORIGIN ?? env?.URL ?? "https://yoursitename.qwik.dev",
7
+ ssg: opts.ssg,
8
+ cleanStaticGenerated: true,
9
+ config() {
10
+ return {
11
+ ssr: { target: "node" },
12
+ build: { ssr: true },
13
+ publicDir: false
14
+ };
15
+ }
16
+ });
22
17
  }
23
-
24
18
  export { nodeServerAdapter };