@qwik.dev/router 2.0.0-beta.5 → 2.0.0-beta.7
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/adapters/static/vite.d.ts +1 -1
- package/lib/adapters/azure-swa/vite/index.d.ts +2 -2
- package/lib/adapters/bun-server/vite/index.d.ts +2 -2
- package/lib/adapters/cloud-run/vite/index.d.ts +2 -2
- package/lib/adapters/cloudflare-pages/vite/index.d.ts +2 -2
- package/lib/adapters/deno-server/vite/index.d.ts +2 -2
- package/lib/adapters/netlify-edge/vite/index.cjs +1 -0
- package/lib/adapters/netlify-edge/vite/index.d.ts +2 -2
- package/lib/adapters/netlify-edge/vite/index.mjs +1 -0
- package/lib/adapters/node-server/vite/index.d.ts +2 -2
- package/lib/adapters/shared/vite/index.cjs +88 -128
- package/lib/adapters/shared/vite/index.d.ts +9 -15
- package/lib/adapters/shared/vite/index.mjs +88 -124
- package/lib/adapters/{static → ssg}/vite/index.cjs +95 -124
- package/lib/adapters/ssg/vite/index.d.ts +13 -0
- package/lib/adapters/{static → ssg}/vite/index.mjs +93 -123
- package/lib/adapters/vercel-edge/vite/index.d.ts +2 -2
- package/lib/index.d.ts +161 -48
- package/lib/index.qwik.cjs +86 -23
- package/lib/index.qwik.mjs +88 -25
- package/lib/middleware/aws-lambda/index.d.ts +3 -2
- package/lib/middleware/aws-lambda/index.mjs +2 -4
- package/lib/middleware/azure-swa/index.mjs +6 -6
- package/lib/middleware/bun/index.mjs +4 -6
- package/lib/middleware/cloudflare-pages/index.mjs +4 -6
- package/lib/middleware/deno/index.mjs +8 -7
- package/lib/middleware/firebase/index.mjs +1 -3
- package/lib/middleware/netlify-edge/index.mjs +7 -6
- package/lib/middleware/node/index.cjs +4 -8
- package/lib/middleware/node/index.mjs +7 -7
- package/lib/middleware/request-handler/index.cjs +331 -268
- package/lib/middleware/request-handler/index.d.ts +56 -49
- package/lib/middleware/request-handler/index.mjs +335 -264
- package/lib/middleware/vercel-edge/index.mjs +7 -6
- package/lib/modules.d.ts +4 -12
- package/lib/{static → ssg}/deno.mjs +1 -1
- package/lib/{static → ssg}/index.cjs +1 -1
- package/lib/{static → ssg}/index.d.ts +17 -17
- package/lib/{static → ssg}/index.mjs +1 -1
- package/lib/{static → ssg}/node.cjs +16 -16
- package/lib/{static → ssg}/node.mjs +15 -15
- package/lib/vite/index.cjs +10260 -10437
- package/lib/vite/index.mjs +8220 -8387
- package/modules.d.ts +4 -12
- package/package.json +19 -8
- package/ssg.d.ts +2 -0
- package/static.d.ts +1 -1
- package/lib/adapters/static/vite/index.d.ts +0 -10
- package/middleware/request-handler/generated/not-found-paths.ts +0 -7
- package/middleware/request-handler/generated/static-paths.ts +0 -35
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// re-export for typescript in old resolution mode
|
|
2
|
-
export * from '../../lib/adapters/
|
|
2
|
+
export * from '../../lib/adapters/ssg/vite';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SsgRenderOptions } from 'packages/qwik-router/src/ssg';
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
5
|
export declare function azureSwaAdapter(opts?: AzureSwaAdapterOptions): any;
|
|
@@ -8,6 +8,6 @@ export declare function azureSwaAdapter(opts?: AzureSwaAdapterOptions): any;
|
|
|
8
8
|
export declare interface AzureSwaAdapterOptions extends ServerAdapterOptions {
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export {
|
|
11
|
+
export { SsgRenderOptions }
|
|
12
12
|
|
|
13
13
|
export { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SsgRenderOptions } from 'packages/qwik-router/src/ssg';
|
|
3
3
|
|
|
4
4
|
/** @beta */
|
|
5
5
|
export declare function bunServerAdapter(opts?: bunServerAdapterOptions): any;
|
|
@@ -9,6 +9,6 @@ export declare interface bunServerAdapterOptions extends ServerAdapterOptions {
|
|
|
9
9
|
name?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export { SsgRenderOptions }
|
|
13
13
|
|
|
14
14
|
export { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SsgRenderOptions } from 'packages/qwik-router/src/ssg';
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
5
|
export declare function cloudRunAdapter(opts?: CloudRunAdapterOptions): any;
|
|
@@ -8,6 +8,6 @@ export declare function cloudRunAdapter(opts?: CloudRunAdapterOptions): any;
|
|
|
8
8
|
export declare interface CloudRunAdapterOptions extends ServerAdapterOptions {
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export {
|
|
11
|
+
export { SsgRenderOptions }
|
|
12
12
|
|
|
13
13
|
export { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SsgRenderOptions } from 'packages/qwik-router/src/ssg';
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
5
|
export declare function cloudflarePagesAdapter(opts?: CloudflarePagesAdapterOptions): any;
|
|
@@ -22,6 +22,6 @@ export declare interface CloudflarePagesAdapterOptions extends ServerAdapterOpti
|
|
|
22
22
|
staticPaths?: string[];
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export {
|
|
25
|
+
export { SsgRenderOptions }
|
|
26
26
|
|
|
27
27
|
export { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SsgRenderOptions } from 'packages/qwik-router/src/ssg';
|
|
3
3
|
|
|
4
4
|
/** @beta */
|
|
5
5
|
export declare function denoServerAdapter(opts?: DenoServerAdapterOptions): any;
|
|
@@ -9,6 +9,6 @@ export declare interface DenoServerAdapterOptions extends ServerAdapterOptions {
|
|
|
9
9
|
name?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export { SsgRenderOptions }
|
|
13
13
|
|
|
14
14
|
export { }
|
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// packages/qwik-router/src/runtime/src/qwik-router-config.ts
|
|
38
|
+
var trailingSlash = !globalThis.__NO_TRAILING_SLASH__;
|
|
38
39
|
var basePathname = "/";
|
|
39
40
|
|
|
40
41
|
// packages/qwik-router/src/adapters/netlify-edge/vite/index.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SsgRenderOptions } from 'packages/qwik-router/src/ssg';
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
5
|
export declare function netlifyEdgeAdapter(opts?: NetlifyEdgeAdapterOptions): any;
|
|
@@ -39,6 +39,6 @@ export declare interface NetlifyEdgeAdapterOptions extends ServerAdapterOptions
|
|
|
39
39
|
excludedPath?: string | string[];
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export {
|
|
42
|
+
export { SsgRenderOptions }
|
|
43
43
|
|
|
44
44
|
export { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SsgRenderOptions } from 'packages/qwik-router/src/ssg';
|
|
3
3
|
|
|
4
4
|
/** @beta */
|
|
5
5
|
export declare function nodeServerAdapter(opts?: NodeServerAdapterOptions): any;
|
|
@@ -9,6 +9,6 @@ export declare interface NodeServerAdapterOptions extends ServerAdapterOptions {
|
|
|
9
9
|
name?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export { SsgRenderOptions }
|
|
13
13
|
|
|
14
14
|
export { }
|
|
@@ -30,26 +30,24 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// packages/qwik-router/src/adapters/shared/vite/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
NOT_FOUND_PATHS_ID: () => NOT_FOUND_PATHS_ID,
|
|
34
|
-
RESOLVED_NOT_FOUND_PATHS_ID: () => RESOLVED_NOT_FOUND_PATHS_ID,
|
|
35
|
-
RESOLVED_STATIC_PATHS_ID: () => RESOLVED_STATIC_PATHS_ID,
|
|
36
|
-
STATIC_PATHS_ID: () => STATIC_PATHS_ID,
|
|
37
33
|
getParentDir: () => getParentDir,
|
|
38
34
|
viteAdapter: () => viteAdapter
|
|
39
35
|
});
|
|
40
36
|
module.exports = __toCommonJS(index_exports);
|
|
41
|
-
var import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
42
37
|
var import_node_path2 = require("node:path");
|
|
43
38
|
|
|
44
39
|
// packages/qwik-router/src/adapters/shared/vite/post-build.ts
|
|
45
40
|
var import_request_handler = require("../../../middleware/request-handler/index.cjs");
|
|
46
41
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
47
42
|
var import_node_path = require("node:path");
|
|
48
|
-
async function postBuild(clientOutDir, pathName, userStaticPaths,
|
|
43
|
+
async function postBuild(clientOutDir, serverOutDir, pathName, userStaticPaths, cleanStatic) {
|
|
49
44
|
if (pathName && !pathName.endsWith("/")) {
|
|
50
45
|
pathName += "/";
|
|
51
46
|
}
|
|
52
|
-
const ignorePathnames = /* @__PURE__ */ new Set([
|
|
47
|
+
const ignorePathnames = /* @__PURE__ */ new Set([
|
|
48
|
+
pathName + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
|
|
49
|
+
pathName + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
|
|
50
|
+
]);
|
|
53
51
|
const staticPaths = new Set(userStaticPaths.map(normalizeTrailingSlash));
|
|
54
52
|
const notFounds = [];
|
|
55
53
|
const loadItem = async (fsDir, fsName, pathname) => {
|
|
@@ -83,12 +81,9 @@ async function postBuild(clientOutDir, pathName, userStaticPaths, format, cleanS
|
|
|
83
81
|
if (import_node_fs.default.existsSync(clientOutDir)) {
|
|
84
82
|
await loadDir(clientOutDir, pathName);
|
|
85
83
|
}
|
|
86
|
-
const notFoundPathsCode =
|
|
87
|
-
const staticPathsCode =
|
|
88
|
-
|
|
89
|
-
notFoundPathsCode,
|
|
90
|
-
staticPathsCode
|
|
91
|
-
};
|
|
84
|
+
const notFoundPathsCode = createNotFoundPathsCode(pathName, notFounds);
|
|
85
|
+
const staticPathsCode = createStaticPathsCode(staticPaths);
|
|
86
|
+
await injectStatics(staticPathsCode, notFoundPathsCode, serverOutDir);
|
|
92
87
|
}
|
|
93
88
|
function normalizeTrailingSlash(pathname) {
|
|
94
89
|
if (!pathname.endsWith("/")) {
|
|
@@ -96,7 +91,7 @@ function normalizeTrailingSlash(pathname) {
|
|
|
96
91
|
}
|
|
97
92
|
return pathname;
|
|
98
93
|
}
|
|
99
|
-
function
|
|
94
|
+
function createNotFoundPathsCode(basePathname, notFounds) {
|
|
100
95
|
notFounds.sort((a, b) => {
|
|
101
96
|
if (a[0].length > b[0].length) {
|
|
102
97
|
return -1;
|
|
@@ -116,64 +111,43 @@ function createNotFoundPathsModule(basePathname, notFounds, format) {
|
|
|
116
111
|
const html = (0, import_request_handler.getErrorHtml)(404, "Resource Not Found");
|
|
117
112
|
notFounds.push([basePathname, html]);
|
|
118
113
|
}
|
|
119
|
-
|
|
120
|
-
c.push(`const notFounds = ${JSON.stringify(notFounds, null, 2)};`);
|
|
121
|
-
c.push(`function getNotFound(p) {`);
|
|
122
|
-
c.push(` for (const r of notFounds) {`);
|
|
123
|
-
c.push(` if (p.startsWith(r[0])) {`);
|
|
124
|
-
c.push(` return r[1];`);
|
|
125
|
-
c.push(` }`);
|
|
126
|
-
c.push(` }`);
|
|
127
|
-
c.push(` return "Resource Not Found";`);
|
|
128
|
-
c.push(`}`);
|
|
129
|
-
if (format === "cjs") {
|
|
130
|
-
c.push("exports.getNotFound = getNotFound;");
|
|
131
|
-
} else {
|
|
132
|
-
c.push("export { getNotFound };");
|
|
133
|
-
}
|
|
134
|
-
return c.join("\n");
|
|
114
|
+
return JSON.stringify(notFounds, null, 2).slice(1, -1);
|
|
135
115
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
const baseBuildPath = basePathname + "build/";
|
|
139
|
-
const c = [];
|
|
140
|
-
c.push(
|
|
141
|
-
`const staticPaths = new Set(${JSON.stringify(
|
|
142
|
-
Array.from(new Set(staticPaths)).sort()
|
|
143
|
-
)});`
|
|
144
|
-
);
|
|
145
|
-
c.push(`function isStaticPath(method, url) {`);
|
|
146
|
-
c.push(` if (method.toUpperCase() !== 'GET') {`);
|
|
147
|
-
c.push(` return false;`);
|
|
148
|
-
c.push(` }`);
|
|
149
|
-
c.push(` const p = url.pathname;`);
|
|
150
|
-
c.push(` if (p.startsWith(${JSON.stringify(baseBuildPath)})) {`);
|
|
151
|
-
c.push(` return true;`);
|
|
152
|
-
c.push(` }`);
|
|
153
|
-
c.push(` if (p.startsWith(${JSON.stringify(assetsPath)})) {`);
|
|
154
|
-
c.push(` return true;`);
|
|
155
|
-
c.push(` }`);
|
|
156
|
-
c.push(` if (staticPaths.has(p)) {`);
|
|
157
|
-
c.push(` return true;`);
|
|
158
|
-
c.push(` }`);
|
|
159
|
-
c.push(` if (p.endsWith('/q-data.json')) {`);
|
|
160
|
-
c.push(` const pWithoutQdata = p.replace(/\\/q-data.json$/, '');`);
|
|
161
|
-
c.push(` if (staticPaths.has(pWithoutQdata + '/')) {`);
|
|
162
|
-
c.push(` return true;`);
|
|
163
|
-
c.push(` }`);
|
|
164
|
-
c.push(` if (staticPaths.has(pWithoutQdata)) {`);
|
|
165
|
-
c.push(` return true;`);
|
|
166
|
-
c.push(` }`);
|
|
167
|
-
c.push(` }`);
|
|
168
|
-
c.push(` return false;`);
|
|
169
|
-
c.push(`}`);
|
|
170
|
-
if (format === "cjs") {
|
|
171
|
-
c.push("exports.isStaticPath = isStaticPath;");
|
|
172
|
-
} else {
|
|
173
|
-
c.push("export { isStaticPath };");
|
|
174
|
-
}
|
|
175
|
-
return c.join("\n");
|
|
116
|
+
function createStaticPathsCode(staticPaths) {
|
|
117
|
+
return JSON.stringify(Array.from(new Set(staticPaths)).sort()).slice(1, -1);
|
|
176
118
|
}
|
|
119
|
+
var injectStatics = async (staticPathsCode, notFoundPathsCode, outDir) => {
|
|
120
|
+
const promises = /* @__PURE__ */ new Set();
|
|
121
|
+
const doReplace = async (path) => {
|
|
122
|
+
const code = await import_node_fs.default.promises.readFile(path, "utf-8");
|
|
123
|
+
let replaced = false;
|
|
124
|
+
const newCode = code.replace(
|
|
125
|
+
/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,
|
|
126
|
+
(_, _quote, type) => {
|
|
127
|
+
replaced = true;
|
|
128
|
+
return type === "STATIC_PATHS" ? staticPathsCode : notFoundPathsCode;
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
if (replaced) {
|
|
132
|
+
await import_node_fs.default.promises.writeFile(path, newCode);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const walk = async (dir) => {
|
|
136
|
+
const entries = await import_node_fs.default.promises.readdir(dir, { withFileTypes: true });
|
|
137
|
+
for (const entry of entries) {
|
|
138
|
+
if (entry.isDirectory()) {
|
|
139
|
+
await walk((0, import_node_path.join)(dir, entry.name));
|
|
140
|
+
} else if (entry.name.endsWith("js")) {
|
|
141
|
+
const p = doReplace((0, import_node_path.join)(dir, entry.name)).finally(() => {
|
|
142
|
+
promises.delete(p);
|
|
143
|
+
});
|
|
144
|
+
promises.add(p);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
await walk(outDir);
|
|
149
|
+
await Promise.all(promises);
|
|
150
|
+
};
|
|
177
151
|
|
|
178
152
|
// packages/qwik-router/src/adapters/shared/vite/index.ts
|
|
179
153
|
function viteAdapter(opts) {
|
|
@@ -183,10 +157,9 @@ function viteAdapter(opts) {
|
|
|
183
157
|
let renderModulePath = null;
|
|
184
158
|
let qwikRouterConfigModulePath = null;
|
|
185
159
|
let isSsrBuild = false;
|
|
186
|
-
let format = "esm";
|
|
187
160
|
const outputEntries = [];
|
|
188
161
|
const plugin = {
|
|
189
|
-
name: `vite-plugin-qwik-router-${opts.name}`,
|
|
162
|
+
name: `vite-plugin-qwik-router-ssg-${opts.name}`,
|
|
190
163
|
enforce: "post",
|
|
191
164
|
apply: "build",
|
|
192
165
|
config(config) {
|
|
@@ -200,7 +173,7 @@ function viteAdapter(opts) {
|
|
|
200
173
|
return config;
|
|
201
174
|
},
|
|
202
175
|
configResolved(config) {
|
|
203
|
-
var _a, _b, _c
|
|
176
|
+
var _a, _b, _c;
|
|
204
177
|
isSsrBuild = !!config.build.ssr;
|
|
205
178
|
if (isSsrBuild) {
|
|
206
179
|
qwikRouterPlugin = config.plugins.find(
|
|
@@ -226,9 +199,21 @@ function viteAdapter(opts) {
|
|
|
226
199
|
`"build.rollupOptions.input" must be set in order to use the "${opts.name}" adapter.`
|
|
227
200
|
);
|
|
228
201
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
buildStart() {
|
|
205
|
+
if (isSsrBuild && opts.ssg !== null) {
|
|
206
|
+
const { srcDir } = qwikVitePlugin.api.getOptions();
|
|
207
|
+
this.emitFile({
|
|
208
|
+
id: "@qwik-router-config",
|
|
209
|
+
type: "chunk",
|
|
210
|
+
fileName: "@qwik-router-config.js"
|
|
211
|
+
});
|
|
212
|
+
this.emitFile({
|
|
213
|
+
id: `${srcDir}/entry.ssr`,
|
|
214
|
+
type: "chunk",
|
|
215
|
+
fileName: "entry.ssr.js"
|
|
216
|
+
});
|
|
232
217
|
}
|
|
233
218
|
},
|
|
234
219
|
generateBundle(_, bundles) {
|
|
@@ -245,23 +230,13 @@ function viteAdapter(opts) {
|
|
|
245
230
|
}
|
|
246
231
|
}
|
|
247
232
|
}
|
|
248
|
-
if (!renderModulePath) {
|
|
249
|
-
throw new Error(
|
|
250
|
-
'Unable to find "entry.ssr" entry point. Did you forget to add it to "build.rollupOptions.input"?'
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
if (!qwikRouterConfigModulePath) {
|
|
254
|
-
throw new Error(
|
|
255
|
-
'Unable to find "@qwik-router-config" entry point. Did you forget to add it to "build.rollupOptions.input"?'
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
233
|
}
|
|
259
234
|
},
|
|
260
235
|
closeBundle: {
|
|
261
236
|
sequential: true,
|
|
262
237
|
async handler() {
|
|
263
238
|
var _a;
|
|
264
|
-
if (isSsrBuild &&
|
|
239
|
+
if (isSsrBuild && serverOutDir && (qwikRouterPlugin == null ? void 0 : qwikRouterPlugin.api) && (qwikVitePlugin == null ? void 0 : qwikVitePlugin.api)) {
|
|
265
240
|
const staticPaths = opts.staticPaths || [];
|
|
266
241
|
const routes = qwikRouterPlugin.api.getRoutes();
|
|
267
242
|
const basePathname = qwikRouterPlugin.api.getBasePathname();
|
|
@@ -269,7 +244,7 @@ function viteAdapter(opts) {
|
|
|
269
244
|
const clientPublicOutDir = qwikVitePlugin.api.getClientPublicOutDir();
|
|
270
245
|
const assetsDir = qwikVitePlugin.api.getAssetsDir();
|
|
271
246
|
const rootDir = qwikVitePlugin.api.getRootDir() ?? void 0;
|
|
272
|
-
if (renderModulePath && qwikRouterConfigModulePath && clientOutDir && clientPublicOutDir) {
|
|
247
|
+
if (opts.ssg !== null && renderModulePath && qwikRouterConfigModulePath && clientOutDir && clientPublicOutDir) {
|
|
273
248
|
let ssgOrigin = ((_a = opts.ssg) == null ? void 0 : _a.origin) ?? opts.origin;
|
|
274
249
|
if (!ssgOrigin) {
|
|
275
250
|
ssgOrigin = `https://yoursite.qwik.dev`;
|
|
@@ -282,13 +257,13 @@ function viteAdapter(opts) {
|
|
|
282
257
|
}
|
|
283
258
|
try {
|
|
284
259
|
ssgOrigin = new URL(ssgOrigin).origin;
|
|
285
|
-
} catch
|
|
260
|
+
} catch {
|
|
286
261
|
this.warn(
|
|
287
262
|
`Invalid "origin" option: "${ssgOrigin}". Using default origin: "https://yoursite.qwik.dev"`
|
|
288
263
|
);
|
|
289
264
|
ssgOrigin = `https://yoursite.qwik.dev`;
|
|
290
265
|
}
|
|
291
|
-
const staticGenerate = await import("../../../
|
|
266
|
+
const staticGenerate = await import("../../../ssg/index.cjs");
|
|
292
267
|
const generateOpts = {
|
|
293
268
|
maxWorkers: opts.maxWorkers,
|
|
294
269
|
basePathname,
|
|
@@ -308,41 +283,34 @@ function viteAdapter(opts) {
|
|
|
308
283
|
this.error(err);
|
|
309
284
|
}
|
|
310
285
|
staticPaths.push(...staticGenerateResult.staticPaths);
|
|
311
|
-
|
|
286
|
+
}
|
|
287
|
+
await postBuild(
|
|
288
|
+
clientPublicOutDir,
|
|
289
|
+
serverOutDir,
|
|
290
|
+
assetsDir ? (0, import_node_path2.join)(basePathname, assetsDir) : basePathname,
|
|
291
|
+
staticPaths,
|
|
292
|
+
!!opts.cleanStaticGenerated
|
|
293
|
+
);
|
|
294
|
+
if (typeof opts.generate === "function") {
|
|
295
|
+
await opts.generate({
|
|
296
|
+
outputEntries,
|
|
297
|
+
serverOutDir,
|
|
298
|
+
clientOutDir,
|
|
312
299
|
clientPublicOutDir,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
notFoundPathsCode
|
|
323
|
-
)
|
|
324
|
-
]);
|
|
325
|
-
if (typeof opts.generate === "function") {
|
|
326
|
-
await opts.generate({
|
|
327
|
-
outputEntries,
|
|
328
|
-
serverOutDir,
|
|
329
|
-
clientOutDir,
|
|
330
|
-
clientPublicOutDir,
|
|
331
|
-
basePathname,
|
|
332
|
-
routes,
|
|
333
|
-
assetsDir,
|
|
334
|
-
warn: (message) => this.warn(message),
|
|
335
|
-
error: (message) => this.error(message)
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
this.warn(
|
|
339
|
-
`
|
|
300
|
+
basePathname,
|
|
301
|
+
routes,
|
|
302
|
+
assetsDir,
|
|
303
|
+
warn: (message) => this.warn(message),
|
|
304
|
+
error: (message) => this.error(message)
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
this.warn(
|
|
308
|
+
`
|
|
340
309
|
==============================================
|
|
341
310
|
Note: Make sure that you are serving the built files with proper cache headers.
|
|
342
311
|
See https://qwik.dev/docs/deployments/#cache-headers for more information.
|
|
343
312
|
==============================================`
|
|
344
|
-
|
|
345
|
-
}
|
|
313
|
+
);
|
|
346
314
|
}
|
|
347
315
|
}
|
|
348
316
|
}
|
|
@@ -363,16 +331,8 @@ function getParentDir(startDir, dirName) {
|
|
|
363
331
|
}
|
|
364
332
|
throw new Error(`Unable to find "${dirName}" directory from "${startDir}"`);
|
|
365
333
|
}
|
|
366
|
-
var STATIC_PATHS_ID = "@qwik-router-static-paths";
|
|
367
|
-
var RESOLVED_STATIC_PATHS_ID = `${STATIC_PATHS_ID}.js`;
|
|
368
|
-
var NOT_FOUND_PATHS_ID = "@qwik-router-not-found-paths";
|
|
369
|
-
var RESOLVED_NOT_FOUND_PATHS_ID = `${NOT_FOUND_PATHS_ID}.js`;
|
|
370
334
|
// Annotate the CommonJS export names for ESM import in node:
|
|
371
335
|
0 && (module.exports = {
|
|
372
|
-
NOT_FOUND_PATHS_ID,
|
|
373
|
-
RESOLVED_NOT_FOUND_PATHS_ID,
|
|
374
|
-
RESOLVED_STATIC_PATHS_ID,
|
|
375
|
-
STATIC_PATHS_ID,
|
|
376
336
|
getParentDir,
|
|
377
337
|
viteAdapter
|
|
378
338
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Plugin as Plugin_2 } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SsgRenderOptions } from 'packages/qwik-router/src/ssg';
|
|
3
3
|
import type { UserConfig } from 'vite';
|
|
4
4
|
|
|
5
5
|
/** @public */
|
|
6
|
-
export declare interface AdapterSSGOptions extends Omit<
|
|
6
|
+
export declare interface AdapterSSGOptions extends Omit<SsgRenderOptions, 'outDir' | 'origin'> {
|
|
7
7
|
/** Defines routes that should be static generated. Accepts wildcard behavior. */
|
|
8
8
|
include: string[];
|
|
9
9
|
/**
|
|
@@ -48,9 +48,6 @@ declare interface BuildRoute extends ParsedPathname {
|
|
|
48
48
|
/** @public */
|
|
49
49
|
export declare function getParentDir(startDir: string, dirName: string): string;
|
|
50
50
|
|
|
51
|
-
/** @public */
|
|
52
|
-
export declare const NOT_FOUND_PATHS_ID = "@qwik-router-not-found-paths";
|
|
53
|
-
|
|
54
51
|
declare interface ParsedPathname {
|
|
55
52
|
routeName: string;
|
|
56
53
|
pattern: RegExp;
|
|
@@ -66,12 +63,6 @@ declare interface PathnameSegmentPart {
|
|
|
66
63
|
rest: boolean;
|
|
67
64
|
}
|
|
68
65
|
|
|
69
|
-
/** @public */
|
|
70
|
-
export declare const RESOLVED_NOT_FOUND_PATHS_ID = "@qwik-router-not-found-paths.js";
|
|
71
|
-
|
|
72
|
-
/** @public */
|
|
73
|
-
export declare const RESOLVED_STATIC_PATHS_ID = "@qwik-router-static-paths.js";
|
|
74
|
-
|
|
75
66
|
/** @public */
|
|
76
67
|
export declare interface ServerAdapterOptions {
|
|
77
68
|
/**
|
|
@@ -83,10 +74,13 @@ export declare interface ServerAdapterOptions {
|
|
|
83
74
|
ssg?: AdapterSSGOptions | null;
|
|
84
75
|
}
|
|
85
76
|
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Implements the SSG after the build is complete. Also provides a `generate(...)` callback that is
|
|
79
|
+
* called after the SSG is complete, which allows for custom post-processing of the complete build
|
|
80
|
+
* results.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
90
84
|
export declare function viteAdapter(opts: ViteAdapterPluginOptions): Plugin_2<never>;
|
|
91
85
|
|
|
92
86
|
/** @public */
|