@qwik.dev/router 2.0.0-beta.10 → 2.0.0-beta.11
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.cjs +2 -2
- package/lib/adapters/azure-swa/vite/index.mjs +73 -69
- package/lib/adapters/bun-server/vite/index.cjs +2 -2
- package/lib/adapters/bun-server/vite/index.mjs +77 -73
- package/lib/adapters/cloud-run/vite/index.cjs +2 -2
- package/lib/adapters/cloud-run/vite/index.mjs +104 -100
- package/lib/adapters/cloudflare-pages/vite/{index-DwovcBp3.js → index-Bg_9YkM5.js} +1 -1
- package/lib/adapters/cloudflare-pages/vite/{index-C455V8_A.cjs → index-C1aDmh1S.cjs} +1 -1
- package/lib/adapters/cloudflare-pages/vite/index-CHT9Y93A.js +254 -0
- package/lib/adapters/cloudflare-pages/vite/{index-DKcVHRBy.cjs → index-Ck7KvpK1.cjs} +1 -1
- package/lib/adapters/cloudflare-pages/vite/{index-D3HITboM.js → index-Cp1cjAds.js} +1 -1
- package/lib/adapters/cloudflare-pages/vite/index-D9RL9dvJ.cjs +5 -0
- package/lib/adapters/cloudflare-pages/vite/index.cjs +1 -1
- package/lib/adapters/cloudflare-pages/vite/index.mjs +1 -1
- package/lib/adapters/deno-server/vite/index.cjs +2 -2
- package/lib/adapters/deno-server/vite/index.mjs +81 -77
- package/lib/adapters/netlify-edge/vite/index.cjs +3 -3
- package/lib/adapters/netlify-edge/vite/index.mjs +119 -115
- package/lib/adapters/node-server/vite/index.cjs +2 -2
- package/lib/adapters/node-server/vite/index.mjs +78 -74
- package/lib/adapters/shared/vite/index.cjs +2 -2
- package/lib/adapters/shared/vite/index.mjs +108 -104
- package/lib/adapters/ssg/vite/index.cjs +2 -2
- package/lib/adapters/ssg/vite/index.mjs +100 -96
- package/lib/adapters/vercel-edge/vite/index.cjs +2 -2
- package/lib/adapters/vercel-edge/vite/index.mjs +114 -110
- package/lib/index.qwik.cjs +39 -33
- package/lib/index.qwik.mjs +39 -33
- package/lib/middleware/request-handler/index.cjs +8 -8
- package/lib/middleware/request-handler/index.mjs +598 -587
- package/lib/vite/index.cjs +17 -17
- package/lib/vite/index.d.ts +3 -3
- package/lib/vite/index.mjs +242 -230
- package/package.json +4 -4
- package/lib/adapters/cloudflare-pages/vite/index-BIeHg2Cj.cjs +0 -5
- package/lib/adapters/cloudflare-pages/vite/index-bogwy7wh.js +0 -250
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("node:path"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("node:path"),O=require("@qwik.dev/router/middleware/request-handler"),p=require("node:fs");async function b(e,l,t,n,m){t&&!t.endsWith("/")&&(t+="/");const h=new Set([t+"/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/",t+"/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/"]),s=new Set(n.map(q)),g=[],c=async(o,a,u)=>{if(u=q(u),h.has(u))return;const f=y.join(o,a);if(a==="index.html"||a==="q-data.json"){!s.has(u)&&m&&await p.promises.unlink(f);return}if(a==="404.html"){const r=await p.promises.readFile(f,"utf-8");g.push([u,r]);return}const S=await p.promises.stat(f);S.isDirectory()?await w(f,u+a+"/"):S.isFile()&&s.add(u+a)},w=async(o,a)=>{const u=await p.promises.readdir(o);await Promise.all(u.map(f=>c(o,f,a)))};p.existsSync(e)&&await w(e,t);const i=T(t,g),d=A(s);await R(d,i,l)}function q(e){return e.endsWith("/")?e:e+"/"}function T(e,l){if(l.sort((t,n)=>t[0].length>n[0].length?-1:t[0].length<n[0].length?1:t[0]<n[0]?-1:t[0]>n[0]?1:0),!l.some(t=>t[0]===e)){const t=O.getErrorHtml(404,"Resource Not Found");l.push([e,t])}return JSON.stringify(l,null,2).slice(1,-1)}function A(e){return JSON.stringify(Array.from(new Set(e)).sort()).slice(1,-1)}const R=async(e,l,t)=>{const n=new Set,m=async s=>{const g=await p.promises.readFile(s,"utf-8");let c=!1;const w=g.replace(/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,(i,d,o)=>(c=!0,o==="STATIC_PATHS"?e:l));c&&await p.promises.writeFile(s,w)},h=async s=>{const g=await p.promises.readdir(s,{withFileTypes:!0});for(const c of g)if(c.isDirectory())await h(y.join(s,c.name));else if(c.name.endsWith("js")){const w=m(y.join(s,c.name)).finally(()=>{n.delete(w)});n.add(w)}};await h(t),await Promise.all(n)};function E(e){let l=null,t=null,n=null,m=null,h=null,s=!1,g;const c=[];return{name:`vite-plugin-qwik-router-ssg-${e.name}`,enforce:"post",apply:"build",config(i){return typeof e.config=="function"&&(i=e.config(i)),i.define={"process.env.NODE_ENV":JSON.stringify("production"),...i.define},i},configResolved(i){if(s=!!i.build.ssr,g=i.command,s){if(l=i.plugins.find(d=>d.name==="vite-plugin-qwik-router"),!l)throw new Error("Missing vite-plugin-qwik-router");if(t=i.plugins.find(d=>d.name==="vite-plugin-qwik"),!t)throw new Error("Missing vite-plugin-qwik");if(n=i.build.outDir,i.build?.ssr!==!0)throw new Error(`"build.ssr" must be set to "true" in order to use the "${e.name}" adapter.`);if(!i.build?.rollupOptions?.input)throw new Error(`"build.rollupOptions.input" must be set in order to use the "${e.name}" adapter.`)}},buildStart(){if(s&&e.ssg!==null){const{srcDir:i}=t.api.getOptions();g==="build"&&n&&i&&(this.emitFile({id:"@qwik-router-config",type:"chunk",fileName:"@qwik-router-config.js"}),this.emitFile({id:`${i}/entry.ssr`,type:"chunk",fileName:"entry.ssr.js"}))}},generateBundle(i,d){if(s){c.length=0;for(const o in d){const a=d[o];a.type==="chunk"&&a.isEntry&&(c.push(o),a.name==="entry.ssr"?m=y.join(n,o):a.name==="@qwik-router-config"&&(h=y.join(n,o)))}}},closeBundle:{sequential:!0,async handler(){if(s&&n&&l?.api&&t?.api){const i=e.staticPaths||[],d=l.api.getRoutes(),o=l.api.getBasePathname(),a=t.api.getClientOutDir(),u=t.api.getClientPublicOutDir(),f=t.api.getAssetsDir(),S=t.api.getRootDir()??void 0;if(e.ssg!==null&&m&&h&&a&&u){let r=e.ssg?.origin??e.origin;r||(r="https://yoursite.qwik.dev"),r.length>0&&!/:\/\//.test(r)&&(r=`https://${r}`),r.startsWith("//")&&(r=`https:${r}`);try{r=new URL(r).origin}catch{this.warn(`Invalid "origin" option: "${r}". Using default origin: "https://yoursite.qwik.dev"`),r="https://yoursite.qwik.dev"}const v=await Promise.resolve().then(()=>require("./index-BqUeglYs.cjs")),D={maxWorkers:e.maxWorkers,basePathname:o,outDir:u,rootDir:S,...e.ssg,origin:r,renderModulePath:m,qwikRouterConfigModulePath:h},_=await v.generate(D);if(_.errors>0){const k=new Error(`Error while running SSG from "${e.name}" adapter. At least one path failed to render.`);k.stack=void 0,this.error(k)}i.push(..._.staticPaths)}await b(u,n,f?y.join(o,f):o,i,!!e.cleanStaticGenerated),typeof e.generate=="function"&&await e.generate({outputEntries:c,serverOutDir:n,clientOutDir:a,clientPublicOutDir:u,basePathname:o,routes:d,assetsDir:f,warn:r=>this.warn(r),error:r=>this.error(r)}),this.warn(`
|
|
2
2
|
==============================================
|
|
3
3
|
Note: Make sure that you are serving the built files with proper cache headers.
|
|
4
4
|
See https://qwik.dev/docs/deployments/#cache-headers for more information.
|
|
5
|
-
==============================================`),e.ssg!==null&&setTimeout(()=>{process.exit(0)},5e3).unref()}}}}}function P(e){return
|
|
5
|
+
==============================================`),e.ssg!==null&&setTimeout(()=>{console.warn("SSG seems to be hanging after completion, forcing process to exit. Everything is likely fine."),process.exit(0)},5e3).unref(),e.ssg!==null&&setTimeout(()=>{process.exit(0)},5e3).unref()}}}}}function P(e){return E({name:"static-site-generation",origin:e.origin,ssg:{include:["/*"],...e}})}const j=P;exports.ssgAdapter=P;exports.staticAdapter=j;
|
|
@@ -1,107 +1,107 @@
|
|
|
1
1
|
import { join as y } from "node:path";
|
|
2
2
|
import { getErrorHtml as D } from "@qwik.dev/router/middleware/request-handler";
|
|
3
3
|
import p from "node:fs";
|
|
4
|
-
async function
|
|
5
|
-
|
|
4
|
+
async function O(e, l, t, n, m) {
|
|
5
|
+
t && !t.endsWith("/") && (t += "/");
|
|
6
6
|
const w = /* @__PURE__ */ new Set([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
]), s = new Set(n.map(P)),
|
|
7
|
+
t + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
|
|
8
|
+
t + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
|
|
9
|
+
]), s = new Set(n.map(P)), g = [], c = async (o, a, u) => {
|
|
10
10
|
if (u = P(u), w.has(u))
|
|
11
11
|
return;
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
!s.has(u) && m && await p.promises.unlink(
|
|
12
|
+
const f = y(o, a);
|
|
13
|
+
if (a === "index.html" || a === "q-data.json") {
|
|
14
|
+
!s.has(u) && m && await p.promises.unlink(f);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
|
|
17
|
+
if (a === "404.html") {
|
|
18
|
+
const r = await p.promises.readFile(f, "utf-8");
|
|
19
|
+
g.push([u, r]);
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
const u = await p.promises.readdir(
|
|
26
|
-
await Promise.all(u.map((
|
|
22
|
+
const k = await p.promises.stat(f);
|
|
23
|
+
k.isDirectory() ? await h(f, u + a + "/") : k.isFile() && s.add(u + a);
|
|
24
|
+
}, h = async (o, a) => {
|
|
25
|
+
const u = await p.promises.readdir(o);
|
|
26
|
+
await Promise.all(u.map((f) => c(o, f, a)));
|
|
27
27
|
};
|
|
28
|
-
p.existsSync(
|
|
29
|
-
const
|
|
30
|
-
await
|
|
28
|
+
p.existsSync(e) && await h(e, t);
|
|
29
|
+
const i = R(t, g), d = T(s);
|
|
30
|
+
await b(d, i, l);
|
|
31
31
|
}
|
|
32
|
-
function P(
|
|
33
|
-
return
|
|
32
|
+
function P(e) {
|
|
33
|
+
return e.endsWith("/") ? e : e + "/";
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
|
|
35
|
+
function R(e, l) {
|
|
36
|
+
if (l.sort((t, n) => t[0].length > n[0].length ? -1 : t[0].length < n[0].length ? 1 : t[0] < n[0] ? -1 : t[0] > n[0] ? 1 : 0), !l.some((t) => t[0] === e)) {
|
|
37
|
+
const t = D(404, "Resource Not Found");
|
|
38
|
+
l.push([e, t]);
|
|
39
39
|
}
|
|
40
|
-
return JSON.stringify(
|
|
40
|
+
return JSON.stringify(l, null, 2).slice(1, -1);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return JSON.stringify(Array.from(new Set(
|
|
42
|
+
function T(e) {
|
|
43
|
+
return JSON.stringify(Array.from(new Set(e)).sort()).slice(1, -1);
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const b = async (e, l, t) => {
|
|
46
46
|
const n = /* @__PURE__ */ new Set(), m = async (s) => {
|
|
47
|
-
const
|
|
48
|
-
let
|
|
49
|
-
const
|
|
47
|
+
const g = await p.promises.readFile(s, "utf-8");
|
|
48
|
+
let c = !1;
|
|
49
|
+
const h = g.replace(
|
|
50
50
|
/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,
|
|
51
|
-
(
|
|
51
|
+
(i, d, o) => (c = !0, o === "STATIC_PATHS" ? e : l)
|
|
52
52
|
);
|
|
53
|
-
|
|
53
|
+
c && await p.promises.writeFile(s, h);
|
|
54
54
|
}, w = async (s) => {
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
if (
|
|
58
|
-
await w(y(s,
|
|
59
|
-
else if (
|
|
60
|
-
const
|
|
61
|
-
n.delete(
|
|
55
|
+
const g = await p.promises.readdir(s, { withFileTypes: !0 });
|
|
56
|
+
for (const c of g)
|
|
57
|
+
if (c.isDirectory())
|
|
58
|
+
await w(y(s, c.name));
|
|
59
|
+
else if (c.name.endsWith("js")) {
|
|
60
|
+
const h = m(y(s, c.name)).finally(() => {
|
|
61
|
+
n.delete(h);
|
|
62
62
|
});
|
|
63
|
-
n.add(
|
|
63
|
+
n.add(h);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
await w(
|
|
66
|
+
await w(t), await Promise.all(n);
|
|
67
67
|
};
|
|
68
|
-
function
|
|
69
|
-
let
|
|
70
|
-
const
|
|
68
|
+
function E(e) {
|
|
69
|
+
let l = null, t = null, n = null, m = null, w = null, s = !1, g;
|
|
70
|
+
const c = [];
|
|
71
71
|
return {
|
|
72
|
-
name: `vite-plugin-qwik-router-ssg-${
|
|
72
|
+
name: `vite-plugin-qwik-router-ssg-${e.name}`,
|
|
73
73
|
enforce: "post",
|
|
74
74
|
apply: "build",
|
|
75
75
|
config(i) {
|
|
76
|
-
return typeof
|
|
76
|
+
return typeof e.config == "function" && (i = e.config(i)), i.define = {
|
|
77
77
|
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
78
78
|
...i.define
|
|
79
79
|
}, i;
|
|
80
80
|
},
|
|
81
81
|
configResolved(i) {
|
|
82
|
-
if (s = !!i.build.ssr, s) {
|
|
83
|
-
if (
|
|
82
|
+
if (s = !!i.build.ssr, g = i.command, s) {
|
|
83
|
+
if (l = i.plugins.find(
|
|
84
84
|
(d) => d.name === "vite-plugin-qwik-router"
|
|
85
|
-
), !
|
|
85
|
+
), !l)
|
|
86
86
|
throw new Error("Missing vite-plugin-qwik-router");
|
|
87
|
-
if (
|
|
87
|
+
if (t = i.plugins.find(
|
|
88
88
|
(d) => d.name === "vite-plugin-qwik"
|
|
89
|
-
), !
|
|
89
|
+
), !t)
|
|
90
90
|
throw new Error("Missing vite-plugin-qwik");
|
|
91
91
|
if (n = i.build.outDir, i.build?.ssr !== !0)
|
|
92
92
|
throw new Error(
|
|
93
|
-
`"build.ssr" must be set to "true" in order to use the "${
|
|
93
|
+
`"build.ssr" must be set to "true" in order to use the "${e.name}" adapter.`
|
|
94
94
|
);
|
|
95
95
|
if (!i.build?.rollupOptions?.input)
|
|
96
96
|
throw new Error(
|
|
97
|
-
`"build.rollupOptions.input" must be set in order to use the "${
|
|
97
|
+
`"build.rollupOptions.input" must be set in order to use the "${e.name}" adapter.`
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
buildStart() {
|
|
102
|
-
if (s &&
|
|
103
|
-
const { srcDir: i } =
|
|
104
|
-
this.emitFile({
|
|
102
|
+
if (s && e.ssg !== null) {
|
|
103
|
+
const { srcDir: i } = t.api.getOptions();
|
|
104
|
+
g === "build" && n && i && (this.emitFile({
|
|
105
105
|
id: "@qwik-router-config",
|
|
106
106
|
type: "chunk",
|
|
107
107
|
fileName: "@qwik-router-config.js"
|
|
@@ -109,25 +109,25 @@ function A(t) {
|
|
|
109
109
|
id: `${i}/entry.ssr`,
|
|
110
110
|
type: "chunk",
|
|
111
111
|
fileName: "entry.ssr.js"
|
|
112
|
-
});
|
|
112
|
+
}));
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
generateBundle(i, d) {
|
|
116
116
|
if (s) {
|
|
117
|
-
|
|
118
|
-
for (const
|
|
119
|
-
const a = d[
|
|
120
|
-
a.type === "chunk" && a.isEntry && (
|
|
117
|
+
c.length = 0;
|
|
118
|
+
for (const o in d) {
|
|
119
|
+
const a = d[o];
|
|
120
|
+
a.type === "chunk" && a.isEntry && (c.push(o), a.name === "entry.ssr" ? m = y(n, o) : a.name === "@qwik-router-config" && (w = y(n, o)));
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
124
|
closeBundle: {
|
|
125
125
|
sequential: !0,
|
|
126
126
|
async handler() {
|
|
127
|
-
if (s && n &&
|
|
128
|
-
const i =
|
|
129
|
-
if (
|
|
130
|
-
let r =
|
|
127
|
+
if (s && n && l?.api && t?.api) {
|
|
128
|
+
const i = e.staticPaths || [], d = l.api.getRoutes(), o = l.api.getBasePathname(), a = t.api.getClientOutDir(), u = t.api.getClientPublicOutDir(), f = t.api.getAssetsDir(), k = t.api.getRootDir() ?? void 0;
|
|
129
|
+
if (e.ssg !== null && m && w && a && u) {
|
|
130
|
+
let r = e.ssg?.origin ?? e.origin;
|
|
131
131
|
r || (r = "https://yoursite.qwik.dev"), r.length > 0 && !/:\/\//.test(r) && (r = `https://${r}`), r.startsWith("//") && (r = `https:${r}`);
|
|
132
132
|
try {
|
|
133
133
|
r = new URL(r).origin;
|
|
@@ -136,38 +136,38 @@ function A(t) {
|
|
|
136
136
|
`Invalid "origin" option: "${r}". Using default origin: "https://yoursite.qwik.dev"`
|
|
137
137
|
), r = "https://yoursite.qwik.dev";
|
|
138
138
|
}
|
|
139
|
-
const
|
|
140
|
-
maxWorkers:
|
|
141
|
-
basePathname:
|
|
142
|
-
outDir:
|
|
143
|
-
rootDir:
|
|
144
|
-
...
|
|
139
|
+
const v = await import("./index-CrwlB95_.js"), q = {
|
|
140
|
+
maxWorkers: e.maxWorkers,
|
|
141
|
+
basePathname: o,
|
|
142
|
+
outDir: u,
|
|
143
|
+
rootDir: k,
|
|
144
|
+
...e.ssg,
|
|
145
145
|
origin: r,
|
|
146
146
|
renderModulePath: m,
|
|
147
147
|
qwikRouterConfigModulePath: w
|
|
148
|
-
},
|
|
149
|
-
if (
|
|
150
|
-
const
|
|
151
|
-
`Error while running SSG from "${
|
|
148
|
+
}, S = await v.generate(q);
|
|
149
|
+
if (S.errors > 0) {
|
|
150
|
+
const _ = new Error(
|
|
151
|
+
`Error while running SSG from "${e.name}" adapter. At least one path failed to render.`
|
|
152
152
|
);
|
|
153
|
-
|
|
153
|
+
_.stack = void 0, this.error(_);
|
|
154
154
|
}
|
|
155
|
-
i.push(...
|
|
155
|
+
i.push(...S.staticPaths);
|
|
156
156
|
}
|
|
157
|
-
await
|
|
158
|
-
|
|
157
|
+
await O(
|
|
158
|
+
u,
|
|
159
159
|
n,
|
|
160
|
-
|
|
160
|
+
f ? y(o, f) : o,
|
|
161
161
|
i,
|
|
162
|
-
!!
|
|
163
|
-
), typeof
|
|
164
|
-
outputEntries:
|
|
162
|
+
!!e.cleanStaticGenerated
|
|
163
|
+
), typeof e.generate == "function" && await e.generate({
|
|
164
|
+
outputEntries: c,
|
|
165
165
|
serverOutDir: n,
|
|
166
166
|
clientOutDir: a,
|
|
167
|
-
clientPublicOutDir:
|
|
168
|
-
basePathname:
|
|
167
|
+
clientPublicOutDir: u,
|
|
168
|
+
basePathname: o,
|
|
169
169
|
routes: d,
|
|
170
|
-
assetsDir:
|
|
170
|
+
assetsDir: f,
|
|
171
171
|
warn: (r) => this.warn(r),
|
|
172
172
|
error: (r) => this.error(r)
|
|
173
173
|
}), this.warn(
|
|
@@ -176,7 +176,11 @@ function A(t) {
|
|
|
176
176
|
Note: Make sure that you are serving the built files with proper cache headers.
|
|
177
177
|
See https://qwik.dev/docs/deployments/#cache-headers for more information.
|
|
178
178
|
==============================================`
|
|
179
|
-
),
|
|
179
|
+
), e.ssg !== null && setTimeout(() => {
|
|
180
|
+
console.warn(
|
|
181
|
+
"SSG seems to be hanging after completion, forcing process to exit. Everything is likely fine."
|
|
182
|
+
), process.exit(0);
|
|
183
|
+
}, 5e3).unref(), e.ssg !== null && setTimeout(() => {
|
|
180
184
|
process.exit(0);
|
|
181
185
|
}, 5e3).unref();
|
|
182
186
|
}
|
|
@@ -184,18 +188,18 @@ See https://qwik.dev/docs/deployments/#cache-headers for more information.
|
|
|
184
188
|
}
|
|
185
189
|
};
|
|
186
190
|
}
|
|
187
|
-
function
|
|
188
|
-
return
|
|
191
|
+
function A(e) {
|
|
192
|
+
return E({
|
|
189
193
|
name: "static-site-generation",
|
|
190
|
-
origin:
|
|
194
|
+
origin: e.origin,
|
|
191
195
|
ssg: {
|
|
192
196
|
include: ["/*"],
|
|
193
|
-
...
|
|
197
|
+
...e
|
|
194
198
|
}
|
|
195
199
|
});
|
|
196
200
|
}
|
|
197
|
-
const
|
|
201
|
+
const W = A;
|
|
198
202
|
export {
|
|
199
|
-
|
|
200
|
-
|
|
203
|
+
A as ssgAdapter,
|
|
204
|
+
W as staticAdapter
|
|
201
205
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("node:fs"),d=require("node:path"),q=require("@qwik.dev/router/middleware/request-handler");async function j(e,n,t,i,h){t&&!t.endsWith("/")&&(t+="/");const m=new Set([t+"/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/",t+"/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/"]),s=new Set(i.map(_)),p=[],c=async(l,u,g)=>{if(g=_(g),m.has(g))return;const y=d.join(l,u);if(u==="index.html"||u==="q-data.json"){!s.has(g)&&h&&await w.promises.unlink(y);return}if(u==="404.html"){const o=await w.promises.readFile(y,"utf-8");p.push([g,o]);return}const v=await w.promises.stat(y);v.isDirectory()?await f(y,g+u+"/"):v.isFile()&&s.add(g+u)},f=async(l,u)=>{const g=await w.promises.readdir(l);await Promise.all(g.map(y=>c(l,y,u)))};w.existsSync(e)&&await f(e,t);const r=D(t,p),a=E(s);await O(a,r,n)}function _(e){return e.endsWith("/")?e:e+"/"}function D(e,n){if(n.sort((t,i)=>t[0].length>i[0].length?-1:t[0].length<i[0].length?1:t[0]<i[0]?-1:t[0]>i[0]?1:0),!n.some(t=>t[0]===e)){const t=q.getErrorHtml(404,"Resource Not Found");n.push([e,t])}return JSON.stringify(n,null,2).slice(1,-1)}function E(e){return JSON.stringify(Array.from(new Set(e)).sort()).slice(1,-1)}const O=async(e,n,t)=>{const i=new Set,h=async s=>{const p=await w.promises.readFile(s,"utf-8");let c=!1;const f=p.replace(/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,(r,a,l)=>(c=!0,l==="STATIC_PATHS"?e:n));c&&await w.promises.writeFile(s,f)},m=async s=>{const p=await w.promises.readdir(s,{withFileTypes:!0});for(const c of p)if(c.isDirectory())await m(d.join(s,c.name));else if(c.name.endsWith("js")){const f=h(d.join(s,c.name)).finally(()=>{i.delete(f)});i.add(f)}};await m(t),await Promise.all(i)};function C(e){let n=null,t=null,i=null,h=null,m=null,s=!1,p;const c=[];return{name:`vite-plugin-qwik-router-ssg-${e.name}`,enforce:"post",apply:"build",config(r){return typeof e.config=="function"&&(r=e.config(r)),r.define={"process.env.NODE_ENV":JSON.stringify("production"),...r.define},r},configResolved(r){if(s=!!r.build.ssr,p=r.command,s){if(n=r.plugins.find(a=>a.name==="vite-plugin-qwik-router"),!n)throw new Error("Missing vite-plugin-qwik-router");if(t=r.plugins.find(a=>a.name==="vite-plugin-qwik"),!t)throw new Error("Missing vite-plugin-qwik");if(i=r.build.outDir,r.build?.ssr!==!0)throw new Error(`"build.ssr" must be set to "true" in order to use the "${e.name}" adapter.`);if(!r.build?.rollupOptions?.input)throw new Error(`"build.rollupOptions.input" must be set in order to use the "${e.name}" adapter.`)}},buildStart(){if(s&&e.ssg!==null){const{srcDir:r}=t.api.getOptions();p==="build"&&i&&r&&(this.emitFile({id:"@qwik-router-config",type:"chunk",fileName:"@qwik-router-config.js"}),this.emitFile({id:`${r}/entry.ssr`,type:"chunk",fileName:"entry.ssr.js"}))}},generateBundle(r,a){if(s){c.length=0;for(const l in a){const u=a[l];u.type==="chunk"&&u.isEntry&&(c.push(l),u.name==="entry.ssr"?h=d.join(i,l):u.name==="@qwik-router-config"&&(m=d.join(i,l)))}}},closeBundle:{sequential:!0,async handler(){if(s&&i&&n?.api&&t?.api){const r=e.staticPaths||[],a=n.api.getRoutes(),l=n.api.getBasePathname(),u=t.api.getClientOutDir(),g=t.api.getClientPublicOutDir(),y=t.api.getAssetsDir(),v=t.api.getRootDir()??void 0;if(e.ssg!==null&&h&&m&&u&&g){let o=e.ssg?.origin??e.origin;o||(o="https://yoursite.qwik.dev"),o.length>0&&!/:\/\//.test(o)&&(o=`https://${o}`),o.startsWith("//")&&(o=`https:${o}`);try{o=new URL(o).origin}catch{this.warn(`Invalid "origin" option: "${o}". Using default origin: "https://yoursite.qwik.dev"`),o="https://yoursite.qwik.dev"}const P=await Promise.resolve().then(()=>require("./index-BqUeglYs.cjs")),b={maxWorkers:e.maxWorkers,basePathname:l,outDir:g,rootDir:v,...e.ssg,origin:o,renderModulePath:h,qwikRouterConfigModulePath:m},k=await P.generate(b);if(k.errors>0){const S=new Error(`Error while running SSG from "${e.name}" adapter. At least one path failed to render.`);S.stack=void 0,this.error(S)}r.push(...k.staticPaths)}await j(g,i,y?d.join(l,y):l,r,!!e.cleanStaticGenerated),typeof e.generate=="function"&&await e.generate({outputEntries:c,serverOutDir:i,clientOutDir:u,clientPublicOutDir:g,basePathname:l,routes:a,assetsDir:y,warn:o=>this.warn(o),error:o=>this.error(o)}),this.warn(`
|
|
2
2
|
==============================================
|
|
3
3
|
Note: Make sure that you are serving the built files with proper cache headers.
|
|
4
4
|
See https://qwik.dev/docs/deployments/#cache-headers for more information.
|
|
5
|
-
==============================================`),e.ssg!==null&&setTimeout(()=>{process.exit(0)},5e3).unref()}}}}}function
|
|
5
|
+
==============================================`),e.ssg!==null&&setTimeout(()=>{console.warn("SSG seems to be hanging after completion, forcing process to exit. Everything is likely fine."),process.exit(0)},5e3).unref(),e.ssg!==null&&setTimeout(()=>{process.exit(0)},5e3).unref()}}}}}function R(e,n){const t=d.resolve("/");let i=e;for(let h=0;h<20;h++){if(i=d.dirname(i),d.basename(i)===n)return i;if(i===t)break}throw new Error(`Unable to find "${n}" directory from "${e}"`)}function T(e={}){return C({name:"vercel-edge",origin:process?.env?.VERCEL_URL||"https://yoursitename.vercel.app",ssg:e.ssg,staticPaths:e.staticPaths,cleanStaticGenerated:!0,config(n){const t=n.build?.outDir||d.join(".vercel","output","functions","_qwik-router.func");return{resolve:{conditions:e.target==="node"?["node","import","module","browser","default"]:["edge-light","webworker","worker","browser","module","main"]},ssr:{target:e.target==="node"?"node":"webworker",noExternal:!0},build:{ssr:!0,outDir:t,rollupOptions:{output:{format:"es",hoistTransitiveImports:!1}}},publicDir:!1}},async generate({clientPublicOutDir:n,serverOutDir:t,basePathname:i,outputEntries:h}){const m=R(t,"output");if(e.outputConfig!==!1){const a={routes:[{handle:"filesystem"},{src:i+".*",dest:"/_qwik-router"}],version:3};await w.promises.writeFile(d.join(m,"config.json"),JSON.stringify(a,null,2))}let s=e.vcConfigEntryPoint;s||(h.some(a=>a==="entry.vercel-edge.mjs")?s="entry.vercel-edge.mjs":s="entry.vercel-edge.js");const p=d.join(t,".vc-config.json"),c={runtime:"edge",entrypoint:s,envVarsInUse:e.vcConfigEnvVarsInUse};await w.promises.writeFile(p,JSON.stringify(c,null,2));let f=d.join(m,"static");const r=i.split("/").filter(a=>a.length>0);r.length>0&&(f=d.join(f,...r)),await w.promises.rm(f,{recursive:!0,force:!0}),await w.promises.mkdir(d.dirname(f),{recursive:!0}),await w.promises.rename(n,f)}})}exports.vercelEdgeAdapter=T;
|