@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,73 +1,73 @@
|
|
|
1
1
|
import { join as y } from "node:path";
|
|
2
|
-
import { getErrorHtml as
|
|
2
|
+
import { getErrorHtml as D } from "@qwik.dev/router/middleware/request-handler";
|
|
3
3
|
import p from "node:fs";
|
|
4
|
-
async function
|
|
4
|
+
async function O(e, s, t, n, m) {
|
|
5
5
|
t && !t.endsWith("/") && (t += "/");
|
|
6
6
|
const w = /* @__PURE__ */ new Set([
|
|
7
7
|
t + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
|
|
8
8
|
t + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
|
|
9
|
-
]), o = new Set(
|
|
9
|
+
]), o = new Set(n.map(v)), g = [], c = async (a, l, u) => {
|
|
10
10
|
if (u = v(u), w.has(u))
|
|
11
11
|
return;
|
|
12
|
-
const
|
|
12
|
+
const f = y(a, l);
|
|
13
13
|
if (l === "index.html" || l === "q-data.json") {
|
|
14
|
-
!o.has(u) && m && await p.promises.unlink(
|
|
14
|
+
!o.has(u) && m && await p.promises.unlink(f);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
if (l === "404.html") {
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const r = await p.promises.readFile(f, "utf-8");
|
|
19
|
+
g.push([u, r]);
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
},
|
|
22
|
+
const S = await p.promises.stat(f);
|
|
23
|
+
S.isDirectory() ? await h(f, u + l + "/") : S.isFile() && o.add(u + l);
|
|
24
|
+
}, h = async (a, l) => {
|
|
25
25
|
const u = await p.promises.readdir(a);
|
|
26
|
-
await Promise.all(u.map((
|
|
26
|
+
await Promise.all(u.map((f) => c(a, f, l)));
|
|
27
27
|
};
|
|
28
|
-
p.existsSync(e) && await
|
|
29
|
-
const
|
|
30
|
-
await
|
|
28
|
+
p.existsSync(e) && await h(e, t);
|
|
29
|
+
const i = R(t, g), d = b(o);
|
|
30
|
+
await T(d, i, s);
|
|
31
31
|
}
|
|
32
32
|
function v(e) {
|
|
33
33
|
return e.endsWith("/") ? e : e + "/";
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
if (
|
|
37
|
-
const t =
|
|
38
|
-
|
|
35
|
+
function R(e, s) {
|
|
36
|
+
if (s.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), !s.some((t) => t[0] === e)) {
|
|
37
|
+
const t = D(404, "Resource Not Found");
|
|
38
|
+
s.push([e, t]);
|
|
39
39
|
}
|
|
40
|
-
return JSON.stringify(
|
|
40
|
+
return JSON.stringify(s, null, 2).slice(1, -1);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function b(e) {
|
|
43
43
|
return JSON.stringify(Array.from(new Set(e)).sort()).slice(1, -1);
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
let
|
|
49
|
-
const
|
|
45
|
+
const T = async (e, s, t) => {
|
|
46
|
+
const n = /* @__PURE__ */ new Set(), m = async (o) => {
|
|
47
|
+
const g = await p.promises.readFile(o, "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, a) => (c = !0, a === "STATIC_PATHS" ? e : s)
|
|
52
52
|
);
|
|
53
|
-
|
|
53
|
+
c && await p.promises.writeFile(o, h);
|
|
54
54
|
}, w = async (o) => {
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
if (
|
|
58
|
-
await w(y(o,
|
|
59
|
-
else if (
|
|
60
|
-
const
|
|
61
|
-
|
|
55
|
+
const g = await p.promises.readdir(o, { withFileTypes: !0 });
|
|
56
|
+
for (const c of g)
|
|
57
|
+
if (c.isDirectory())
|
|
58
|
+
await w(y(o, c.name));
|
|
59
|
+
else if (c.name.endsWith("js")) {
|
|
60
|
+
const h = m(y(o, c.name)).finally(() => {
|
|
61
|
+
n.delete(h);
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
n.add(h);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
await w(t), await Promise.all(
|
|
66
|
+
await w(t), await Promise.all(n);
|
|
67
67
|
};
|
|
68
|
-
function
|
|
69
|
-
let
|
|
70
|
-
const
|
|
68
|
+
function E(e) {
|
|
69
|
+
let s = null, t = null, n = null, m = null, w = null, o = !1, g;
|
|
70
|
+
const c = [];
|
|
71
71
|
return {
|
|
72
72
|
name: `vite-plugin-qwik-router-ssg-${e.name}`,
|
|
73
73
|
enforce: "post",
|
|
@@ -79,16 +79,16 @@ function T(e) {
|
|
|
79
79
|
}, i;
|
|
80
80
|
},
|
|
81
81
|
configResolved(i) {
|
|
82
|
-
if (o = !!i.build.ssr, o) {
|
|
83
|
-
if (
|
|
82
|
+
if (o = !!i.build.ssr, g = i.command, o) {
|
|
83
|
+
if (s = i.plugins.find(
|
|
84
84
|
(d) => d.name === "vite-plugin-qwik-router"
|
|
85
|
-
), !
|
|
85
|
+
), !s)
|
|
86
86
|
throw new Error("Missing vite-plugin-qwik-router");
|
|
87
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
|
-
if (
|
|
91
|
+
if (n = i.build.outDir, i.build?.ssr !== !0)
|
|
92
92
|
throw new Error(
|
|
93
93
|
`"build.ssr" must be set to "true" in order to use the "${e.name}" adapter.`
|
|
94
94
|
);
|
|
@@ -101,7 +101,7 @@ function T(e) {
|
|
|
101
101
|
buildStart() {
|
|
102
102
|
if (o && e.ssg !== null) {
|
|
103
103
|
const { srcDir: i } = t.api.getOptions();
|
|
104
|
-
this.emitFile({
|
|
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,24 +109,24 @@ function T(e) {
|
|
|
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 (o) {
|
|
117
|
-
|
|
118
|
-
for (const
|
|
119
|
-
const
|
|
120
|
-
|
|
117
|
+
c.length = 0;
|
|
118
|
+
for (const a in d) {
|
|
119
|
+
const l = d[a];
|
|
120
|
+
l.type === "chunk" && l.isEntry && (c.push(a), l.name === "entry.ssr" ? m = y(n, a) : l.name === "@qwik-router-config" && (w = y(n, a)));
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
124
|
closeBundle: {
|
|
125
125
|
sequential: !0,
|
|
126
126
|
async handler() {
|
|
127
|
-
if (o &&
|
|
128
|
-
const i = e.staticPaths || [], d =
|
|
129
|
-
if (e.ssg !== null && m && w &&
|
|
127
|
+
if (o && n && s?.api && t?.api) {
|
|
128
|
+
const i = e.staticPaths || [], d = s.api.getRoutes(), a = s.api.getBasePathname(), l = t.api.getClientOutDir(), u = t.api.getClientPublicOutDir(), f = t.api.getAssetsDir(), S = t.api.getRootDir() ?? void 0;
|
|
129
|
+
if (e.ssg !== null && m && w && l && u) {
|
|
130
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 {
|
|
@@ -136,38 +136,38 @@ function T(e) {
|
|
|
136
136
|
`Invalid "origin" option: "${r}". Using default origin: "https://yoursite.qwik.dev"`
|
|
137
137
|
), r = "https://yoursite.qwik.dev";
|
|
138
138
|
}
|
|
139
|
-
const
|
|
139
|
+
const P = await import("./index-CrwlB95_.js"), q = {
|
|
140
140
|
maxWorkers: e.maxWorkers,
|
|
141
|
-
basePathname:
|
|
142
|
-
outDir:
|
|
143
|
-
rootDir:
|
|
141
|
+
basePathname: a,
|
|
142
|
+
outDir: u,
|
|
143
|
+
rootDir: S,
|
|
144
144
|
...e.ssg,
|
|
145
145
|
origin: r,
|
|
146
146
|
renderModulePath: m,
|
|
147
147
|
qwikRouterConfigModulePath: w
|
|
148
|
-
},
|
|
149
|
-
if (
|
|
148
|
+
}, k = await P.generate(q);
|
|
149
|
+
if (k.errors > 0) {
|
|
150
150
|
const _ = new Error(
|
|
151
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(...k.staticPaths);
|
|
156
156
|
}
|
|
157
|
-
await
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
await O(
|
|
158
|
+
u,
|
|
159
|
+
n,
|
|
160
|
+
f ? y(a, f) : a,
|
|
161
161
|
i,
|
|
162
162
|
!!e.cleanStaticGenerated
|
|
163
163
|
), typeof e.generate == "function" && await e.generate({
|
|
164
|
-
outputEntries:
|
|
165
|
-
serverOutDir:
|
|
166
|
-
clientOutDir:
|
|
167
|
-
clientPublicOutDir:
|
|
168
|
-
basePathname:
|
|
164
|
+
outputEntries: c,
|
|
165
|
+
serverOutDir: n,
|
|
166
|
+
clientOutDir: l,
|
|
167
|
+
clientPublicOutDir: u,
|
|
168
|
+
basePathname: a,
|
|
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(
|
|
@@ -177,6 +177,10 @@ 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,11 +188,11 @@ See https://qwik.dev/docs/deployments/#cache-headers for more information.
|
|
|
184
188
|
}
|
|
185
189
|
};
|
|
186
190
|
}
|
|
187
|
-
function
|
|
188
|
-
const
|
|
189
|
-
return
|
|
191
|
+
function F(e = {}) {
|
|
192
|
+
const s = process?.env;
|
|
193
|
+
return E({
|
|
190
194
|
name: e.name || "node-server",
|
|
191
|
-
origin:
|
|
195
|
+
origin: s?.ORIGIN ?? s?.URL ?? "https://yoursitename.qwik.dev",
|
|
192
196
|
ssg: e.ssg,
|
|
193
197
|
cleanStaticGenerated: !0,
|
|
194
198
|
config() {
|
|
@@ -205,5 +209,5 @@ function C(e = {}) {
|
|
|
205
209
|
});
|
|
206
210
|
}
|
|
207
211
|
export {
|
|
208
|
-
|
|
212
|
+
F as nodeServerAdapter
|
|
209
213
|
};
|
|
@@ -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:path"),b=require("@qwik.dev/router/middleware/request-handler"),y=require("node:fs");async function D(e,s,t,i,f){t&&!t.endsWith("/")&&(t+="/");const p=new Set([t+"/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/",t+"/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/"]),o=new Set(i.map(P)),h=[],c=async(a,l,u)=>{if(u=P(u),p.has(u))return;const g=w.join(a,l);if(l==="index.html"||l==="q-data.json"){!o.has(u)&&f&&await y.promises.unlink(g);return}if(l==="404.html"){const n=await y.promises.readFile(g,"utf-8");h.push([u,n]);return}const S=await y.promises.stat(g);S.isDirectory()?await m(g,u+l+"/"):S.isFile()&&o.add(u+l)},m=async(a,l)=>{const u=await y.promises.readdir(a);await Promise.all(u.map(g=>c(a,g,l)))};y.existsSync(e)&&await m(e,t);const r=O(t,h),d=T(o);await E(d,r,s)}function P(e){return e.endsWith("/")?e:e+"/"}function O(e,s){if(s.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),!s.some(t=>t[0]===e)){const t=b.getErrorHtml(404,"Resource Not Found");s.push([e,t])}return JSON.stringify(s,null,2).slice(1,-1)}function T(e){return JSON.stringify(Array.from(new Set(e)).sort()).slice(1,-1)}const E=async(e,s,t)=>{const i=new Set,f=async o=>{const h=await y.promises.readFile(o,"utf-8");let c=!1;const m=h.replace(/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,(r,d,a)=>(c=!0,a==="STATIC_PATHS"?e:s));c&&await y.promises.writeFile(o,m)},p=async o=>{const h=await y.promises.readdir(o,{withFileTypes:!0});for(const c of h)if(c.isDirectory())await p(w.join(o,c.name));else if(c.name.endsWith("js")){const m=f(w.join(o,c.name)).finally(()=>{i.delete(m)});i.add(m)}};await p(t),await Promise.all(i)};function R(e){let s=null,t=null,i=null,f=null,p=null,o=!1,h;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(o=!!r.build.ssr,h=r.command,o){if(s=r.plugins.find(d=>d.name==="vite-plugin-qwik-router"),!s)throw new Error("Missing vite-plugin-qwik-router");if(t=r.plugins.find(d=>d.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(o&&e.ssg!==null){const{srcDir:r}=t.api.getOptions();h==="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,d){if(o){c.length=0;for(const a in d){const l=d[a];l.type==="chunk"&&l.isEntry&&(c.push(a),l.name==="entry.ssr"?f=w.join(i,a):l.name==="@qwik-router-config"&&(p=w.join(i,a)))}}},closeBundle:{sequential:!0,async handler(){if(o&&i&&s?.api&&t?.api){const r=e.staticPaths||[],d=s.api.getRoutes(),a=s.api.getBasePathname(),l=t.api.getClientOutDir(),u=t.api.getClientPublicOutDir(),g=t.api.getAssetsDir(),S=t.api.getRootDir()??void 0;if(e.ssg!==null&&f&&p&&l&&u){let n=e.ssg?.origin??e.origin;n||(n="https://yoursite.qwik.dev"),n.length>0&&!/:\/\//.test(n)&&(n=`https://${n}`),n.startsWith("//")&&(n=`https:${n}`);try{n=new URL(n).origin}catch{this.warn(`Invalid "origin" option: "${n}". Using default origin: "https://yoursite.qwik.dev"`),n="https://yoursite.qwik.dev"}const q=await Promise.resolve().then(()=>require("./index-BqUeglYs.cjs")),v={maxWorkers:e.maxWorkers,basePathname:a,outDir:u,rootDir:S,...e.ssg,origin:n,renderModulePath:f,qwikRouterConfigModulePath:p},k=await q.generate(v);if(k.errors>0){const _=new Error(`Error while running SSG from "${e.name}" adapter. At least one path failed to render.`);_.stack=void 0,this.error(_)}r.push(...k.staticPaths)}await D(u,i,g?w.join(a,g):a,r,!!e.cleanStaticGenerated),typeof e.generate=="function"&&await e.generate({outputEntries:c,serverOutDir:i,clientOutDir:l,clientPublicOutDir:u,basePathname:a,routes:d,assetsDir:g,warn:n=>this.warn(n),error:n=>this.error(n)}),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 j(e,s){const t=w.resolve("/");let i=e;for(let f=0;f<20;f++){if(i=w.dirname(i),w.basename(i)===s)return i;if(i===t)break}throw new Error(`Unable to find "${s}" directory from "${e}"`)}exports.getParentDir=j;exports.viteAdapter=R;
|
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
import { join as y, resolve as
|
|
2
|
-
import { getErrorHtml as
|
|
1
|
+
import { join as y, resolve as D, dirname as b, basename as O } from "node:path";
|
|
2
|
+
import { getErrorHtml as E } from "@qwik.dev/router/middleware/request-handler";
|
|
3
3
|
import m from "node:fs";
|
|
4
|
-
async function R(
|
|
5
|
-
|
|
4
|
+
async function R(e, s, t, i, d) {
|
|
5
|
+
t && !t.endsWith("/") && (t += "/");
|
|
6
6
|
const h = /* @__PURE__ */ new Set([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
]), o = new Set(
|
|
7
|
+
t + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
|
|
8
|
+
t + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
|
|
9
|
+
]), o = new Set(i.map(P)), w = [], c = async (a, l, u) => {
|
|
10
10
|
if (u = P(u), h.has(u))
|
|
11
11
|
return;
|
|
12
|
-
const
|
|
12
|
+
const g = y(a, l);
|
|
13
13
|
if (l === "index.html" || l === "q-data.json") {
|
|
14
|
-
!o.has(u) && d && await m.promises.unlink(
|
|
14
|
+
!o.has(u) && d && await m.promises.unlink(g);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
if (l === "404.html") {
|
|
18
|
-
const
|
|
19
|
-
w.push([u,
|
|
18
|
+
const n = await m.promises.readFile(g, "utf-8");
|
|
19
|
+
w.push([u, n]);
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
},
|
|
22
|
+
const k = await m.promises.stat(g);
|
|
23
|
+
k.isDirectory() ? await p(g, u + l + "/") : k.isFile() && o.add(u + l);
|
|
24
|
+
}, p = async (a, l) => {
|
|
25
25
|
const u = await m.promises.readdir(a);
|
|
26
|
-
await Promise.all(u.map((
|
|
26
|
+
await Promise.all(u.map((g) => c(a, g, l)));
|
|
27
27
|
};
|
|
28
|
-
m.existsSync(
|
|
29
|
-
const
|
|
30
|
-
await
|
|
28
|
+
m.existsSync(e) && await p(e, t);
|
|
29
|
+
const r = T(t, w), f = A(o);
|
|
30
|
+
await C(f, r, s);
|
|
31
31
|
}
|
|
32
|
-
function P(
|
|
33
|
-
return
|
|
32
|
+
function P(e) {
|
|
33
|
+
return e.endsWith("/") ? e : e + "/";
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
if (s.sort((
|
|
37
|
-
const
|
|
38
|
-
s.push([
|
|
35
|
+
function T(e, s) {
|
|
36
|
+
if (s.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), !s.some((t) => t[0] === e)) {
|
|
37
|
+
const t = E(404, "Resource Not Found");
|
|
38
|
+
s.push([e, t]);
|
|
39
39
|
}
|
|
40
40
|
return JSON.stringify(s, null, 2).slice(1, -1);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return JSON.stringify(Array.from(new Set(
|
|
42
|
+
function A(e) {
|
|
43
|
+
return JSON.stringify(Array.from(new Set(e)).sort()).slice(1, -1);
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
const
|
|
45
|
+
const C = async (e, s, t) => {
|
|
46
|
+
const i = /* @__PURE__ */ new Set(), d = async (o) => {
|
|
47
47
|
const w = await m.promises.readFile(o, "utf-8");
|
|
48
|
-
let
|
|
49
|
-
const
|
|
48
|
+
let c = !1;
|
|
49
|
+
const p = w.replace(
|
|
50
50
|
/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,
|
|
51
|
-
(
|
|
51
|
+
(r, f, a) => (c = !0, a === "STATIC_PATHS" ? e : s)
|
|
52
52
|
);
|
|
53
|
-
|
|
53
|
+
c && await m.promises.writeFile(o, p);
|
|
54
54
|
}, h = async (o) => {
|
|
55
55
|
const w = await m.promises.readdir(o, { withFileTypes: !0 });
|
|
56
|
-
for (const
|
|
57
|
-
if (
|
|
58
|
-
await h(y(o,
|
|
59
|
-
else if (
|
|
60
|
-
const
|
|
61
|
-
|
|
56
|
+
for (const c of w)
|
|
57
|
+
if (c.isDirectory())
|
|
58
|
+
await h(y(o, c.name));
|
|
59
|
+
else if (c.name.endsWith("js")) {
|
|
60
|
+
const p = d(y(o, c.name)).finally(() => {
|
|
61
|
+
i.delete(p);
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
i.add(p);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
await h(
|
|
66
|
+
await h(t), await Promise.all(i);
|
|
67
67
|
};
|
|
68
|
-
function
|
|
69
|
-
let s = null,
|
|
70
|
-
const
|
|
68
|
+
function W(e) {
|
|
69
|
+
let s = null, t = null, i = null, d = null, h = null, o = !1, w;
|
|
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
|
-
config(
|
|
76
|
-
return typeof
|
|
75
|
+
config(r) {
|
|
76
|
+
return typeof e.config == "function" && (r = e.config(r)), r.define = {
|
|
77
77
|
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
78
|
-
...
|
|
79
|
-
},
|
|
78
|
+
...r.define
|
|
79
|
+
}, r;
|
|
80
80
|
},
|
|
81
|
-
configResolved(
|
|
82
|
-
if (o = !!
|
|
83
|
-
if (s =
|
|
81
|
+
configResolved(r) {
|
|
82
|
+
if (o = !!r.build.ssr, w = r.command, o) {
|
|
83
|
+
if (s = r.plugins.find(
|
|
84
84
|
(f) => f.name === "vite-plugin-qwik-router"
|
|
85
85
|
), !s)
|
|
86
86
|
throw new Error("Missing vite-plugin-qwik-router");
|
|
87
|
-
if (
|
|
87
|
+
if (t = r.plugins.find(
|
|
88
88
|
(f) => f.name === "vite-plugin-qwik"
|
|
89
|
-
), !
|
|
89
|
+
), !t)
|
|
90
90
|
throw new Error("Missing vite-plugin-qwik");
|
|
91
|
-
if (
|
|
91
|
+
if (i = r.build.outDir, r.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
|
-
if (!
|
|
95
|
+
if (!r.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 (o &&
|
|
103
|
-
const { srcDir:
|
|
104
|
-
this.emitFile({
|
|
102
|
+
if (o && e.ssg !== null) {
|
|
103
|
+
const { srcDir: r } = t.api.getOptions();
|
|
104
|
+
w === "build" && i && r && (this.emitFile({
|
|
105
105
|
id: "@qwik-router-config",
|
|
106
106
|
type: "chunk",
|
|
107
107
|
fileName: "@qwik-router-config.js"
|
|
108
108
|
}), this.emitFile({
|
|
109
|
-
id: `${
|
|
109
|
+
id: `${r}/entry.ssr`,
|
|
110
110
|
type: "chunk",
|
|
111
111
|
fileName: "entry.ssr.js"
|
|
112
|
-
});
|
|
112
|
+
}));
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
|
-
generateBundle(
|
|
115
|
+
generateBundle(r, f) {
|
|
116
116
|
if (o) {
|
|
117
|
-
|
|
118
|
-
for (const
|
|
119
|
-
const
|
|
120
|
-
|
|
117
|
+
c.length = 0;
|
|
118
|
+
for (const a in f) {
|
|
119
|
+
const l = f[a];
|
|
120
|
+
l.type === "chunk" && l.isEntry && (c.push(a), l.name === "entry.ssr" ? d = y(i, a) : l.name === "@qwik-router-config" && (h = y(i, a)));
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
124
|
closeBundle: {
|
|
125
125
|
sequential: !0,
|
|
126
126
|
async handler() {
|
|
127
|
-
if (o &&
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
let n =
|
|
127
|
+
if (o && i && s?.api && t?.api) {
|
|
128
|
+
const r = e.staticPaths || [], f = s.api.getRoutes(), a = s.api.getBasePathname(), l = t.api.getClientOutDir(), u = t.api.getClientPublicOutDir(), g = t.api.getAssetsDir(), k = t.api.getRootDir() ?? void 0;
|
|
129
|
+
if (e.ssg !== null && d && h && l && u) {
|
|
130
|
+
let n = e.ssg?.origin ?? e.origin;
|
|
131
131
|
n || (n = "https://yoursite.qwik.dev"), n.length > 0 && !/:\/\//.test(n) && (n = `https://${n}`), n.startsWith("//") && (n = `https:${n}`);
|
|
132
132
|
try {
|
|
133
133
|
n = new URL(n).origin;
|
|
@@ -136,38 +136,38 @@ function $(t) {
|
|
|
136
136
|
`Invalid "origin" option: "${n}". Using default origin: "https://yoursite.qwik.dev"`
|
|
137
137
|
), n = "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: a,
|
|
142
|
+
outDir: u,
|
|
143
|
+
rootDir: k,
|
|
144
|
+
...e.ssg,
|
|
145
145
|
origin: n,
|
|
146
146
|
renderModulePath: d,
|
|
147
147
|
qwikRouterConfigModulePath: h
|
|
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
|
-
|
|
155
|
+
r.push(...S.staticPaths);
|
|
156
156
|
}
|
|
157
157
|
await R(
|
|
158
|
-
|
|
159
|
-
r,
|
|
160
|
-
u ? y(c, u) : c,
|
|
158
|
+
u,
|
|
161
159
|
i,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
160
|
+
g ? y(a, g) : a,
|
|
161
|
+
r,
|
|
162
|
+
!!e.cleanStaticGenerated
|
|
163
|
+
), typeof e.generate == "function" && await e.generate({
|
|
164
|
+
outputEntries: c,
|
|
165
|
+
serverOutDir: i,
|
|
166
|
+
clientOutDir: l,
|
|
167
|
+
clientPublicOutDir: u,
|
|
168
|
+
basePathname: a,
|
|
169
169
|
routes: f,
|
|
170
|
-
assetsDir:
|
|
170
|
+
assetsDir: g,
|
|
171
171
|
warn: (n) => this.warn(n),
|
|
172
172
|
error: (n) => this.error(n)
|
|
173
173
|
}), this.warn(
|
|
@@ -176,7 +176,11 @@ function $(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
|
-
const
|
|
189
|
-
let
|
|
191
|
+
function x(e, s) {
|
|
192
|
+
const t = D("/");
|
|
193
|
+
let i = e;
|
|
190
194
|
for (let d = 0; d < 20; d++) {
|
|
191
|
-
if (
|
|
192
|
-
return
|
|
193
|
-
if (
|
|
195
|
+
if (i = b(i), O(i) === s)
|
|
196
|
+
return i;
|
|
197
|
+
if (i === t)
|
|
194
198
|
break;
|
|
195
199
|
}
|
|
196
|
-
throw new Error(`Unable to find "${s}" directory from "${
|
|
200
|
+
throw new Error(`Unable to find "${s}" directory from "${e}"`);
|
|
197
201
|
}
|
|
198
202
|
export {
|
|
199
|
-
|
|
200
|
-
|
|
203
|
+
x as getParentDir,
|
|
204
|
+
W as viteAdapter
|
|
201
205
|
};
|