vite-ssg-optimized 0.24.2-optimized.21 → 0.24.2-optimized.3
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/README.md +1 -32
- package/dist/client/single-page.d.cts +2 -2
- package/dist/client/single-page.d.mts +2 -2
- package/dist/client/single-page.d.ts +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/node/cli.cjs +1 -1
- package/dist/node/cli.mjs +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.d.cts +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.mjs +1 -1
- package/dist/shared/build.worker.cjs +5 -43
- package/dist/shared/build.worker.d.cts +3 -4
- package/dist/shared/build.worker.d.mts +3 -4
- package/dist/shared/build.worker.d.ts +3 -4
- package/dist/shared/build.worker.mjs +6 -44
- package/dist/shared/{vite-ssg-optimized.f03a17e6.d.mts → vite-ssg-optimized.12fd9d22.d.cts} +1 -1
- package/dist/shared/{vite-ssg-optimized.79d27333.cjs → vite-ssg-optimized.31f4c9de.cjs} +20 -57
- package/dist/shared/{vite-ssg-optimized.27bed688.d.cts → vite-ssg-optimized.892682c8.d.mts} +1 -1
- package/dist/shared/{vite-ssg-optimized.f1a9229c.d.ts → vite-ssg-optimized.950926bc.d.ts} +1 -1
- package/dist/shared/{vite-ssg-optimized.341e382e.d.ts → vite-ssg-optimized.cf5cb4ee.d.cts} +1 -6
- package/dist/shared/{vite-ssg-optimized.341e382e.d.cts → vite-ssg-optimized.cf5cb4ee.d.mts} +1 -6
- package/dist/shared/{vite-ssg-optimized.341e382e.d.mts → vite-ssg-optimized.cf5cb4ee.d.ts} +1 -6
- package/dist/shared/{vite-ssg-optimized.22da6b90.mjs → vite-ssg-optimized.dc2a4a38.mjs} +19 -56
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Vite SSG
|
|
1
|
+
# Vite SSG
|
|
2
2
|
|
|
3
3
|
Static-site generation for Vue 3 on Vite.
|
|
4
4
|
|
|
@@ -6,37 +6,6 @@ Static-site generation for Vue 3 on Vite.
|
|
|
6
6
|
|
|
7
7
|
> ℹ️ **Vite 2 is supported from `v0.2.x`, Vite 1's support is discontinued.**
|
|
8
8
|
|
|
9
|
-
> ℹ️ This is a fork from vite-ssg
|
|
10
|
-
|
|
11
|
-
## Optimizations
|
|
12
|
-
|
|
13
|
-
* Replaced @unhead/dom by @unhead/ssr
|
|
14
|
-
* Used a custom injectInHtml instead of jsdom with is faster
|
|
15
|
-
* Added worker threads to avoid locking main event loop
|
|
16
|
-
* Avoid grow the number of tasks in queue when we have many routes
|
|
17
|
-
* Added teleport support, the original vite-ssg don't writes teleports to the final file causing SSR mismatches
|
|
18
|
-
* Detect if is in isHydrationMode by quering [data-server-rendered] on client
|
|
19
|
-
* Creates SSRApp or App accord with environment and hydration
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
#### Thread Workers
|
|
24
|
-
|
|
25
|
-
To configure `workerThreads` `ssgOptions.numberOfWorkers` in `vite.config.ts`
|
|
26
|
-
|
|
27
|
-
Each thread accept the `Math.ceil(concurrency / numberOfWorkers )` concurrent tasks at max.
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
defineConfig({
|
|
31
|
-
ssgOptions: {
|
|
32
|
-
concurrency: 50,
|
|
33
|
-
numberOfWorkers: 5 // 5 is the default
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
9
|
## Install
|
|
41
10
|
|
|
42
11
|
> **This library requires Node.js version >= 14**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
-
import { V as ViteSSGContext, a as ViteSSGClientOptions } from '../shared/vite-ssg-optimized.
|
|
3
|
-
export { R as RouterOptions, b as ViteSSGOptions } from '../shared/vite-ssg-optimized.
|
|
2
|
+
import { V as ViteSSGContext, a as ViteSSGClientOptions } from '../shared/vite-ssg-optimized.cf5cb4ee.cjs';
|
|
3
|
+
export { R as RouterOptions, b as ViteSSGOptions } from '../shared/vite-ssg-optimized.cf5cb4ee.cjs';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
-
import { V as ViteSSGContext, a as ViteSSGClientOptions } from '../shared/vite-ssg-optimized.
|
|
3
|
-
export { R as RouterOptions, b as ViteSSGOptions } from '../shared/vite-ssg-optimized.
|
|
2
|
+
import { V as ViteSSGContext, a as ViteSSGClientOptions } from '../shared/vite-ssg-optimized.cf5cb4ee.mjs';
|
|
3
|
+
export { R as RouterOptions, b as ViteSSGOptions } from '../shared/vite-ssg-optimized.cf5cb4ee.mjs';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
-
import { V as ViteSSGContext, a as ViteSSGClientOptions } from '../shared/vite-ssg-optimized.
|
|
3
|
-
export { R as RouterOptions, b as ViteSSGOptions } from '../shared/vite-ssg-optimized.
|
|
2
|
+
import { V as ViteSSGContext, a as ViteSSGClientOptions } from '../shared/vite-ssg-optimized.cf5cb4ee.js';
|
|
3
|
+
export { R as RouterOptions, b as ViteSSGOptions } from '../shared/vite-ssg-optimized.cf5cb4ee.js';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
-
import { R as RouterOptions, V as ViteSSGContext, a as ViteSSGClientOptions } from './shared/vite-ssg-optimized.
|
|
3
|
-
export { b as ViteSSGOptions } from './shared/vite-ssg-optimized.
|
|
2
|
+
import { R as RouterOptions, V as ViteSSGContext, a as ViteSSGClientOptions } from './shared/vite-ssg-optimized.cf5cb4ee.cjs';
|
|
3
|
+
export { b as ViteSSGOptions } from './shared/vite-ssg-optimized.cf5cb4ee.cjs';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
-
import { R as RouterOptions, V as ViteSSGContext, a as ViteSSGClientOptions } from './shared/vite-ssg-optimized.
|
|
3
|
-
export { b as ViteSSGOptions } from './shared/vite-ssg-optimized.
|
|
2
|
+
import { R as RouterOptions, V as ViteSSGContext, a as ViteSSGClientOptions } from './shared/vite-ssg-optimized.cf5cb4ee.mjs';
|
|
3
|
+
export { b as ViteSSGOptions } from './shared/vite-ssg-optimized.cf5cb4ee.mjs';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
-
import { R as RouterOptions, V as ViteSSGContext, a as ViteSSGClientOptions } from './shared/vite-ssg-optimized.
|
|
3
|
-
export { b as ViteSSGOptions } from './shared/vite-ssg-optimized.
|
|
2
|
+
import { R as RouterOptions, V as ViteSSGContext, a as ViteSSGClientOptions } from './shared/vite-ssg-optimized.cf5cb4ee.js';
|
|
3
|
+
export { b as ViteSSGOptions } from './shared/vite-ssg-optimized.cf5cb4ee.js';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
package/dist/node/cli.cjs
CHANGED
|
@@ -4,7 +4,7 @@ const process = require('node:process');
|
|
|
4
4
|
const kolorist = require('kolorist');
|
|
5
5
|
const yargs = require('yargs');
|
|
6
6
|
const helpers = require('yargs/helpers');
|
|
7
|
-
const node = require('../shared/vite-ssg-optimized.
|
|
7
|
+
const node = require('../shared/vite-ssg-optimized.31f4c9de.cjs');
|
|
8
8
|
require('node:module');
|
|
9
9
|
require('node:path');
|
|
10
10
|
require('@unhead/ssr');
|
package/dist/node/cli.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import process from 'node:process';
|
|
|
2
2
|
import { gray, bold, red, reset, underline } from 'kolorist';
|
|
3
3
|
import yargs from 'yargs';
|
|
4
4
|
import { hideBin } from 'yargs/helpers';
|
|
5
|
-
import { b as build } from '../shared/vite-ssg-optimized.
|
|
5
|
+
import { b as build } from '../shared/vite-ssg-optimized.dc2a4a38.mjs';
|
|
6
6
|
import 'node:module';
|
|
7
7
|
import 'node:path';
|
|
8
8
|
import '@unhead/ssr';
|
package/dist/node.cjs
CHANGED
package/dist/node.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { b as build } from './shared/vite-ssg-optimized.
|
|
1
|
+
export { b as build } from './shared/vite-ssg-optimized.12fd9d22.cjs';
|
|
2
2
|
import 'vite';
|
|
3
|
-
import './shared/vite-ssg-optimized.
|
|
3
|
+
import './shared/vite-ssg-optimized.cf5cb4ee.cjs';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
package/dist/node.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { b as build } from './shared/vite-ssg-optimized.
|
|
1
|
+
export { b as build } from './shared/vite-ssg-optimized.892682c8.mjs';
|
|
2
2
|
import 'vite';
|
|
3
|
-
import './shared/vite-ssg-optimized.
|
|
3
|
+
import './shared/vite-ssg-optimized.cf5cb4ee.mjs';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { b as build } from './shared/vite-ssg-optimized.
|
|
1
|
+
export { b as build } from './shared/vite-ssg-optimized.950926bc.js';
|
|
2
2
|
import 'vite';
|
|
3
|
-
import './shared/vite-ssg-optimized.
|
|
3
|
+
import './shared/vite-ssg-optimized.cf5cb4ee.js';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
package/dist/node.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const node_module = require('node:module');
|
|
4
4
|
const node_worker_threads = require('node:worker_threads');
|
|
5
|
-
const node = require('./vite-ssg-optimized.
|
|
5
|
+
const node = require('./vite-ssg-optimized.31f4c9de.cjs');
|
|
6
6
|
const kolorist = require('kolorist');
|
|
7
7
|
const vite = require('vite');
|
|
8
8
|
require('node:path');
|
|
@@ -14,46 +14,13 @@ require('html5parser');
|
|
|
14
14
|
|
|
15
15
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
16
16
|
(async () => {
|
|
17
|
-
const plainnify = (m) => {
|
|
18
|
-
if (m instanceof Function) {
|
|
19
|
-
return void 0;
|
|
20
|
-
}
|
|
21
|
-
if (Array.isArray(m)) {
|
|
22
|
-
return m.map(plainnify);
|
|
23
|
-
}
|
|
24
|
-
if (typeof m === "object" && m !== null) {
|
|
25
|
-
if (m instanceof Error || "stack" in m) {
|
|
26
|
-
return {
|
|
27
|
-
message: m.message,
|
|
28
|
-
stack: m.stack
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return Object.entries(m).reduce((acc, [key, value]) => {
|
|
32
|
-
acc[key] = plainnify(value);
|
|
33
|
-
return acc;
|
|
34
|
-
}, {});
|
|
35
|
-
}
|
|
36
|
-
return m?.toString();
|
|
37
|
-
};
|
|
38
|
-
const fnLog = (level = "info", ...msg) => {
|
|
39
|
-
const newMsg = msg.map(plainnify);
|
|
40
|
-
node_worker_threads.parentPort.postMessage({ type: "log", args: newMsg, level });
|
|
41
|
-
};
|
|
42
|
-
globalThis.console = Object.assign(globalThis.console, {
|
|
43
|
-
info: fnLog.bind(globalThis.console, "info"),
|
|
44
|
-
warn: fnLog.bind(globalThis.console, "warn"),
|
|
45
|
-
error: fnLog.bind(globalThis.console, "error"),
|
|
46
|
-
log: fnLog.bind(globalThis.console, "log"),
|
|
47
|
-
trace: fnLog.bind(globalThis.console, "trace"),
|
|
48
|
-
debug: fnLog.bind(globalThis.console, "debug")
|
|
49
|
-
});
|
|
50
17
|
const { serverEntry, out, beastiesOptions, viteConfig, mode, format, dirStyle, ...extraOpts } = node_worker_threads.workerData;
|
|
51
18
|
const nodeEnv = process.env.NODE_ENV || "production";
|
|
52
19
|
const config = await vite.resolveConfig(viteConfig, "build", mode, nodeEnv);
|
|
53
20
|
const {
|
|
54
21
|
onPageRendered,
|
|
55
|
-
onBeforePageRender
|
|
56
|
-
|
|
22
|
+
onBeforePageRender,
|
|
23
|
+
onDonePageRender
|
|
57
24
|
} = config.ssgOptions || {};
|
|
58
25
|
const { renderToString } = await import('vue/server-renderer');
|
|
59
26
|
const outDir = out.replace(process.cwd(), "").replace(/^\//g, "");
|
|
@@ -72,7 +39,7 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
|
|
|
72
39
|
renderToString,
|
|
73
40
|
onPageRendered,
|
|
74
41
|
onBeforePageRender,
|
|
75
|
-
|
|
42
|
+
onDonePageRender,
|
|
76
43
|
beasties,
|
|
77
44
|
config: { logger: { info: (msg) => {
|
|
78
45
|
node_worker_threads.parentPort.postMessage({ type: "log", args: [msg] });
|
|
@@ -95,12 +62,7 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
|
|
|
95
62
|
}
|
|
96
63
|
node_worker_threads.parentPort.postMessage({ type: "result", id, result });
|
|
97
64
|
} catch (e) {
|
|
98
|
-
|
|
99
|
-
const stack = e.stack || "";
|
|
100
|
-
const error = { message: message2, stack };
|
|
101
|
-
process.stderr.write(`${kolorist.red("[vite-ssg-worker]")} ${message2} ${stack}
|
|
102
|
-
`);
|
|
103
|
-
node_worker_threads.parentPort.postMessage({ type: "error", id, error });
|
|
65
|
+
node_worker_threads.parentPort.postMessage({ type: "error", id, error: e.toString() });
|
|
104
66
|
}
|
|
105
67
|
}
|
|
106
68
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { M as Manifest } from './vite-ssg-optimized.
|
|
1
|
+
import { M as Manifest } from './vite-ssg-optimized.12fd9d22.cjs';
|
|
2
2
|
import { ViteSSGOptions } from 'vite-ssg';
|
|
3
3
|
import { Options } from 'beasties';
|
|
4
4
|
import { Options as Options$1 } from 'html-minifier-terser';
|
|
5
5
|
import 'vite';
|
|
6
|
-
import './vite-ssg-optimized.
|
|
6
|
+
import './vite-ssg-optimized.cf5cb4ee.cjs';
|
|
7
7
|
import '@unhead/vue';
|
|
8
8
|
import 'critters';
|
|
9
9
|
import 'vue';
|
|
@@ -11,7 +11,6 @@ import 'vue-router';
|
|
|
11
11
|
|
|
12
12
|
interface WorkerDataEntry {
|
|
13
13
|
serverEntry: string;
|
|
14
|
-
workerId: number | string;
|
|
15
14
|
format: 'esm' | 'cjs';
|
|
16
15
|
out: string;
|
|
17
16
|
dirStyle: ViteSSGOptions['dirStyle'];
|
|
@@ -23,7 +22,7 @@ interface WorkerDataEntry {
|
|
|
23
22
|
formatting: ViteSSGOptions['formatting'];
|
|
24
23
|
minifyOptions: Options$1;
|
|
25
24
|
viteConfig: {
|
|
26
|
-
configFile
|
|
25
|
+
configFile: string;
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { M as Manifest } from './vite-ssg-optimized.
|
|
1
|
+
import { M as Manifest } from './vite-ssg-optimized.892682c8.mjs';
|
|
2
2
|
import { ViteSSGOptions } from 'vite-ssg';
|
|
3
3
|
import { Options } from 'beasties';
|
|
4
4
|
import { Options as Options$1 } from 'html-minifier-terser';
|
|
5
5
|
import 'vite';
|
|
6
|
-
import './vite-ssg-optimized.
|
|
6
|
+
import './vite-ssg-optimized.cf5cb4ee.mjs';
|
|
7
7
|
import '@unhead/vue';
|
|
8
8
|
import 'critters';
|
|
9
9
|
import 'vue';
|
|
@@ -11,7 +11,6 @@ import 'vue-router';
|
|
|
11
11
|
|
|
12
12
|
interface WorkerDataEntry {
|
|
13
13
|
serverEntry: string;
|
|
14
|
-
workerId: number | string;
|
|
15
14
|
format: 'esm' | 'cjs';
|
|
16
15
|
out: string;
|
|
17
16
|
dirStyle: ViteSSGOptions['dirStyle'];
|
|
@@ -23,7 +22,7 @@ interface WorkerDataEntry {
|
|
|
23
22
|
formatting: ViteSSGOptions['formatting'];
|
|
24
23
|
minifyOptions: Options$1;
|
|
25
24
|
viteConfig: {
|
|
26
|
-
configFile
|
|
25
|
+
configFile: string;
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { M as Manifest } from './vite-ssg-optimized.
|
|
1
|
+
import { M as Manifest } from './vite-ssg-optimized.950926bc.js';
|
|
2
2
|
import { ViteSSGOptions } from 'vite-ssg';
|
|
3
3
|
import { Options } from 'beasties';
|
|
4
4
|
import { Options as Options$1 } from 'html-minifier-terser';
|
|
5
5
|
import 'vite';
|
|
6
|
-
import './vite-ssg-optimized.
|
|
6
|
+
import './vite-ssg-optimized.cf5cb4ee.js';
|
|
7
7
|
import '@unhead/vue';
|
|
8
8
|
import 'critters';
|
|
9
9
|
import 'vue';
|
|
@@ -11,7 +11,6 @@ import 'vue-router';
|
|
|
11
11
|
|
|
12
12
|
interface WorkerDataEntry {
|
|
13
13
|
serverEntry: string;
|
|
14
|
-
workerId: number | string;
|
|
15
14
|
format: 'esm' | 'cjs';
|
|
16
15
|
out: string;
|
|
17
16
|
dirStyle: ViteSSGOptions['dirStyle'];
|
|
@@ -23,7 +22,7 @@ interface WorkerDataEntry {
|
|
|
23
22
|
formatting: ViteSSGOptions['formatting'];
|
|
24
23
|
minifyOptions: Options$1;
|
|
25
24
|
viteConfig: {
|
|
26
|
-
configFile
|
|
25
|
+
configFile: string;
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { parentPort, workerData } from 'node:worker_threads';
|
|
3
|
-
import { g as getBeastiesOrCritters, e as executeTaskFn } from './vite-ssg-optimized.
|
|
4
|
-
import { gray, blue
|
|
3
|
+
import { g as getBeastiesOrCritters, e as executeTaskFn } from './vite-ssg-optimized.dc2a4a38.mjs';
|
|
4
|
+
import { gray, blue } from 'kolorist';
|
|
5
5
|
import { resolveConfig } from 'vite';
|
|
6
6
|
import 'node:path';
|
|
7
7
|
import 'node:process';
|
|
@@ -11,46 +11,13 @@ import './vite-ssg-optimized.579feabb.mjs';
|
|
|
11
11
|
import 'html5parser';
|
|
12
12
|
|
|
13
13
|
(async () => {
|
|
14
|
-
const plainnify = (m) => {
|
|
15
|
-
if (m instanceof Function) {
|
|
16
|
-
return void 0;
|
|
17
|
-
}
|
|
18
|
-
if (Array.isArray(m)) {
|
|
19
|
-
return m.map(plainnify);
|
|
20
|
-
}
|
|
21
|
-
if (typeof m === "object" && m !== null) {
|
|
22
|
-
if (m instanceof Error || "stack" in m) {
|
|
23
|
-
return {
|
|
24
|
-
message: m.message,
|
|
25
|
-
stack: m.stack
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
return Object.entries(m).reduce((acc, [key, value]) => {
|
|
29
|
-
acc[key] = plainnify(value);
|
|
30
|
-
return acc;
|
|
31
|
-
}, {});
|
|
32
|
-
}
|
|
33
|
-
return m?.toString();
|
|
34
|
-
};
|
|
35
|
-
const fnLog = (level = "info", ...msg) => {
|
|
36
|
-
const newMsg = msg.map(plainnify);
|
|
37
|
-
parentPort.postMessage({ type: "log", args: newMsg, level });
|
|
38
|
-
};
|
|
39
|
-
globalThis.console = Object.assign(globalThis.console, {
|
|
40
|
-
info: fnLog.bind(globalThis.console, "info"),
|
|
41
|
-
warn: fnLog.bind(globalThis.console, "warn"),
|
|
42
|
-
error: fnLog.bind(globalThis.console, "error"),
|
|
43
|
-
log: fnLog.bind(globalThis.console, "log"),
|
|
44
|
-
trace: fnLog.bind(globalThis.console, "trace"),
|
|
45
|
-
debug: fnLog.bind(globalThis.console, "debug")
|
|
46
|
-
});
|
|
47
14
|
const { serverEntry, out, beastiesOptions, viteConfig, mode, format, dirStyle, ...extraOpts } = workerData;
|
|
48
15
|
const nodeEnv = process.env.NODE_ENV || "production";
|
|
49
16
|
const config = await resolveConfig(viteConfig, "build", mode, nodeEnv);
|
|
50
17
|
const {
|
|
51
18
|
onPageRendered,
|
|
52
|
-
onBeforePageRender
|
|
53
|
-
|
|
19
|
+
onBeforePageRender,
|
|
20
|
+
onDonePageRender
|
|
54
21
|
} = config.ssgOptions || {};
|
|
55
22
|
const { renderToString } = await import('vue/server-renderer');
|
|
56
23
|
const outDir = out.replace(process.cwd(), "").replace(/^\//g, "");
|
|
@@ -69,7 +36,7 @@ import 'html5parser';
|
|
|
69
36
|
renderToString,
|
|
70
37
|
onPageRendered,
|
|
71
38
|
onBeforePageRender,
|
|
72
|
-
|
|
39
|
+
onDonePageRender,
|
|
73
40
|
beasties,
|
|
74
41
|
config: { logger: { info: (msg) => {
|
|
75
42
|
parentPort.postMessage({ type: "log", args: [msg] });
|
|
@@ -92,12 +59,7 @@ import 'html5parser';
|
|
|
92
59
|
}
|
|
93
60
|
parentPort.postMessage({ type: "result", id, result });
|
|
94
61
|
} catch (e) {
|
|
95
|
-
|
|
96
|
-
const stack = e.stack || "";
|
|
97
|
-
const error = { message: message2, stack };
|
|
98
|
-
process.stderr.write(`${red("[vite-ssg-worker]")} ${message2} ${stack}
|
|
99
|
-
`);
|
|
100
|
-
parentPort.postMessage({ type: "error", id, error });
|
|
62
|
+
parentPort.postMessage({ type: "error", id, error: e.toString() });
|
|
101
63
|
}
|
|
102
64
|
}
|
|
103
65
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InlineConfig } from 'vite';
|
|
2
|
-
import { b as ViteSSGOptions } from './vite-ssg-optimized.
|
|
2
|
+
import { b as ViteSSGOptions } from './vite-ssg-optimized.cf5cb4ee.cjs';
|
|
3
3
|
|
|
4
4
|
type Manifest = Record<string, string[]>;
|
|
5
5
|
declare function build(ssgOptions?: Partial<ViteSSGOptions & {
|
|
@@ -1059,8 +1059,9 @@ class BuildWorkerProxy {
|
|
|
1059
1059
|
if (type !== "log")
|
|
1060
1060
|
return;
|
|
1061
1061
|
const fn = console[level]?.bind(console);
|
|
1062
|
-
|
|
1063
|
-
|
|
1062
|
+
let msg = args.map((arg) => typeof arg === "object" && !!arg ? "[object]" : arg).join(" ");
|
|
1063
|
+
process.stdout.write(msg);
|
|
1064
|
+
fn?.(msg);
|
|
1064
1065
|
});
|
|
1065
1066
|
this.worker.on("message", (message) => {
|
|
1066
1067
|
const { id, type, result = void 0, error = void 0 } = message;
|
|
@@ -1159,13 +1160,12 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1159
1160
|
ssgOut: _ssgOutDir = node_path.join(root, ".vite-ssg-temp", Math.random().toString(36).substring(2, 12)),
|
|
1160
1161
|
formatting = "none",
|
|
1161
1162
|
minifyOptions = {},
|
|
1162
|
-
|
|
1163
|
+
crittersOptions = {},
|
|
1163
1164
|
beastiesOptions = {},
|
|
1164
1165
|
includedRoutes: configIncludedRoutes = DefaultIncludedRoutes,
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
numberOfWorkers: _numberOfWorkers = 5,
|
|
1166
|
+
onBeforePageRender,
|
|
1167
|
+
onPageRendered,
|
|
1168
|
+
onDonePageRender,
|
|
1169
1169
|
onFinished,
|
|
1170
1170
|
dirStyle = "flat",
|
|
1171
1171
|
includeAllRoutes = false,
|
|
@@ -1193,7 +1193,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1193
1193
|
const prefix = format === "esm" && process__default.platform === "win32" ? "file://" : "";
|
|
1194
1194
|
const ext = format === "esm" ? ".mjs" : ".cjs";
|
|
1195
1195
|
const serverEntry = prefix + node_path.join(ssgOut, node_path.parse(ssrEntry).name + ext).replace(/\\/g, "/");
|
|
1196
|
-
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/vite-ssg-optimized.
|
|
1196
|
+
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/vite-ssg-optimized.31f4c9de.cjs', document.baseURI).href)));
|
|
1197
1197
|
const { createApp, includedRoutes: serverEntryIncludedRoutes } = format === "esm" ? await import(serverEntry) : _require(serverEntry);
|
|
1198
1198
|
const includedRoutes = serverEntryIncludedRoutes || configIncludedRoutes;
|
|
1199
1199
|
const { routes } = await createApp(false);
|
|
@@ -1219,11 +1219,9 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1219
1219
|
indexHTML = await formatHtml(indexHTML, IS_PROD ? "minify" : formatting, minifyOptions);
|
|
1220
1220
|
const queue = new PQueue({ concurrency });
|
|
1221
1221
|
const workerExt = format === "esm" ? ".mjs" : ".cjs";
|
|
1222
|
-
const createProxy = (
|
|
1223
|
-
const workerProxy = new BuildWorkerProxy(new URL(`./build.worker${workerExt}`, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/vite-ssg-optimized.
|
|
1224
|
-
env: process__default.env,
|
|
1222
|
+
const createProxy = () => {
|
|
1223
|
+
const workerProxy = new BuildWorkerProxy(new URL(`./build.worker${workerExt}`, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/vite-ssg-optimized.31f4c9de.cjs', document.baseURI).href))), {
|
|
1225
1224
|
workerData: {
|
|
1226
|
-
workerId: index,
|
|
1227
1225
|
serverEntry,
|
|
1228
1226
|
ssrManifest,
|
|
1229
1227
|
format,
|
|
@@ -1235,63 +1233,28 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1235
1233
|
formatting,
|
|
1236
1234
|
minifyOptions,
|
|
1237
1235
|
viteConfig: {
|
|
1238
|
-
configFile: config.configFile
|
|
1236
|
+
configFile: config.configFile || "vite.config.ts"
|
|
1239
1237
|
}
|
|
1240
1238
|
}
|
|
1241
1239
|
});
|
|
1242
1240
|
return workerProxy;
|
|
1243
1241
|
};
|
|
1244
|
-
const numberOfWorkers =
|
|
1245
|
-
|
|
1246
|
-
const workers = Array.from({ length: numberOfWorkers }, (_, index) => createProxy(index));
|
|
1247
|
-
const terminateWorkers = () => {
|
|
1248
|
-
workers.splice(0, workers.length).forEach((worker) => worker.terminate());
|
|
1249
|
-
};
|
|
1250
|
-
process__default.on("SIGINT", terminateWorkers);
|
|
1251
|
-
process__default.on("SIGTERM", terminateWorkers);
|
|
1252
|
-
process__default.on("SIGBREAK", terminateWorkers);
|
|
1253
|
-
process__default.on("beforeExit", terminateWorkers);
|
|
1254
|
-
process__default.on("exit", terminateWorkers);
|
|
1242
|
+
const numberOfWorkers = 5;
|
|
1243
|
+
const workers = Array.from({ length: numberOfWorkers }, createProxy);
|
|
1255
1244
|
let workerIndex = 0;
|
|
1256
|
-
const maxTasksPerWorker = Math.ceil(concurrency / numberOfWorkers);
|
|
1257
|
-
const workersInUse = /* @__PURE__ */ new Map();
|
|
1258
|
-
const workerTasksRunning = (w) => workersInUse.get(w)?.length || 0;
|
|
1259
|
-
const selectIdleWorker = () => workers.filter((w) => workerTasksRunning(w) < maxTasksPerWorker).sort((a, b) => workerTasksRunning(a) - workerTasksRunning(b))[0];
|
|
1260
|
-
const selectWorker = async (workerIndex2) => {
|
|
1261
|
-
const index = workerIndex2 ?? Math.round(Math.random() * numberOfWorkers);
|
|
1262
|
-
const maybeWorker = workers[index % numberOfWorkers];
|
|
1263
|
-
const worker = maybeWorker && workerTasksRunning(maybeWorker) < maxTasksPerWorker ? maybeWorker : selectIdleWorker();
|
|
1264
|
-
if (!worker) {
|
|
1265
|
-
await Promise.race(Array.from(workersInUse.values()).flat());
|
|
1266
|
-
return selectWorker(workerIndex2);
|
|
1267
|
-
}
|
|
1268
|
-
const workerPromises = workersInUse.get(worker) || [];
|
|
1269
|
-
const delayPromise = new Promise((resolve) => setImmediate(resolve));
|
|
1270
|
-
workersInUse.set(worker, [...workerPromises, delayPromise]);
|
|
1271
|
-
delayPromise.finally(() => {
|
|
1272
|
-
workerPromises.splice(workerPromises.indexOf(delayPromise), 1);
|
|
1273
|
-
workersInUse.set(worker, workerPromises);
|
|
1274
|
-
});
|
|
1275
|
-
return worker;
|
|
1276
|
-
};
|
|
1277
1245
|
for (const route of routesPaths) {
|
|
1278
|
-
await queue.onSizeLessThan(concurrency);
|
|
1246
|
+
await queue.onSizeLessThan(concurrency + 5);
|
|
1247
|
+
const workerProxy = workers[workerIndex];
|
|
1248
|
+
workerIndex = (workerIndex + 1) % numberOfWorkers;
|
|
1279
1249
|
queue.add(async () => {
|
|
1280
|
-
const workerProxy = await selectWorker(workerIndex++ % numberOfWorkers);
|
|
1281
1250
|
const taskPromise = executeTaskInWorker(workerProxy, {
|
|
1282
1251
|
route
|
|
1283
1252
|
});
|
|
1284
|
-
const workerPromises = workersInUse.get(workerProxy) || [];
|
|
1285
|
-
workersInUse.set(workerProxy, workerPromises);
|
|
1286
|
-
taskPromise.finally(() => {
|
|
1287
|
-
workerPromises.splice(workerPromises.indexOf(taskPromise), 1);
|
|
1288
|
-
workersInUse.set(workerProxy, workerPromises);
|
|
1289
|
-
});
|
|
1290
1253
|
return taskPromise;
|
|
1291
1254
|
});
|
|
1292
1255
|
}
|
|
1293
1256
|
await queue.start().onIdle();
|
|
1294
|
-
|
|
1257
|
+
workers.forEach((worker) => worker.terminate());
|
|
1295
1258
|
if (!ssgOptions["skip-build"]) {
|
|
1296
1259
|
await fs__default.remove(ssgOut);
|
|
1297
1260
|
}
|
|
@@ -1327,7 +1290,7 @@ async function executeTaskFn(opts) {
|
|
|
1327
1290
|
renderToString,
|
|
1328
1291
|
indexHTML,
|
|
1329
1292
|
onBeforePageRender,
|
|
1330
|
-
|
|
1293
|
+
onDonePageRender,
|
|
1331
1294
|
onPageRendered,
|
|
1332
1295
|
ssrManifest,
|
|
1333
1296
|
rootContainerId,
|
|
@@ -1383,10 +1346,10 @@ async function executeTaskFn(opts) {
|
|
|
1383
1346
|
const filename = dirStyle === "nested" ? node_path.join(route.replace(/^\//g, ""), "index.html") : relativeRouteFile;
|
|
1384
1347
|
await fs__default.ensureDir(node_path.join(out, node_path.dirname(filename)));
|
|
1385
1348
|
return fs__default.writeFile(node_path.join(out, filename), formatted, "utf-8").then(() => {
|
|
1386
|
-
const outDir = out.replace(process__default.cwd(), "").replace(/^\//, "");
|
|
1387
1349
|
config.logger.info(
|
|
1388
|
-
`${kolorist.dim(`${
|
|
1350
|
+
`${kolorist.dim(`${out}/`)}${kolorist.cyan(filename.padEnd(15, " "))} ${kolorist.dim(getSize(formatted))}`
|
|
1389
1351
|
);
|
|
1352
|
+
onDonePageRender?.(route, html, appCtx);
|
|
1390
1353
|
return { route, html };
|
|
1391
1354
|
});
|
|
1392
1355
|
} catch (err) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InlineConfig } from 'vite';
|
|
2
|
-
import { b as ViteSSGOptions } from './vite-ssg-optimized.
|
|
2
|
+
import { b as ViteSSGOptions } from './vite-ssg-optimized.cf5cb4ee.mjs';
|
|
3
3
|
|
|
4
4
|
type Manifest = Record<string, string[]>;
|
|
5
5
|
declare function build(ssgOptions?: Partial<ViteSSGOptions & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InlineConfig } from 'vite';
|
|
2
|
-
import { b as ViteSSGOptions } from './vite-ssg-optimized.
|
|
2
|
+
import { b as ViteSSGOptions } from './vite-ssg-optimized.cf5cb4ee.js';
|
|
3
3
|
|
|
4
4
|
type Manifest = Record<string, string[]>;
|
|
5
5
|
declare function build(ssgOptions?: Partial<ViteSSGOptions & {
|
|
@@ -113,13 +113,8 @@ interface ViteSSGOptions {
|
|
|
113
113
|
* It's useful to debug memory leaks
|
|
114
114
|
*
|
|
115
115
|
*/
|
|
116
|
+
onDonePageRender?: (route: string, renderedHTML: string, appCtx: ViteSSGContext<true>) => Promise<void> | void;
|
|
116
117
|
onFinished?: () => Promise<void> | void;
|
|
117
|
-
/**
|
|
118
|
-
* The number of workers to use.
|
|
119
|
-
*
|
|
120
|
-
* @default 5
|
|
121
|
-
*/
|
|
122
|
-
numberOfWorkers?: number;
|
|
123
118
|
/**
|
|
124
119
|
* The application's root container `id`.
|
|
125
120
|
*
|
|
@@ -113,13 +113,8 @@ interface ViteSSGOptions {
|
|
|
113
113
|
* It's useful to debug memory leaks
|
|
114
114
|
*
|
|
115
115
|
*/
|
|
116
|
+
onDonePageRender?: (route: string, renderedHTML: string, appCtx: ViteSSGContext<true>) => Promise<void> | void;
|
|
116
117
|
onFinished?: () => Promise<void> | void;
|
|
117
|
-
/**
|
|
118
|
-
* The number of workers to use.
|
|
119
|
-
*
|
|
120
|
-
* @default 5
|
|
121
|
-
*/
|
|
122
|
-
numberOfWorkers?: number;
|
|
123
118
|
/**
|
|
124
119
|
* The application's root container `id`.
|
|
125
120
|
*
|
|
@@ -113,13 +113,8 @@ interface ViteSSGOptions {
|
|
|
113
113
|
* It's useful to debug memory leaks
|
|
114
114
|
*
|
|
115
115
|
*/
|
|
116
|
+
onDonePageRender?: (route: string, renderedHTML: string, appCtx: ViteSSGContext<true>) => Promise<void> | void;
|
|
116
117
|
onFinished?: () => Promise<void> | void;
|
|
117
|
-
/**
|
|
118
|
-
* The number of workers to use.
|
|
119
|
-
*
|
|
120
|
-
* @default 5
|
|
121
|
-
*/
|
|
122
|
-
numberOfWorkers?: number;
|
|
123
118
|
/**
|
|
124
119
|
* The application's root container `id`.
|
|
125
120
|
*
|
|
@@ -3,7 +3,7 @@ import { isAbsolute, join, parse, dirname } from 'node:path';
|
|
|
3
3
|
import process$1 from 'node:process';
|
|
4
4
|
import { renderSSRHead } from '@unhead/ssr';
|
|
5
5
|
import fs from 'fs-extra';
|
|
6
|
-
import { gray, yellow, blue,
|
|
6
|
+
import { gray, yellow, blue, green, dim, cyan, red } from 'kolorist';
|
|
7
7
|
import { resolveConfig, build as build$1, mergeConfig } from 'vite';
|
|
8
8
|
import { s as serializeState } from './vite-ssg-optimized.579feabb.mjs';
|
|
9
9
|
import html5Parser, { SyntaxKind } from 'html5parser';
|
|
@@ -1050,8 +1050,9 @@ class BuildWorkerProxy {
|
|
|
1050
1050
|
if (type !== "log")
|
|
1051
1051
|
return;
|
|
1052
1052
|
const fn = console[level]?.bind(console);
|
|
1053
|
-
|
|
1054
|
-
|
|
1053
|
+
let msg = args.map((arg) => typeof arg === "object" && !!arg ? "[object]" : arg).join(" ");
|
|
1054
|
+
process.stdout.write(msg);
|
|
1055
|
+
fn?.(msg);
|
|
1055
1056
|
});
|
|
1056
1057
|
this.worker.on("message", (message) => {
|
|
1057
1058
|
const { id, type, result = void 0, error = void 0 } = message;
|
|
@@ -1150,13 +1151,12 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1150
1151
|
ssgOut: _ssgOutDir = join(root, ".vite-ssg-temp", Math.random().toString(36).substring(2, 12)),
|
|
1151
1152
|
formatting = "none",
|
|
1152
1153
|
minifyOptions = {},
|
|
1153
|
-
|
|
1154
|
+
crittersOptions = {},
|
|
1154
1155
|
beastiesOptions = {},
|
|
1155
1156
|
includedRoutes: configIncludedRoutes = DefaultIncludedRoutes,
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
numberOfWorkers: _numberOfWorkers = 5,
|
|
1157
|
+
onBeforePageRender,
|
|
1158
|
+
onPageRendered,
|
|
1159
|
+
onDonePageRender,
|
|
1160
1160
|
onFinished,
|
|
1161
1161
|
dirStyle = "flat",
|
|
1162
1162
|
includeAllRoutes = false,
|
|
@@ -1210,11 +1210,9 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1210
1210
|
indexHTML = await formatHtml(indexHTML, IS_PROD ? "minify" : formatting, minifyOptions);
|
|
1211
1211
|
const queue = new PQueue({ concurrency });
|
|
1212
1212
|
const workerExt = format === "esm" ? ".mjs" : ".cjs";
|
|
1213
|
-
const createProxy = (
|
|
1213
|
+
const createProxy = () => {
|
|
1214
1214
|
const workerProxy = new BuildWorkerProxy(new URL(`./build.worker${workerExt}`, import.meta.url), {
|
|
1215
|
-
env: process$1.env,
|
|
1216
1215
|
workerData: {
|
|
1217
|
-
workerId: index,
|
|
1218
1216
|
serverEntry,
|
|
1219
1217
|
ssrManifest,
|
|
1220
1218
|
format,
|
|
@@ -1226,63 +1224,28 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1226
1224
|
formatting,
|
|
1227
1225
|
minifyOptions,
|
|
1228
1226
|
viteConfig: {
|
|
1229
|
-
configFile: config.configFile
|
|
1227
|
+
configFile: config.configFile || "vite.config.ts"
|
|
1230
1228
|
}
|
|
1231
1229
|
}
|
|
1232
1230
|
});
|
|
1233
1231
|
return workerProxy;
|
|
1234
1232
|
};
|
|
1235
|
-
const numberOfWorkers =
|
|
1236
|
-
|
|
1237
|
-
const workers = Array.from({ length: numberOfWorkers }, (_, index) => createProxy(index));
|
|
1238
|
-
const terminateWorkers = () => {
|
|
1239
|
-
workers.splice(0, workers.length).forEach((worker) => worker.terminate());
|
|
1240
|
-
};
|
|
1241
|
-
process$1.on("SIGINT", terminateWorkers);
|
|
1242
|
-
process$1.on("SIGTERM", terminateWorkers);
|
|
1243
|
-
process$1.on("SIGBREAK", terminateWorkers);
|
|
1244
|
-
process$1.on("beforeExit", terminateWorkers);
|
|
1245
|
-
process$1.on("exit", terminateWorkers);
|
|
1233
|
+
const numberOfWorkers = 5;
|
|
1234
|
+
const workers = Array.from({ length: numberOfWorkers }, createProxy);
|
|
1246
1235
|
let workerIndex = 0;
|
|
1247
|
-
const maxTasksPerWorker = Math.ceil(concurrency / numberOfWorkers);
|
|
1248
|
-
const workersInUse = /* @__PURE__ */ new Map();
|
|
1249
|
-
const workerTasksRunning = (w) => workersInUse.get(w)?.length || 0;
|
|
1250
|
-
const selectIdleWorker = () => workers.filter((w) => workerTasksRunning(w) < maxTasksPerWorker).sort((a, b) => workerTasksRunning(a) - workerTasksRunning(b))[0];
|
|
1251
|
-
const selectWorker = async (workerIndex2) => {
|
|
1252
|
-
const index = workerIndex2 ?? Math.round(Math.random() * numberOfWorkers);
|
|
1253
|
-
const maybeWorker = workers[index % numberOfWorkers];
|
|
1254
|
-
const worker = maybeWorker && workerTasksRunning(maybeWorker) < maxTasksPerWorker ? maybeWorker : selectIdleWorker();
|
|
1255
|
-
if (!worker) {
|
|
1256
|
-
await Promise.race(Array.from(workersInUse.values()).flat());
|
|
1257
|
-
return selectWorker(workerIndex2);
|
|
1258
|
-
}
|
|
1259
|
-
const workerPromises = workersInUse.get(worker) || [];
|
|
1260
|
-
const delayPromise = new Promise((resolve) => setImmediate(resolve));
|
|
1261
|
-
workersInUse.set(worker, [...workerPromises, delayPromise]);
|
|
1262
|
-
delayPromise.finally(() => {
|
|
1263
|
-
workerPromises.splice(workerPromises.indexOf(delayPromise), 1);
|
|
1264
|
-
workersInUse.set(worker, workerPromises);
|
|
1265
|
-
});
|
|
1266
|
-
return worker;
|
|
1267
|
-
};
|
|
1268
1236
|
for (const route of routesPaths) {
|
|
1269
|
-
await queue.onSizeLessThan(concurrency);
|
|
1237
|
+
await queue.onSizeLessThan(concurrency + 5);
|
|
1238
|
+
const workerProxy = workers[workerIndex];
|
|
1239
|
+
workerIndex = (workerIndex + 1) % numberOfWorkers;
|
|
1270
1240
|
queue.add(async () => {
|
|
1271
|
-
const workerProxy = await selectWorker(workerIndex++ % numberOfWorkers);
|
|
1272
1241
|
const taskPromise = executeTaskInWorker(workerProxy, {
|
|
1273
1242
|
route
|
|
1274
1243
|
});
|
|
1275
|
-
const workerPromises = workersInUse.get(workerProxy) || [];
|
|
1276
|
-
workersInUse.set(workerProxy, workerPromises);
|
|
1277
|
-
taskPromise.finally(() => {
|
|
1278
|
-
workerPromises.splice(workerPromises.indexOf(taskPromise), 1);
|
|
1279
|
-
workersInUse.set(workerProxy, workerPromises);
|
|
1280
|
-
});
|
|
1281
1244
|
return taskPromise;
|
|
1282
1245
|
});
|
|
1283
1246
|
}
|
|
1284
1247
|
await queue.start().onIdle();
|
|
1285
|
-
|
|
1248
|
+
workers.forEach((worker) => worker.terminate());
|
|
1286
1249
|
if (!ssgOptions["skip-build"]) {
|
|
1287
1250
|
await fs.remove(ssgOut);
|
|
1288
1251
|
}
|
|
@@ -1318,7 +1281,7 @@ async function executeTaskFn(opts) {
|
|
|
1318
1281
|
renderToString,
|
|
1319
1282
|
indexHTML,
|
|
1320
1283
|
onBeforePageRender,
|
|
1321
|
-
|
|
1284
|
+
onDonePageRender,
|
|
1322
1285
|
onPageRendered,
|
|
1323
1286
|
ssrManifest,
|
|
1324
1287
|
rootContainerId,
|
|
@@ -1374,10 +1337,10 @@ async function executeTaskFn(opts) {
|
|
|
1374
1337
|
const filename = dirStyle === "nested" ? join(route.replace(/^\//g, ""), "index.html") : relativeRouteFile;
|
|
1375
1338
|
await fs.ensureDir(join(out, dirname(filename)));
|
|
1376
1339
|
return fs.writeFile(join(out, filename), formatted, "utf-8").then(() => {
|
|
1377
|
-
const outDir = out.replace(process$1.cwd(), "").replace(/^\//, "");
|
|
1378
1340
|
config.logger.info(
|
|
1379
|
-
`${dim(`${
|
|
1341
|
+
`${dim(`${out}/`)}${cyan(filename.padEnd(15, " "))} ${dim(getSize(formatted))}`
|
|
1380
1342
|
);
|
|
1343
|
+
onDonePageRender?.(route, html, appCtx);
|
|
1381
1344
|
return { route, html };
|
|
1382
1345
|
});
|
|
1383
1346
|
} catch (err) {
|