@qwik.dev/router 2.0.0-beta.8 → 2.0.0-rc.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.
- package/lib/adapters/azure-swa/vite/index.d.ts +2 -2
- package/lib/adapters/azure-swa/vite/index.mjs +44 -57
- package/lib/adapters/bun-server/vite/index.d.ts +2 -2
- package/lib/adapters/bun-server/vite/index.mjs +16 -22
- package/lib/adapters/cloud-run/vite/index.d.ts +2 -2
- package/lib/adapters/cloud-run/vite/index.mjs +15 -19
- package/lib/adapters/cloudflare-pages/vite/index.d.ts +2 -2
- package/lib/adapters/cloudflare-pages/vite/index.mjs +45 -76
- package/lib/adapters/deno-server/vite/index.d.ts +2 -2
- package/lib/adapters/deno-server/vite/index.mjs +25 -34
- package/lib/adapters/netlify-edge/vite/index.d.ts +2 -2
- package/lib/adapters/netlify-edge/vite/index.mjs +49 -89
- package/lib/adapters/node-server/vite/index.d.ts +2 -2
- package/lib/adapters/node-server/vite/index.mjs +16 -22
- package/lib/adapters/shared/vite/index.d.ts +9 -16
- package/lib/adapters/shared/vite/index.mjs +280 -293
- package/lib/adapters/ssg/vite/index.d.ts +1 -1
- package/lib/adapters/ssg/vite/index.mjs +13 -299
- package/lib/adapters/vercel-edge/vite/index.d.ts +3 -3
- package/lib/adapters/vercel-edge/vite/index.mjs +75 -79
- package/lib/chunks/dev-preloaded-route-loader.mjs +2 -0
- package/lib/chunks/format.mjs +24 -0
- package/lib/chunks/fs.mjs +143 -0
- package/lib/chunks/head.qwik.mjs +1570 -0
- package/lib/chunks/http-error.qwik.mjs +28 -0
- package/lib/chunks/pathname.mjs +58 -0
- package/lib/chunks/request-body-limit.mjs +27 -0
- package/lib/chunks/request-path.mjs +53 -0
- package/lib/chunks/route-trie-key.mjs +10 -0
- package/lib/chunks/routes.mjs +26 -0
- package/lib/chunks/server-error.mjs +38 -0
- package/lib/chunks/static-file.mjs +70 -0
- package/lib/chunks/system.mjs +271 -0
- package/lib/chunks/user-response.mjs +1883 -0
- package/lib/chunks/worker-thread.mjs +274 -0
- package/lib/index.d.ts +550 -182
- package/lib/index.qwik.mjs +1742 -2030
- package/lib/middleware/aws-lambda/index.d.ts +15 -17
- package/lib/middleware/aws-lambda/index.mjs +46 -50
- package/lib/middleware/azure-swa/index.mjs +85 -294
- package/lib/middleware/bun/index.d.ts +20 -5
- package/lib/middleware/bun/index.mjs +117 -201
- package/lib/middleware/cloudflare-pages/index.mjs +101 -101
- package/lib/middleware/deno/index.d.ts +22 -5
- package/lib/middleware/deno/index.mjs +103 -191
- package/lib/middleware/firebase/index.mjs +22 -31
- package/lib/middleware/netlify-edge/index.mjs +63 -80
- package/lib/middleware/node/index.d.ts +17 -5
- package/lib/middleware/node/index.mjs +298 -269
- package/lib/middleware/request-handler/index.d.ts +259 -58
- package/lib/middleware/request-handler/index.mjs +108 -1730
- package/lib/middleware/vercel-edge/index.mjs +76 -100
- package/lib/modules.d.ts +7 -4
- package/lib/service-worker/index.mjs +14 -0
- package/lib/ssg/index.d.ts +50 -26
- package/lib/ssg/index.mjs +257 -43
- package/lib/vite/index.d.ts +59 -11
- package/lib/vite/index.mjs +2533 -27535
- package/modules.d.ts +7 -4
- package/package.json +53 -70
- package/lib/adapters/azure-swa/vite/index.cjs +0 -96
- package/lib/adapters/bun-server/vite/index.cjs +0 -50
- package/lib/adapters/cloud-run/vite/index.cjs +0 -47
- package/lib/adapters/cloudflare-pages/vite/index.cjs +0 -115
- package/lib/adapters/deno-server/vite/index.cjs +0 -62
- package/lib/adapters/netlify-edge/vite/index.cjs +0 -130
- package/lib/adapters/node-server/vite/index.cjs +0 -50
- package/lib/adapters/shared/vite/index.cjs +0 -338
- package/lib/adapters/ssg/vite/index.cjs +0 -339
- package/lib/adapters/vercel-edge/vite/index.cjs +0 -118
- package/lib/index.qwik.cjs +0 -2085
- package/lib/middleware/node/index.cjs +0 -310
- package/lib/middleware/request-handler/index.cjs +0 -1766
- package/lib/service-worker.cjs +0 -17
- package/lib/service-worker.mjs +0 -15
- package/lib/ssg/deno.mjs +0 -8
- package/lib/ssg/index.cjs +0 -67
- package/lib/ssg/node.cjs +0 -1126
- package/lib/ssg/node.mjs +0 -1088
- package/lib/vite/index.cjs +0 -27607
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type { SsgRenderOptions } from '
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite/index.js';
|
|
2
|
+
import type { SsgRenderOptions } from '../../../ssg/index.js';
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
5
|
export declare function azureSwaAdapter(opts?: AzureSwaAdapterOptions): any;
|
|
@@ -1,61 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
|
|
4
|
+
/** @public */
|
|
5
5
|
function azureSwaAdapter(opts = {}) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
scriptFile: azureSwaModulePath
|
|
48
|
-
},
|
|
49
|
-
null,
|
|
50
|
-
2
|
|
51
|
-
);
|
|
52
|
-
await fs.promises.writeFile(funcJsonPath, funcJson);
|
|
53
|
-
if (!fs.existsSync(join(clientPublicOutDir, "index.html"))) {
|
|
54
|
-
await fs.promises.writeFile(join(clientPublicOutDir, "index.html"), "");
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
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, { recursive: true });
|
|
16
|
+
await fs.promises.writeFile(serverPackageJsonPath, serverPackageJsonCode);
|
|
17
|
+
const azureSwaModulePath = outputEntries.find((entryName) => entryName.indexOf("entry.azure-swa") === 0);
|
|
18
|
+
const funcJsonPath = join(serverOutDir, "function.json");
|
|
19
|
+
const funcJson = JSON.stringify({
|
|
20
|
+
bindings: [{
|
|
21
|
+
authLevel: "anonymous",
|
|
22
|
+
type: "httpTrigger",
|
|
23
|
+
direction: "in",
|
|
24
|
+
name: "req",
|
|
25
|
+
methods: [
|
|
26
|
+
"get",
|
|
27
|
+
"head",
|
|
28
|
+
"post",
|
|
29
|
+
"put",
|
|
30
|
+
"delete",
|
|
31
|
+
"connect",
|
|
32
|
+
"options",
|
|
33
|
+
"trace",
|
|
34
|
+
"patch"
|
|
35
|
+
]
|
|
36
|
+
}, {
|
|
37
|
+
type: "http",
|
|
38
|
+
direction: "out",
|
|
39
|
+
name: "$return"
|
|
40
|
+
}],
|
|
41
|
+
scriptFile: azureSwaModulePath
|
|
42
|
+
}, null, 2);
|
|
43
|
+
await fs.promises.writeFile(funcJsonPath, funcJson);
|
|
44
|
+
if (!fs.existsSync(join(clientPublicOutDir, "index.html"))) await fs.promises.writeFile(join(clientPublicOutDir, "index.html"), "");
|
|
45
|
+
}
|
|
46
|
+
});
|
|
58
47
|
}
|
|
59
|
-
export {
|
|
60
|
-
azureSwaAdapter
|
|
61
|
-
};
|
|
48
|
+
export { azureSwaAdapter };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type { SsgRenderOptions } from '
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite/index.js';
|
|
2
|
+
import type { SsgRenderOptions } from '../../../ssg/index.js';
|
|
3
3
|
|
|
4
4
|
/** @beta */
|
|
5
5
|
export declare function bunServerAdapter(opts?: bunServerAdapterOptions): any;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
// packages/qwik-router/src/adapters/bun-server/vite/index.ts
|
|
2
1
|
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
2
|
+
/** @beta */
|
|
3
3
|
function bunServerAdapter(opts = {}) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
publicDir: false
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
});
|
|
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: { target: "node" },
|
|
13
|
+
build: { ssr: true },
|
|
14
|
+
publicDir: false
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
});
|
|
22
18
|
}
|
|
23
|
-
export {
|
|
24
|
-
bunServerAdapter
|
|
25
|
-
};
|
|
19
|
+
export { bunServerAdapter };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type { SsgRenderOptions } from '
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite/index.js';
|
|
2
|
+
import type { SsgRenderOptions } from '../../../ssg/index.js';
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
5
|
export declare function cloudRunAdapter(opts?: CloudRunAdapterOptions): any;
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
// packages/qwik-router/src/adapters/cloud-run/vite/index.ts
|
|
2
1
|
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
2
|
+
/** @public */
|
|
3
3
|
function cloudRunAdapter(opts = {}) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
});
|
|
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: { ssr: true },
|
|
13
|
+
publicDir: false
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
});
|
|
19
17
|
}
|
|
20
|
-
export {
|
|
21
|
-
cloudRunAdapter
|
|
22
|
-
};
|
|
18
|
+
export { cloudRunAdapter };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type { SsgRenderOptions } from '
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite/index.js';
|
|
2
|
+
import type { SsgRenderOptions } from '../../../ssg/index.js';
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
5
|
export declare function cloudflarePagesAdapter(opts?: CloudflarePagesAdapterOptions): any;
|
|
@@ -1,80 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
import { t as ensureSlash } from "../../../chunks/pathname.mjs";
|
|
2
|
+
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
3
|
+
import { y as normalizePathSlash } from "../../../chunks/fs.mjs";
|
|
2
4
|
import fs from "node:fs";
|
|
3
5
|
import { join, relative } from "node:path";
|
|
4
|
-
|
|
5
|
-
// packages/qwik-router/src/utils/fs.ts
|
|
6
|
-
function normalizePathSlash(path) {
|
|
7
|
-
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
|
|
8
|
-
const hasNonAscii = /[^\u0000-\u0080]+/.test(path);
|
|
9
|
-
if (isExtendedLengthPath || hasNonAscii) {
|
|
10
|
-
return path;
|
|
11
|
-
}
|
|
12
|
-
path = path.replace(/\\/g, "/");
|
|
13
|
-
if (path.endsWith("/")) {
|
|
14
|
-
path = path.slice(0, path.length - 1);
|
|
15
|
-
}
|
|
16
|
-
return path;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// packages/qwik-router/src/adapters/cloudflare-pages/vite/index.ts
|
|
20
|
-
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
6
|
+
/** @public */
|
|
21
7
|
function cloudflarePagesAdapter(opts = {}) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
exclude: [pathName + "build/*", pathName + "assets/*"]
|
|
63
|
-
};
|
|
64
|
-
await fs.promises.writeFile(routesJsonPath, JSON.stringify(routesJson, void 0, 2));
|
|
65
|
-
}
|
|
66
|
-
const workerJsPath = join(clientOutDir, "_worker.js");
|
|
67
|
-
const hasWorkerJs = fs.existsSync(workerJsPath);
|
|
68
|
-
if (!hasWorkerJs) {
|
|
69
|
-
const importPath = relative(clientOutDir, join(serverOutDir, "entry.cloudflare-pages"));
|
|
70
|
-
await fs.promises.writeFile(
|
|
71
|
-
workerJsPath,
|
|
72
|
-
`import { fetch } from "${normalizePathSlash(importPath)}"; export default { fetch };`
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
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: { conditions: ["webworker", "worker"] },
|
|
18
|
+
ssr: {
|
|
19
|
+
target: "webworker",
|
|
20
|
+
noExternal: true,
|
|
21
|
+
external: ["node:async_hooks"]
|
|
22
|
+
},
|
|
23
|
+
build: {
|
|
24
|
+
ssr: true,
|
|
25
|
+
rolldownOptions: { output: { format: "es" } }
|
|
26
|
+
},
|
|
27
|
+
publicDir: false
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
async generate({ clientOutDir, serverOutDir, basePathname }) {
|
|
31
|
+
const routesJsonPath = join(clientOutDir, "_routes.json");
|
|
32
|
+
if (!fs.existsSync(routesJsonPath) && opts.functionRoutes !== false) {
|
|
33
|
+
const pathName = ensureSlash(basePathname);
|
|
34
|
+
const routesJson = {
|
|
35
|
+
version: 1,
|
|
36
|
+
include: [basePathname + "*"],
|
|
37
|
+
exclude: [pathName + "build/*", pathName + "assets/*"]
|
|
38
|
+
};
|
|
39
|
+
await fs.promises.writeFile(routesJsonPath, JSON.stringify(routesJson, void 0, 2));
|
|
40
|
+
}
|
|
41
|
+
const workerJsPath = join(clientOutDir, "_worker.js");
|
|
42
|
+
if (!fs.existsSync(workerJsPath)) {
|
|
43
|
+
const importPath = relative(clientOutDir, join(serverOutDir, "entry.cloudflare-pages"));
|
|
44
|
+
await fs.promises.writeFile(workerJsPath, `import { fetch } from "${normalizePathSlash(importPath)}"; export default { fetch };`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
77
48
|
}
|
|
78
|
-
export {
|
|
79
|
-
cloudflarePagesAdapter
|
|
80
|
-
};
|
|
49
|
+
export { cloudflarePagesAdapter };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type { SsgRenderOptions } from '
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite/index.js';
|
|
2
|
+
import type { SsgRenderOptions } from '../../../ssg/index.js';
|
|
3
3
|
|
|
4
4
|
/** @beta */
|
|
5
5
|
export declare function denoServerAdapter(opts?: DenoServerAdapterOptions): any;
|
|
@@ -1,37 +1,28 @@
|
|
|
1
|
-
// packages/qwik-router/src/adapters/deno-server/vite/index.ts
|
|
2
1
|
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
2
|
+
/** @beta */
|
|
3
3
|
function denoServerAdapter(opts = {}) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
publicDir: false
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
});
|
|
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: { conditions: ["webworker", "worker"] },
|
|
13
|
+
ssr: {
|
|
14
|
+
target: "webworker",
|
|
15
|
+
noExternal: true,
|
|
16
|
+
external: ["node:async_hooks"]
|
|
17
|
+
},
|
|
18
|
+
build: {
|
|
19
|
+
ssr: true,
|
|
20
|
+
target: "esnext",
|
|
21
|
+
rolldownOptions: { output: { format: "es" } }
|
|
22
|
+
},
|
|
23
|
+
publicDir: false
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
34
27
|
}
|
|
35
|
-
export {
|
|
36
|
-
denoServerAdapter
|
|
37
|
-
};
|
|
28
|
+
export { denoServerAdapter };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type { SsgRenderOptions } from '
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite/index.js';
|
|
2
|
+
import type { SsgRenderOptions } from '../../../ssg/index.js';
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
5
|
export declare function netlifyEdgeAdapter(opts?: NetlifyEdgeAdapterOptions): any;
|
|
@@ -1,93 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
var trailingSlash = !globalThis.__NO_TRAILING_SLASH__;
|
|
3
|
-
var basePathname = "/";
|
|
4
|
-
|
|
5
|
-
// packages/qwik-router/src/adapters/netlify-edge/vite/index.ts
|
|
1
|
+
import { getParentDir, viteAdapter } from "../../shared/vite/index.mjs";
|
|
6
2
|
import fs, { existsSync } from "node:fs";
|
|
7
3
|
import { join } from "node:path";
|
|
8
|
-
|
|
4
|
+
/** @public */
|
|
9
5
|
function netlifyEdgeAdapter(opts = {}) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"/service-worker.js",
|
|
57
|
-
"/sitemap.xml"
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
const netlifyEdgeManifest = {
|
|
61
|
-
functions: [
|
|
62
|
-
{
|
|
63
|
-
path: basePathname + "*",
|
|
64
|
-
function: "entry.netlify-edge",
|
|
65
|
-
cache: "manual",
|
|
66
|
-
excludedPath
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
version: 1
|
|
70
|
-
};
|
|
71
|
-
const jsPath = join(serverOutDir, "entry.netlify-edge.js");
|
|
72
|
-
const mjsPath = join(serverOutDir, "entry.netlify-edge.mjs");
|
|
73
|
-
if (existsSync(mjsPath)) {
|
|
74
|
-
await fs.promises.writeFile(
|
|
75
|
-
jsPath,
|
|
76
|
-
[
|
|
77
|
-
`import entry_netlifyEdge from './entry.netlify-edge.mjs';`,
|
|
78
|
-
`export default entry_netlifyEdge;`
|
|
79
|
-
].join("\n")
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
const netlifyEdgeFnsDir = getParentDir(serverOutDir, "edge-functions");
|
|
83
|
-
await fs.promises.writeFile(
|
|
84
|
-
join(netlifyEdgeFnsDir, "manifest.json"),
|
|
85
|
-
JSON.stringify(netlifyEdgeManifest, null, 2)
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
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
|
+
return {
|
|
15
|
+
resolve: { conditions: ["webworker", "worker"] },
|
|
16
|
+
ssr: {
|
|
17
|
+
target: "webworker",
|
|
18
|
+
noExternal: true,
|
|
19
|
+
external: ["node:async_hooks"]
|
|
20
|
+
},
|
|
21
|
+
build: {
|
|
22
|
+
ssr: true,
|
|
23
|
+
outDir: config.build?.outDir || ".netlify/edge-functions/entry.netlify-edge",
|
|
24
|
+
rolldownOptions: { output: { format: "es" } }
|
|
25
|
+
},
|
|
26
|
+
publicDir: false
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
async generate({ serverOutDir, basePathname }) {
|
|
30
|
+
if (opts.functionRoutes !== false) {
|
|
31
|
+
const excludedPath = [];
|
|
32
|
+
if (typeof opts.excludedPath === "string") excludedPath.push(opts.excludedPath);
|
|
33
|
+
else if (Array.isArray(opts.excludedPath)) excludedPath.push(...opts.excludedPath);
|
|
34
|
+
else excludedPath.push("/build/*", "/favicon.ico", "/robots.txt", "/mainifest.json", "/~partytown/*", "/service-worker.js", "/sitemap.xml");
|
|
35
|
+
const netlifyEdgeManifest = {
|
|
36
|
+
functions: [{
|
|
37
|
+
path: basePathname + "*",
|
|
38
|
+
function: "entry.netlify-edge",
|
|
39
|
+
cache: "manual",
|
|
40
|
+
excludedPath
|
|
41
|
+
}],
|
|
42
|
+
version: 1
|
|
43
|
+
};
|
|
44
|
+
const jsPath = join(serverOutDir, "entry.netlify-edge.js");
|
|
45
|
+
const mjsPath = join(serverOutDir, "entry.netlify-edge.mjs");
|
|
46
|
+
if (existsSync(mjsPath)) await fs.promises.writeFile(jsPath, [`import entry_netlifyEdge from './entry.netlify-edge.mjs';`, `export default entry_netlifyEdge;`].join("\n"));
|
|
47
|
+
const netlifyEdgeFnsDir = getParentDir(serverOutDir, "edge-functions");
|
|
48
|
+
await fs.promises.writeFile(join(netlifyEdgeFnsDir, "manifest.json"), JSON.stringify(netlifyEdgeManifest, null, 2));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
90
52
|
}
|
|
91
|
-
export {
|
|
92
|
-
netlifyEdgeAdapter
|
|
93
|
-
};
|
|
53
|
+
export { netlifyEdgeAdapter };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type { SsgRenderOptions } from '
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite/index.js';
|
|
2
|
+
import type { SsgRenderOptions } from '../../../ssg/index.js';
|
|
3
3
|
|
|
4
4
|
/** @beta */
|
|
5
5
|
export declare function nodeServerAdapter(opts?: NodeServerAdapterOptions): any;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
// packages/qwik-router/src/adapters/node-server/vite/index.ts
|
|
2
1
|
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
2
|
+
/** @beta */
|
|
3
3
|
function nodeServerAdapter(opts = {}) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
publicDir: false
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
});
|
|
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: { target: "node" },
|
|
13
|
+
build: { ssr: true },
|
|
14
|
+
publicDir: false
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
});
|
|
22
18
|
}
|
|
23
|
-
export {
|
|
24
|
-
nodeServerAdapter
|
|
25
|
-
};
|
|
19
|
+
export { nodeServerAdapter };
|