@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
|
@@ -2,7 +2,7 @@ import E from "node:fs";
|
|
|
2
2
|
import { isAbsolute as N, resolve as te, join as L, dirname as re, relative as ne } from "node:path";
|
|
3
3
|
import { cpus as se } from "node:os";
|
|
4
4
|
import { Worker as oe, parentPort as A, isMainThread as V, workerData as j } from "node:worker_threads";
|
|
5
|
-
import { n as D } from "./index-
|
|
5
|
+
import { n as D } from "./index-CHT9Y93A.js";
|
|
6
6
|
import { _serialize as ie } from "@qwik.dev/core/internal";
|
|
7
7
|
import { RequestEvShareQData as ae, requestHandler as ce, getErrorHtml as le } from "@qwik.dev/router/middleware/request-handler";
|
|
8
8
|
import { WritableStream as ue } from "node:stream/web";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";const f=require("node:fs"),g=require("node:path"),b=require("@qwik.dev/router/middleware/request-handler");function j(e){return v(g.normalize(e))}function v(e){const n=/^\\\\\?\\/.test(e),t=/[^\u0000-\u0080]+/.test(e);return n||t||(e=e.replace(/\\/g,"/"),e.endsWith("/")&&(e=e.slice(0,e.length-1))),e}async function E(e,n,t,r,h){t&&!t.endsWith("/")&&(t+="/");const w=new Set([t+"/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/",t+"/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/"]),o=new Set(r.map(_)),p=[],a=async(l,u,c)=>{if(c=_(c),w.has(c))return;const m=g.join(l,u);if(u==="index.html"||u==="q-data.json"){!o.has(c)&&h&&await f.promises.unlink(m);return}if(u==="404.html"){const s=await f.promises.readFile(m,"utf-8");p.push([c,s]);return}const k=await f.promises.stat(m);k.isDirectory()?await y(m,c+u+"/"):k.isFile()&&o.add(c+u)},y=async(l,u)=>{const c=await f.promises.readdir(l);await Promise.all(c.map(m=>a(l,m,u)))};f.existsSync(e)&&await y(e,t);const i=O(t,p),d=D(o);await T(d,i,n)}function _(e){return e.endsWith("/")?e:e+"/"}function O(e,n){if(n.sort((t,r)=>t[0].length>r[0].length?-1:t[0].length<r[0].length?1:t[0]<r[0]?-1:t[0]>r[0]?1:0),!n.some(t=>t[0]===e)){const t=b.getErrorHtml(404,"Resource Not Found");n.push([e,t])}return JSON.stringify(n,null,2).slice(1,-1)}function D(e){return JSON.stringify(Array.from(new Set(e)).sort()).slice(1,-1)}const T=async(e,n,t)=>{const r=new Set,h=async o=>{const p=await f.promises.readFile(o,"utf-8");let a=!1;const y=p.replace(/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,(i,d,l)=>(a=!0,l==="STATIC_PATHS"?e:n));a&&await f.promises.writeFile(o,y)},w=async o=>{const p=await f.promises.readdir(o,{withFileTypes:!0});for(const a of p)if(a.isDirectory())await w(g.join(o,a.name));else if(a.name.endsWith("js")){const y=h(g.join(o,a.name)).finally(()=>{r.delete(y)});r.add(y)}};await w(t),await Promise.all(r)};function A(e){let n=null,t=null,r=null,h=null,w=null,o=!1,p;const a=[];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(o=!!i.build.ssr,p=i.command,o){if(n=i.plugins.find(d=>d.name==="vite-plugin-qwik-router"),!n)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(r=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(o&&e.ssg!==null){const{srcDir:i}=t.api.getOptions();p==="build"&&r&&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(o){a.length=0;for(const l in d){const u=d[l];u.type==="chunk"&&u.isEntry&&(a.push(l),u.name==="entry.ssr"?h=g.join(r,l):u.name==="@qwik-router-config"&&(w=g.join(r,l)))}}},closeBundle:{sequential:!0,async handler(){if(o&&r&&n?.api&&t?.api){const i=e.staticPaths||[],d=n.api.getRoutes(),l=n.api.getBasePathname(),u=t.api.getClientOutDir(),c=t.api.getClientPublicOutDir(),m=t.api.getAssetsDir(),k=t.api.getRootDir()??void 0;if(e.ssg!==null&&h&&w&&u&&c){let s=e.ssg?.origin??e.origin;s||(s="https://yoursite.qwik.dev"),s.length>0&&!/:\/\//.test(s)&&(s=`https://${s}`),s.startsWith("//")&&(s=`https:${s}`);try{s=new URL(s).origin}catch{this.warn(`Invalid "origin" option: "${s}". Using default origin: "https://yoursite.qwik.dev"`),s="https://yoursite.qwik.dev"}const q=await Promise.resolve().then(()=>require("./index-C1aDmh1S.cjs")),R={maxWorkers:e.maxWorkers,basePathname:l,outDir:c,rootDir:k,...e.ssg,origin:s,renderModulePath:h,qwikRouterConfigModulePath:w},P=await q.generate(R);if(P.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)}i.push(...P.staticPaths)}await E(c,r,m?g.join(l,m):l,i,!!e.cleanStaticGenerated),typeof e.generate=="function"&&await e.generate({outputEntries:a,serverOutDir:r,clientOutDir:u,clientPublicOutDir:c,basePathname:l,routes:d,assetsDir:m,warn:s=>this.warn(s),error:s=>this.error(s)}),this.warn(`
|
|
2
|
+
==============================================
|
|
3
|
+
Note: Make sure that you are serving the built files with proper cache headers.
|
|
4
|
+
See https://qwik.dev/docs/deployments/#cache-headers for more information.
|
|
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 x(e={}){const n=process?.env;return A({name:"cloudflare-pages",origin:n?.CF_PAGES_URL??n?.ORIGIN??"https://your.cloudflare.pages.dev",ssg:e.ssg,staticPaths:e.staticPaths,cleanStaticGenerated:!0,config(){return{resolve:{conditions:["webworker","worker"]},ssr:{target:"webworker",noExternal:!0,external:["node:async_hooks"]},build:{ssr:!0,rollupOptions:{output:{format:"es",hoistTransitiveImports:!1}}},publicDir:!1}},async generate({clientOutDir:t,serverOutDir:r,basePathname:h,assetsDir:w}){const o=g.join(t,"_routes.json");if(!f.existsSync(o)&&e.functionRoutes!==!1){let i=w?g.join(h,w):h;i.endsWith("/")||(i+="/");const d={version:1,include:[h+"*"],exclude:[i+"build/*",i+"assets/*"]};await f.promises.writeFile(o,JSON.stringify(d,void 0,2))}const a=g.join(t,"_worker.js");if(!f.existsSync(a)){const i=g.relative(t,g.join(r,"entry.cloudflare-pages"));await f.promises.writeFile(a,`import { fetch } from "${v(i)}"; export default { fetch };`)}}})}exports.cloudflarePagesAdapter=x;exports.normalizePath=j;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("node:fs");require("node:path");const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("node:fs");require("node:path");const e=require("./index-D9RL9dvJ.cjs");exports.cloudflarePagesAdapter=e.cloudflarePagesAdapter;
|
|
@@ -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"),b=require("@qwik.dev/router/middleware/request-handler"),p=require("node:fs");async function D(e,s,t,n,m){t&&!t.endsWith("/")&&(t+="/");const w=new Set([t+"/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/",t+"/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/"]),o=new Set(n.map(_)),g=[],c=async(a,l,u)=>{if(u=_(u),w.has(u))return;const f=y.join(a,l);if(l==="index.html"||l==="q-data.json"){!o.has(u)&&m&&await p.promises.unlink(f);return}if(l==="404.html"){const r=await p.promises.readFile(f,"utf-8");g.push([u,r]);return}const k=await p.promises.stat(f);k.isDirectory()?await h(f,u+l+"/"):k.isFile()&&o.add(u+l)},h=async(a,l)=>{const u=await p.promises.readdir(a);await Promise.all(u.map(f=>c(a,f,l)))};p.existsSync(e)&&await h(e,t);const i=O(t,g),d=R(o);await T(d,i,s)}function _(e){return e.endsWith("/")?e:e+"/"}function O(e,s){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)){const t=b.getErrorHtml(404,"Resource Not Found");s.push([e,t])}return JSON.stringify(s,null,2).slice(1,-1)}function R(e){return JSON.stringify(Array.from(new Set(e)).sort()).slice(1,-1)}const T=async(e,s,t)=>{const n=new Set,m=async o=>{const g=await p.promises.readFile(o,"utf-8");let c=!1;const h=g.replace(/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,(i,d,a)=>(c=!0,a==="STATIC_PATHS"?e:s));c&&await p.promises.writeFile(o,h)},w=async o=>{const g=await p.promises.readdir(o,{withFileTypes:!0});for(const c of g)if(c.isDirectory())await w(y.join(o,c.name));else if(c.name.endsWith("js")){const h=m(y.join(o,c.name)).finally(()=>{n.delete(h)});n.add(h)}};await w(t),await Promise.all(n)};function E(e){let s=null,t=null,n=null,m=null,w=null,o=!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(o=!!i.build.ssr,g=i.command,o){if(s=i.plugins.find(d=>d.name==="vite-plugin-qwik-router"),!s)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(o&&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(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"?m=y.join(n,a):l.name==="@qwik-router-config"&&(w=y.join(n,a)))}}},closeBundle:{sequential:!0,async handler(){if(o&&n&&s?.api&&t?.api){const i=e.staticPaths||[],d=s.api.getRoutes(),a=s.api.getBasePathname(),l=t.api.getClientOutDir(),u=t.api.getClientPublicOutDir(),f=t.api.getAssetsDir(),k=t.api.getRootDir()??void 0;if(e.ssg!==null&&m&&w&&l&&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 q=await Promise.resolve().then(()=>require("./index-BqUeglYs.cjs")),P={maxWorkers:e.maxWorkers,basePathname:a,outDir:u,rootDir:k,...e.ssg,origin:r,renderModulePath:m,qwikRouterConfigModulePath:w},S=await q.generate(P);if(S.errors>0){const v=new Error(`Error while running SSG from "${e.name}" adapter. At least one path failed to render.`);v.stack=void 0,this.error(v)}i.push(...S.staticPaths)}await D(u,n,f?y.join(a,f):a,i,!!e.cleanStaticGenerated),typeof e.generate=="function"&&await e.generate({outputEntries:c,serverOutDir:n,clientOutDir:l,clientPublicOutDir:u,basePathname:a,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
|
|
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 A(e={}){const s=process?.env;return E({name:e.name||"deno-server",origin:s?.ORIGIN??s?.URL??"https://yoursitename.qwik.dev",ssg:e.ssg,cleanStaticGenerated:!0,config(){return{resolve:{conditions:["webworker","worker"]},ssr:{target:"webworker",noExternal:!0,external:["node:async_hooks"]},build:{ssr:!0,target:"esnext",rollupOptions:{output:{format:"es",hoistTransitiveImports:!1}}},publicDir:!1}}})}exports.denoServerAdapter=A;
|
|
@@ -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 b(e, s, t, n, m) {
|
|
5
5
|
t && !t.endsWith("/") && (t += "/");
|
|
6
|
-
const
|
|
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(
|
|
10
|
-
if (u = v(u),
|
|
9
|
+
]), o = new Set(n.map(v)), g = [], c = async (a, l, u) => {
|
|
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 k = await p.promises.stat(f);
|
|
23
|
+
k.isDirectory() ? await h(f, u + l + "/") : k.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 = O(t, g), d = R(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 O(e,
|
|
36
|
-
if (
|
|
37
|
-
const t =
|
|
38
|
-
|
|
35
|
+
function O(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
42
|
function R(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
|
-
|
|
54
|
-
},
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
if (
|
|
58
|
-
await
|
|
59
|
-
else if (
|
|
60
|
-
const
|
|
61
|
-
|
|
53
|
+
c && await p.promises.writeFile(o, h);
|
|
54
|
+
}, w = async (o) => {
|
|
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
|
|
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 &&
|
|
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(), k = 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: k,
|
|
144
144
|
...e.ssg,
|
|
145
145
|
origin: r,
|
|
146
146
|
renderModulePath: m,
|
|
147
|
-
qwikRouterConfigModulePath:
|
|
148
|
-
},
|
|
149
|
-
if (
|
|
150
|
-
const
|
|
147
|
+
qwikRouterConfigModulePath: w
|
|
148
|
+
}, S = await P.generate(q);
|
|
149
|
+
if (S.errors > 0) {
|
|
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(...S.staticPaths);
|
|
156
156
|
}
|
|
157
|
-
await
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
await b(
|
|
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
|
}
|
|
@@ -185,10 +189,10 @@ See https://qwik.dev/docs/deployments/#cache-headers for more information.
|
|
|
185
189
|
};
|
|
186
190
|
}
|
|
187
191
|
function C(e = {}) {
|
|
188
|
-
const
|
|
189
|
-
return
|
|
192
|
+
const s = process?.env;
|
|
193
|
+
return E({
|
|
190
194
|
name: e.name || "deno-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() {
|
|
@@ -1,6 +1,6 @@
|
|
|
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"),j=require("@qwik.dev/router/middleware/request-handler");async function q(e,r,t,i,u){t&&!t.endsWith("/")&&(t+="/");const y=new Set([t+"/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/",t+"/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/"]),o=new Set(i.map(_)),g=[],c=async(a,l,f)=>{if(f=_(f),y.has(f))return;const p=d.join(a,l);if(l==="index.html"||l==="q-data.json"){!o.has(f)&&u&&await w.promises.unlink(p);return}if(l==="404.html"){const s=await w.promises.readFile(p,"utf-8");g.push([f,s]);return}const P=await w.promises.stat(p);P.isDirectory()?await m(p,f+l+"/"):P.isFile()&&o.add(f+l)},m=async(a,l)=>{const f=await w.promises.readdir(a);await Promise.all(f.map(p=>c(a,p,l)))};w.existsSync(e)&&await m(e,t);const n=E(t,g),h=D(o);await x(h,n,r)}function _(e){return e.endsWith("/")?e:e+"/"}function E(e,r){if(r.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),!r.some(t=>t[0]===e)){const t=j.getErrorHtml(404,"Resource Not Found");r.push([e,t])}return JSON.stringify(r,null,2).slice(1,-1)}function D(e){return JSON.stringify(Array.from(new Set(e)).sort()).slice(1,-1)}const x=async(e,r,t)=>{const i=new Set,u=async o=>{const g=await w.promises.readFile(o,"utf-8");let c=!1;const m=g.replace(/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,(n,h,a)=>(c=!0,a==="STATIC_PATHS"?e:r));c&&await w.promises.writeFile(o,m)},y=async o=>{const g=await w.promises.readdir(o,{withFileTypes:!0});for(const c of g)if(c.isDirectory())await y(d.join(o,c.name));else if(c.name.endsWith("js")){const m=u(d.join(o,c.name)).finally(()=>{i.delete(m)});i.add(m)}};await y(t),await Promise.all(i)};function O(e){let r=null,t=null,i=null,u=null,y=null,o=!1,g;const c=[];return{name:`vite-plugin-qwik-router-ssg-${e.name}`,enforce:"post",apply:"build",config(n){return typeof e.config=="function"&&(n=e.config(n)),n.define={"process.env.NODE_ENV":JSON.stringify("production"),...n.define},n},configResolved(n){if(o=!!n.build.ssr,g=n.command,o){if(r=n.plugins.find(h=>h.name==="vite-plugin-qwik-router"),!r)throw new Error("Missing vite-plugin-qwik-router");if(t=n.plugins.find(h=>h.name==="vite-plugin-qwik"),!t)throw new Error("Missing vite-plugin-qwik");if(i=n.build.outDir,n.build?.ssr!==!0)throw new Error(`"build.ssr" must be set to "true" in order to use the "${e.name}" adapter.`);if(!n.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:n}=t.api.getOptions();g==="build"&&i&&n&&(this.emitFile({id:"@qwik-router-config",type:"chunk",fileName:"@qwik-router-config.js"}),this.emitFile({id:`${n}/entry.ssr`,type:"chunk",fileName:"entry.ssr.js"}))}},generateBundle(n,h){if(o){c.length=0;for(const a in h){const l=h[a];l.type==="chunk"&&l.isEntry&&(c.push(a),l.name==="entry.ssr"?u=d.join(i,a):l.name==="@qwik-router-config"&&(y=d.join(i,a)))}}},closeBundle:{sequential:!0,async handler(){if(o&&i&&r?.api&&t?.api){const n=e.staticPaths||[],h=r.api.getRoutes(),a=r.api.getBasePathname(),l=t.api.getClientOutDir(),f=t.api.getClientPublicOutDir(),p=t.api.getAssetsDir(),P=t.api.getRootDir()??void 0;if(e.ssg!==null&&u&&y&&l&&f){let s=e.ssg?.origin??e.origin;s||(s="https://yoursite.qwik.dev"),s.length>0&&!/:\/\//.test(s)&&(s=`https://${s}`),s.startsWith("//")&&(s=`https:${s}`);try{s=new URL(s).origin}catch{this.warn(`Invalid "origin" option: "${s}". Using default origin: "https://yoursite.qwik.dev"`),s="https://yoursite.qwik.dev"}const v=await Promise.resolve().then(()=>require("./index-BqUeglYs.cjs")),b={maxWorkers:e.maxWorkers,basePathname:a,outDir:f,rootDir:P,...e.ssg,origin:s,renderModulePath:u,qwikRouterConfigModulePath:y},k=await v.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)}n.push(...k.staticPaths)}await q(f,i,p?d.join(a,p):a,n,!!e.cleanStaticGenerated),typeof e.generate=="function"&&await e.generate({outputEntries:c,serverOutDir:i,clientOutDir:l,clientPublicOutDir:f,basePathname:a,routes:h,assetsDir:p,warn:s=>this.warn(s),error:s=>this.error(s)}),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 R(e,
|
|
6
|
-
`));const
|
|
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,r){const t=d.resolve("/");let i=e;for(let u=0;u<20;u++){if(i=d.dirname(i),d.basename(i)===r)return i;if(i===t)break}throw new Error(`Unable to find "${r}" directory from "${e}"`)}function T(e={}){const r=process?.env;return O({name:"netlify-edge",origin:r?.ORIGIN??r?.URL??"https://yoursitename.netlify.app",ssg:e.ssg,staticPaths:e.staticPaths,cleanStaticGenerated:!0,config(t){const i=t.build?.outDir||".netlify/edge-functions/entry.netlify-edge";return{resolve:{conditions:["webworker","worker"]},ssr:{target:"webworker",noExternal:!0,external:["node:async_hooks"]},build:{ssr:!0,outDir:i,rollupOptions:{output:{format:"es",hoistTransitiveImports:!1}}},publicDir:!1}},async generate({serverOutDir:t,basePathname:i}){if(e.functionRoutes!==!1){const u=[];typeof e.excludedPath=="string"?u.push(e.excludedPath):Array.isArray(e.excludedPath)?u.push(...e.excludedPath):u.push("/build/*","/favicon.ico","/robots.txt","/mainifest.json","/~partytown/*","/service-worker.js","/sitemap.xml");const y={functions:[{path:i+"*",function:"entry.netlify-edge",cache:"manual",excludedPath:u}],version:1},o=d.join(t,"entry.netlify-edge.js"),g=d.join(t,"entry.netlify-edge.mjs");w.existsSync(g)&&await w.promises.writeFile(o,["import entry_netlifyEdge from './entry.netlify-edge.mjs';","export default entry_netlifyEdge;"].join(`
|
|
6
|
+
`));const c=R(t,"edge-functions");await w.promises.writeFile(d.join(c,"manifest.json"),JSON.stringify(y,null,2))}}})}exports.netlifyEdgeAdapter=T;
|