vite-ssg-optimized 0.24.2-optimized.5 → 0.24.2-optimized.50
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 +32 -1
- package/dist/client/single-page.cjs +1 -1
- 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/client/single-page.mjs +2 -2
- package/dist/index.cjs +20 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +22 -5
- 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 +8 -3
- package/dist/node.d.mts +8 -3
- package/dist/node.d.ts +8 -3
- package/dist/node.mjs +1 -1
- package/dist/shared/build.worker.cjs +99 -18
- package/dist/shared/build.worker.d.cts +4 -14
- package/dist/shared/build.worker.d.mts +4 -14
- package/dist/shared/build.worker.d.ts +4 -14
- package/dist/shared/build.worker.mjs +100 -19
- package/dist/shared/{vite-ssg-optimized.cf5cb4ee.d.cts → vite-ssg-optimized.341e382e.d.cts} +6 -1
- package/dist/shared/{vite-ssg-optimized.cf5cb4ee.d.mts → vite-ssg-optimized.341e382e.d.mts} +6 -1
- package/dist/shared/{vite-ssg-optimized.cf5cb4ee.d.ts → vite-ssg-optimized.341e382e.d.ts} +6 -1
- package/dist/shared/{vite-ssg-optimized.62fed880.mjs → vite-ssg-optimized.65f46348.mjs} +198 -87
- package/dist/shared/{vite-ssg-optimized.46e3caf6.cjs → vite-ssg-optimized.e58a8d97.cjs} +200 -87
- package/package.json +1 -1
- package/dist/shared/vite-ssg-optimized.12fd9d22.d.cts +0 -9
- package/dist/shared/vite-ssg-optimized.892682c8.d.mts +0 -9
- package/dist/shared/vite-ssg-optimized.950926bc.d.ts +0 -9
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Vite SSG
|
|
1
|
+
# Vite SSG Optimized
|
|
2
2
|
|
|
3
3
|
Static-site generation for Vue 3 on Vite.
|
|
4
4
|
|
|
@@ -6,6 +6,37 @@ 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
|
+
|
|
9
40
|
## Install
|
|
10
41
|
|
|
11
42
|
> **This library requires Node.js version >= 14**
|
|
@@ -17,7 +17,7 @@ function ViteSSG(App, fn, options = {}) {
|
|
|
17
17
|
const app = client ? vue.createApp(App) : vue.createSSRApp(App);
|
|
18
18
|
let head;
|
|
19
19
|
if (useHead) {
|
|
20
|
-
head =
|
|
20
|
+
head = vue$1.createHead();
|
|
21
21
|
app.use(head);
|
|
22
22
|
}
|
|
23
23
|
const appRenderCallbacks = [];
|
|
@@ -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.341e382e.cjs';
|
|
3
|
+
export { R as RouterOptions, b as ViteSSGOptions } from '../shared/vite-ssg-optimized.341e382e.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.341e382e.mjs';
|
|
3
|
+
export { R as RouterOptions, b as ViteSSGOptions } from '../shared/vite-ssg-optimized.341e382e.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.341e382e.js';
|
|
3
|
+
export { R as RouterOptions, b as ViteSSGOptions } from '../shared/vite-ssg-optimized.341e382e.js';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHead
|
|
1
|
+
import { createHead } from '@unhead/vue';
|
|
2
2
|
import { createApp, createSSRApp } from 'vue';
|
|
3
3
|
import { C as ClientOnly, d as documentReady } from '../shared/vite-ssg-optimized.5912142e.mjs';
|
|
4
4
|
import { d as deserializeState } from '../shared/vite-ssg-optimized.579feabb.mjs';
|
|
@@ -15,7 +15,7 @@ function ViteSSG(App, fn, options = {}) {
|
|
|
15
15
|
const app = client ? createApp(App) : createSSRApp(App);
|
|
16
16
|
let head;
|
|
17
17
|
if (useHead) {
|
|
18
|
-
head =
|
|
18
|
+
head = createHead();
|
|
19
19
|
app.use(head);
|
|
20
20
|
}
|
|
21
21
|
const appRenderCallbacks = [];
|
package/dist/index.cjs
CHANGED
|
@@ -14,12 +14,29 @@ function ViteSSG(App, routerOptions, fn, options = {}) {
|
|
|
14
14
|
rootContainer = "#app"
|
|
15
15
|
} = options;
|
|
16
16
|
const isClient = typeof window !== "undefined";
|
|
17
|
+
async function detectHydrationMode() {
|
|
18
|
+
if (!isClient)
|
|
19
|
+
return false;
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
let timeout = void 0;
|
|
22
|
+
const fnResolve = () => {
|
|
23
|
+
if (document.readyState !== "loading") {
|
|
24
|
+
document.removeEventListener("readystatechange", fnResolve);
|
|
25
|
+
clearTimeout(timeout);
|
|
26
|
+
resolve(document.querySelectorAll("[data-server-rendered]").length > 0);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
timeout = setTimeout(fnResolve, 1e3);
|
|
30
|
+
document.addEventListener("readystatechange", fnResolve);
|
|
31
|
+
fnResolve();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
17
34
|
async function createApp(client = false, routePath) {
|
|
18
|
-
const isHydrationMode =
|
|
19
|
-
const app =
|
|
35
|
+
const isHydrationMode = await detectHydrationMode();
|
|
36
|
+
const app = isHydrationMode ? vue.createSSRApp(App) : vue.createApp(App);
|
|
20
37
|
let head;
|
|
21
38
|
if (useHead) {
|
|
22
|
-
head =
|
|
39
|
+
head = vue$1.createHead();
|
|
23
40
|
app.use(head);
|
|
24
41
|
}
|
|
25
42
|
const router = vueRouter.createRouter({
|
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.341e382e.cjs';
|
|
3
|
+
export { b as ViteSSGOptions } from './shared/vite-ssg-optimized.341e382e.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.341e382e.mjs';
|
|
3
|
+
export { b as ViteSSGOptions } from './shared/vite-ssg-optimized.341e382e.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.341e382e.js';
|
|
3
|
+
export { b as ViteSSGOptions } from './shared/vite-ssg-optimized.341e382e.js';
|
|
4
4
|
import '@unhead/vue';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'critters';
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createHead
|
|
2
|
-
import {
|
|
1
|
+
import { createHead } from '@unhead/vue';
|
|
2
|
+
import { createSSRApp, createApp } from 'vue';
|
|
3
3
|
import { createRouter, createWebHistory, createMemoryHistory } from 'vue-router';
|
|
4
4
|
import { C as ClientOnly, d as documentReady } from './shared/vite-ssg-optimized.5912142e.mjs';
|
|
5
5
|
import { d as deserializeState } from './shared/vite-ssg-optimized.579feabb.mjs';
|
|
@@ -12,12 +12,29 @@ function ViteSSG(App, routerOptions, fn, options = {}) {
|
|
|
12
12
|
rootContainer = "#app"
|
|
13
13
|
} = options;
|
|
14
14
|
const isClient = typeof window !== "undefined";
|
|
15
|
+
async function detectHydrationMode() {
|
|
16
|
+
if (!isClient)
|
|
17
|
+
return false;
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
|
+
let timeout = void 0;
|
|
20
|
+
const fnResolve = () => {
|
|
21
|
+
if (document.readyState !== "loading") {
|
|
22
|
+
document.removeEventListener("readystatechange", fnResolve);
|
|
23
|
+
clearTimeout(timeout);
|
|
24
|
+
resolve(document.querySelectorAll("[data-server-rendered]").length > 0);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
timeout = setTimeout(fnResolve, 1e3);
|
|
28
|
+
document.addEventListener("readystatechange", fnResolve);
|
|
29
|
+
fnResolve();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
15
32
|
async function createApp$1(client = false, routePath) {
|
|
16
|
-
const isHydrationMode =
|
|
17
|
-
const app =
|
|
33
|
+
const isHydrationMode = await detectHydrationMode();
|
|
34
|
+
const app = isHydrationMode ? createSSRApp(App) : createApp(App);
|
|
18
35
|
let head;
|
|
19
36
|
if (useHead) {
|
|
20
|
-
head =
|
|
37
|
+
head = createHead();
|
|
21
38
|
app.use(head);
|
|
22
39
|
}
|
|
23
40
|
const router = createRouter({
|
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.e58a8d97.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.65f46348.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,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import 'vite';
|
|
3
|
-
import './shared/vite-ssg-optimized.cf5cb4ee.cjs';
|
|
1
|
+
import { InlineConfig } from 'vite';
|
|
2
|
+
import { b as ViteSSGOptions } from './shared/vite-ssg-optimized.341e382e.cjs';
|
|
4
3
|
import '@unhead/vue';
|
|
5
4
|
import 'beasties';
|
|
6
5
|
import 'critters';
|
|
7
6
|
import 'vue';
|
|
8
7
|
import 'vue-router';
|
|
9
8
|
import 'html-minifier-terser';
|
|
9
|
+
|
|
10
|
+
declare function build(ssgOptions?: Partial<ViteSSGOptions & {
|
|
11
|
+
'skip-build'?: boolean;
|
|
12
|
+
}>, viteConfig?: InlineConfig): Promise<void>;
|
|
13
|
+
|
|
14
|
+
export { build };
|
package/dist/node.d.mts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import 'vite';
|
|
3
|
-
import './shared/vite-ssg-optimized.cf5cb4ee.mjs';
|
|
1
|
+
import { InlineConfig } from 'vite';
|
|
2
|
+
import { b as ViteSSGOptions } from './shared/vite-ssg-optimized.341e382e.mjs';
|
|
4
3
|
import '@unhead/vue';
|
|
5
4
|
import 'beasties';
|
|
6
5
|
import 'critters';
|
|
7
6
|
import 'vue';
|
|
8
7
|
import 'vue-router';
|
|
9
8
|
import 'html-minifier-terser';
|
|
9
|
+
|
|
10
|
+
declare function build(ssgOptions?: Partial<ViteSSGOptions & {
|
|
11
|
+
'skip-build'?: boolean;
|
|
12
|
+
}>, viteConfig?: InlineConfig): Promise<void>;
|
|
13
|
+
|
|
14
|
+
export { build };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import 'vite';
|
|
3
|
-
import './shared/vite-ssg-optimized.cf5cb4ee.js';
|
|
1
|
+
import { InlineConfig } from 'vite';
|
|
2
|
+
import { b as ViteSSGOptions } from './shared/vite-ssg-optimized.341e382e.js';
|
|
4
3
|
import '@unhead/vue';
|
|
5
4
|
import 'beasties';
|
|
6
5
|
import 'critters';
|
|
7
6
|
import 'vue';
|
|
8
7
|
import 'vue-router';
|
|
9
8
|
import 'html-minifier-terser';
|
|
9
|
+
|
|
10
|
+
declare function build(ssgOptions?: Partial<ViteSSGOptions & {
|
|
11
|
+
'skip-build'?: boolean;
|
|
12
|
+
}>, viteConfig?: InlineConfig): Promise<void>;
|
|
13
|
+
|
|
14
|
+
export { build };
|
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.e58a8d97.cjs');
|
|
6
6
|
const kolorist = require('kolorist');
|
|
7
7
|
const vite = require('vite');
|
|
8
8
|
require('node:path');
|
|
@@ -13,9 +13,39 @@ require('./vite-ssg-optimized.bee8a5a9.cjs');
|
|
|
13
13
|
require('html5parser');
|
|
14
14
|
|
|
15
15
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
16
|
+
async function getBeastiesOrCritters(outDir, options = {}) {
|
|
17
|
+
try {
|
|
18
|
+
const BeastiesClass = (await import('beasties')).default;
|
|
19
|
+
return new BeastiesClass({
|
|
20
|
+
path: outDir,
|
|
21
|
+
logLevel: "warn",
|
|
22
|
+
external: true,
|
|
23
|
+
inlineFonts: true,
|
|
24
|
+
preloadFonts: true,
|
|
25
|
+
...options
|
|
26
|
+
});
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const CrittersClass = (await import('critters')).default;
|
|
31
|
+
console.warn("`critters` is deprecated. Please use `beasties` instead.");
|
|
32
|
+
return new CrittersClass({
|
|
33
|
+
path: outDir,
|
|
34
|
+
logLevel: "warn",
|
|
35
|
+
external: true,
|
|
36
|
+
inlineFonts: true,
|
|
37
|
+
preloadFonts: true,
|
|
38
|
+
...options
|
|
39
|
+
});
|
|
40
|
+
} catch {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
16
45
|
(async () => {
|
|
17
|
-
const fnLog = (level = "info", msg) => {
|
|
18
|
-
|
|
46
|
+
const fnLog = (level = "info", ...msg) => {
|
|
47
|
+
const newMsg = msg.map(node.plainify);
|
|
48
|
+
node_worker_threads.parentPort.postMessage({ type: "log", args: newMsg, level });
|
|
19
49
|
};
|
|
20
50
|
globalThis.console = Object.assign(globalThis.console, {
|
|
21
51
|
info: fnLog.bind(globalThis.console, "info"),
|
|
@@ -25,23 +55,53 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
|
|
|
25
55
|
trace: fnLog.bind(globalThis.console, "trace"),
|
|
26
56
|
debug: fnLog.bind(globalThis.console, "debug")
|
|
27
57
|
});
|
|
28
|
-
const
|
|
58
|
+
const noop = () => void 0;
|
|
59
|
+
const proccessInjections = {
|
|
60
|
+
clearLine: noop,
|
|
61
|
+
cursorTo: noop,
|
|
62
|
+
clearScreenDown: noop,
|
|
63
|
+
moveCursor: noop,
|
|
64
|
+
isTTY: false
|
|
65
|
+
};
|
|
66
|
+
Object.assign(process.stdout, proccessInjections);
|
|
67
|
+
Object.assign(process.stderr, proccessInjections);
|
|
68
|
+
const { format, out, dirStyle, viteConfig, mode, ...extraOpts } = node_worker_threads.workerData;
|
|
29
69
|
const nodeEnv = process.env.NODE_ENV || "production";
|
|
30
70
|
const config = await vite.resolveConfig(viteConfig, "build", mode, nodeEnv);
|
|
31
71
|
const {
|
|
32
72
|
onPageRendered,
|
|
33
73
|
onBeforePageRender,
|
|
34
|
-
onDonePageRender
|
|
74
|
+
// onDonePageRender,
|
|
75
|
+
onFinished
|
|
35
76
|
} = config.ssgOptions || {};
|
|
36
77
|
const { renderToString } = await import('vue/server-renderer');
|
|
37
78
|
const outDir = out.replace(process.cwd(), "").replace(/^\//g, "");
|
|
38
79
|
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/build.worker.cjs', document.baseURI).href)));
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
80
|
+
let createAppPromise = void 0;
|
|
81
|
+
let beastiesPromise = void 0;
|
|
82
|
+
function cancelablePromise(promise) {
|
|
83
|
+
let cancel = () => void 0;
|
|
84
|
+
const newPromise = new Promise((resolve, reject) => {
|
|
85
|
+
cancel = () => void reject(new Error("Cancelled"));
|
|
86
|
+
promise.then((result) => {
|
|
87
|
+
resolve(result);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
return Object.assign(newPromise, { cancel });
|
|
91
|
+
}
|
|
43
92
|
const execMap = {
|
|
44
93
|
executeTaskFn: async (opts) => {
|
|
94
|
+
const { serverEntry } = opts;
|
|
95
|
+
createAppPromise ?? (createAppPromise = Promise.resolve(format === "esm" ? import(serverEntry) : _require(serverEntry)).then(({ createApp: createApp2 }) => createApp2));
|
|
96
|
+
const createApp = await createAppPromise;
|
|
97
|
+
const beastiesOptions = opts.beastiesOptions;
|
|
98
|
+
beastiesPromise ?? (beastiesPromise = Promise.resolve(beastiesOptions !== false ? getBeastiesOrCritters(outDir, beastiesOptions) : void 0).then((beasties2) => {
|
|
99
|
+
if (!beasties2)
|
|
100
|
+
return;
|
|
101
|
+
console.log(`${kolorist.gray("[vite-ssg]")} ${kolorist.blue("Critical CSS generation enabled via `beasties`")}`);
|
|
102
|
+
return beasties2;
|
|
103
|
+
}));
|
|
104
|
+
const beasties = await beastiesPromise;
|
|
45
105
|
const newOpts = {
|
|
46
106
|
...extraOpts,
|
|
47
107
|
out,
|
|
@@ -50,14 +110,34 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
|
|
|
50
110
|
renderToString,
|
|
51
111
|
onPageRendered,
|
|
52
112
|
onBeforePageRender,
|
|
53
|
-
onDonePageRender,
|
|
113
|
+
// onDonePageRender: onDonePageRender,
|
|
54
114
|
beasties,
|
|
55
115
|
config: { logger: { info: (msg) => {
|
|
56
116
|
node_worker_threads.parentPort.postMessage({ type: "log", args: [msg] });
|
|
57
117
|
} } },
|
|
58
118
|
...opts
|
|
59
119
|
};
|
|
60
|
-
|
|
120
|
+
const resultPromise = cancelablePromise(node.executeTaskFn(newOpts));
|
|
121
|
+
const cancel = async () => {
|
|
122
|
+
resultPromise.cancel();
|
|
123
|
+
};
|
|
124
|
+
process.once("beforeExit", cancel);
|
|
125
|
+
process.once("SIGINT", cancel);
|
|
126
|
+
process.once("SIGTERM", cancel);
|
|
127
|
+
return resultPromise;
|
|
128
|
+
},
|
|
129
|
+
onFinished,
|
|
130
|
+
buildClient: async (...args) => {
|
|
131
|
+
let [_config, _viteConfig] = args;
|
|
132
|
+
_config = Object.assign({}, config, _config);
|
|
133
|
+
_viteConfig = Object.assign({}, viteConfig, _viteConfig);
|
|
134
|
+
return await node.buildClient(_config, _viteConfig);
|
|
135
|
+
},
|
|
136
|
+
buildServer: async (...args) => {
|
|
137
|
+
let [_config, _viteConfig, _opts] = args;
|
|
138
|
+
_config = Object.assign({}, config, _config);
|
|
139
|
+
_viteConfig = Object.assign({}, viteConfig, _viteConfig);
|
|
140
|
+
return await node.buildServer(_config, _viteConfig, _opts);
|
|
61
141
|
}
|
|
62
142
|
};
|
|
63
143
|
node_worker_threads.parentPort?.on("message", async (message) => {
|
|
@@ -65,15 +145,16 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
|
|
|
65
145
|
if (type in execMap) {
|
|
66
146
|
node_worker_threads.parentPort.postMessage(`running ${type}`);
|
|
67
147
|
try {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Object.assign(result, {
|
|
71
|
-
appCtx: result.appCtx.router.push(result.route)
|
|
72
|
-
});
|
|
73
|
-
}
|
|
148
|
+
let result = await execMap[type](...args ?? []);
|
|
149
|
+
result = node.plainify(result);
|
|
74
150
|
node_worker_threads.parentPort.postMessage({ type: "result", id, result });
|
|
75
151
|
} catch (e) {
|
|
76
|
-
|
|
152
|
+
const message2 = e.message || e.toString();
|
|
153
|
+
const stack = e.stack || "";
|
|
154
|
+
const error = { message: message2, stack };
|
|
155
|
+
process.stderr.write(`${kolorist.red("[vite-ssg-worker]")} ${message2} ${stack}
|
|
156
|
+
`);
|
|
157
|
+
node_worker_threads.parentPort.postMessage({ type: "error", id, error });
|
|
77
158
|
}
|
|
78
159
|
}
|
|
79
160
|
});
|
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ViteSSGOptions } from 'vite-ssg';
|
|
3
|
-
import { Options } from 'beasties';
|
|
4
|
-
import { Options as Options$1 } from 'html-minifier-terser';
|
|
5
|
-
import 'vite';
|
|
6
|
-
import './vite-ssg-optimized.cf5cb4ee.cjs';
|
|
1
|
+
import { b as ViteSSGOptions } from './vite-ssg-optimized.341e382e.cjs';
|
|
7
2
|
import '@unhead/vue';
|
|
3
|
+
import 'beasties';
|
|
8
4
|
import 'critters';
|
|
9
5
|
import 'vue';
|
|
10
6
|
import 'vue-router';
|
|
7
|
+
import 'html-minifier-terser';
|
|
11
8
|
|
|
12
9
|
interface WorkerDataEntry {
|
|
13
|
-
serverEntry: string;
|
|
14
10
|
workerId: number | string;
|
|
15
11
|
format: 'esm' | 'cjs';
|
|
16
12
|
out: string;
|
|
17
13
|
dirStyle: ViteSSGOptions['dirStyle'];
|
|
18
|
-
beastiesOptions: Options | false;
|
|
19
14
|
mode?: string;
|
|
20
|
-
ssrManifest: Manifest;
|
|
21
|
-
indexHTML: string;
|
|
22
|
-
rootContainerId: string;
|
|
23
|
-
formatting: ViteSSGOptions['formatting'];
|
|
24
|
-
minifyOptions: Options$1;
|
|
25
15
|
viteConfig: {
|
|
26
|
-
configFile
|
|
16
|
+
configFile?: string;
|
|
27
17
|
};
|
|
28
18
|
}
|
|
29
19
|
|
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ViteSSGOptions } from 'vite-ssg';
|
|
3
|
-
import { Options } from 'beasties';
|
|
4
|
-
import { Options as Options$1 } from 'html-minifier-terser';
|
|
5
|
-
import 'vite';
|
|
6
|
-
import './vite-ssg-optimized.cf5cb4ee.mjs';
|
|
1
|
+
import { b as ViteSSGOptions } from './vite-ssg-optimized.341e382e.mjs';
|
|
7
2
|
import '@unhead/vue';
|
|
3
|
+
import 'beasties';
|
|
8
4
|
import 'critters';
|
|
9
5
|
import 'vue';
|
|
10
6
|
import 'vue-router';
|
|
7
|
+
import 'html-minifier-terser';
|
|
11
8
|
|
|
12
9
|
interface WorkerDataEntry {
|
|
13
|
-
serverEntry: string;
|
|
14
10
|
workerId: number | string;
|
|
15
11
|
format: 'esm' | 'cjs';
|
|
16
12
|
out: string;
|
|
17
13
|
dirStyle: ViteSSGOptions['dirStyle'];
|
|
18
|
-
beastiesOptions: Options | false;
|
|
19
14
|
mode?: string;
|
|
20
|
-
ssrManifest: Manifest;
|
|
21
|
-
indexHTML: string;
|
|
22
|
-
rootContainerId: string;
|
|
23
|
-
formatting: ViteSSGOptions['formatting'];
|
|
24
|
-
minifyOptions: Options$1;
|
|
25
15
|
viteConfig: {
|
|
26
|
-
configFile
|
|
16
|
+
configFile?: string;
|
|
27
17
|
};
|
|
28
18
|
}
|
|
29
19
|
|
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ViteSSGOptions } from 'vite-ssg';
|
|
3
|
-
import { Options } from 'beasties';
|
|
4
|
-
import { Options as Options$1 } from 'html-minifier-terser';
|
|
5
|
-
import 'vite';
|
|
6
|
-
import './vite-ssg-optimized.cf5cb4ee.js';
|
|
1
|
+
import { b as ViteSSGOptions } from './vite-ssg-optimized.341e382e.js';
|
|
7
2
|
import '@unhead/vue';
|
|
3
|
+
import 'beasties';
|
|
8
4
|
import 'critters';
|
|
9
5
|
import 'vue';
|
|
10
6
|
import 'vue-router';
|
|
7
|
+
import 'html-minifier-terser';
|
|
11
8
|
|
|
12
9
|
interface WorkerDataEntry {
|
|
13
|
-
serverEntry: string;
|
|
14
10
|
workerId: number | string;
|
|
15
11
|
format: 'esm' | 'cjs';
|
|
16
12
|
out: string;
|
|
17
13
|
dirStyle: ViteSSGOptions['dirStyle'];
|
|
18
|
-
beastiesOptions: Options | false;
|
|
19
14
|
mode?: string;
|
|
20
|
-
ssrManifest: Manifest;
|
|
21
|
-
indexHTML: string;
|
|
22
|
-
rootContainerId: string;
|
|
23
|
-
formatting: ViteSSGOptions['formatting'];
|
|
24
|
-
minifyOptions: Options$1;
|
|
25
15
|
viteConfig: {
|
|
26
|
-
configFile
|
|
16
|
+
configFile?: string;
|
|
27
17
|
};
|
|
28
18
|
}
|
|
29
19
|
|