vite-ssg-optimized 0.24.2-optimized.49 → 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/dist/node/cli.cjs +1 -1
- package/dist/node/cli.mjs +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.mjs +1 -1
- package/dist/shared/build.worker.cjs +24 -7
- package/dist/shared/build.worker.mjs +24 -7
- package/dist/shared/{vite-ssg-optimized.0dfc50c9.mjs → vite-ssg-optimized.65f46348.mjs} +4 -0
- package/dist/shared/{vite-ssg-optimized.635b4c57.cjs → vite-ssg-optimized.e58a8d97.cjs} +6 -2
- package/package.json +1 -1
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.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');
|
|
@@ -79,19 +79,29 @@ async function getBeastiesOrCritters(outDir, options = {}) {
|
|
|
79
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)));
|
|
80
80
|
let createAppPromise = void 0;
|
|
81
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
|
+
}
|
|
82
92
|
const execMap = {
|
|
83
93
|
executeTaskFn: async (opts) => {
|
|
84
94
|
const { serverEntry } = opts;
|
|
85
95
|
createAppPromise ?? (createAppPromise = Promise.resolve(format === "esm" ? import(serverEntry) : _require(serverEntry)).then(({ createApp: createApp2 }) => createApp2));
|
|
86
96
|
const createApp = await createAppPromise;
|
|
87
97
|
const beastiesOptions = opts.beastiesOptions;
|
|
88
|
-
beastiesPromise ?? (beastiesPromise = Promise.resolve(beastiesOptions !== false ? getBeastiesOrCritters(outDir, beastiesOptions) : void 0).then((
|
|
89
|
-
if (!
|
|
98
|
+
beastiesPromise ?? (beastiesPromise = Promise.resolve(beastiesOptions !== false ? getBeastiesOrCritters(outDir, beastiesOptions) : void 0).then((beasties2) => {
|
|
99
|
+
if (!beasties2)
|
|
90
100
|
return;
|
|
91
101
|
console.log(`${kolorist.gray("[vite-ssg]")} ${kolorist.blue("Critical CSS generation enabled via `beasties`")}`);
|
|
92
|
-
return
|
|
102
|
+
return beasties2;
|
|
93
103
|
}));
|
|
94
|
-
const
|
|
104
|
+
const beasties = await beastiesPromise;
|
|
95
105
|
const newOpts = {
|
|
96
106
|
...extraOpts,
|
|
97
107
|
out,
|
|
@@ -101,13 +111,20 @@ async function getBeastiesOrCritters(outDir, options = {}) {
|
|
|
101
111
|
onPageRendered,
|
|
102
112
|
onBeforePageRender,
|
|
103
113
|
// onDonePageRender: onDonePageRender,
|
|
104
|
-
beasties
|
|
114
|
+
beasties,
|
|
105
115
|
config: { logger: { info: (msg) => {
|
|
106
116
|
node_worker_threads.parentPort.postMessage({ type: "log", args: [msg] });
|
|
107
117
|
} } },
|
|
108
118
|
...opts
|
|
109
119
|
};
|
|
110
|
-
|
|
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;
|
|
111
128
|
},
|
|
112
129
|
onFinished,
|
|
113
130
|
buildClient: async (...args) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { parentPort, workerData } from 'node:worker_threads';
|
|
3
|
-
import { p as plainify, e as executeTaskFn, a as buildClient, c as buildServer } from './vite-ssg-optimized.
|
|
3
|
+
import { p as plainify, e as executeTaskFn, a as buildClient, c as buildServer } from './vite-ssg-optimized.65f46348.mjs';
|
|
4
4
|
import { red, gray, blue } from 'kolorist';
|
|
5
5
|
import { resolveConfig } from 'vite';
|
|
6
6
|
import 'node:path';
|
|
@@ -76,19 +76,29 @@ async function getBeastiesOrCritters(outDir, options = {}) {
|
|
|
76
76
|
const _require = createRequire(import.meta.url);
|
|
77
77
|
let createAppPromise = void 0;
|
|
78
78
|
let beastiesPromise = void 0;
|
|
79
|
+
function cancelablePromise(promise) {
|
|
80
|
+
let cancel = () => void 0;
|
|
81
|
+
const newPromise = new Promise((resolve, reject) => {
|
|
82
|
+
cancel = () => void reject(new Error("Cancelled"));
|
|
83
|
+
promise.then((result) => {
|
|
84
|
+
resolve(result);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
return Object.assign(newPromise, { cancel });
|
|
88
|
+
}
|
|
79
89
|
const execMap = {
|
|
80
90
|
executeTaskFn: async (opts) => {
|
|
81
91
|
const { serverEntry } = opts;
|
|
82
92
|
createAppPromise ?? (createAppPromise = Promise.resolve(format === "esm" ? import(serverEntry) : _require(serverEntry)).then(({ createApp: createApp2 }) => createApp2));
|
|
83
93
|
const createApp = await createAppPromise;
|
|
84
94
|
const beastiesOptions = opts.beastiesOptions;
|
|
85
|
-
beastiesPromise ?? (beastiesPromise = Promise.resolve(beastiesOptions !== false ? getBeastiesOrCritters(outDir, beastiesOptions) : void 0).then((
|
|
86
|
-
if (!
|
|
95
|
+
beastiesPromise ?? (beastiesPromise = Promise.resolve(beastiesOptions !== false ? getBeastiesOrCritters(outDir, beastiesOptions) : void 0).then((beasties2) => {
|
|
96
|
+
if (!beasties2)
|
|
87
97
|
return;
|
|
88
98
|
console.log(`${gray("[vite-ssg]")} ${blue("Critical CSS generation enabled via `beasties`")}`);
|
|
89
|
-
return
|
|
99
|
+
return beasties2;
|
|
90
100
|
}));
|
|
91
|
-
const
|
|
101
|
+
const beasties = await beastiesPromise;
|
|
92
102
|
const newOpts = {
|
|
93
103
|
...extraOpts,
|
|
94
104
|
out,
|
|
@@ -98,13 +108,20 @@ async function getBeastiesOrCritters(outDir, options = {}) {
|
|
|
98
108
|
onPageRendered,
|
|
99
109
|
onBeforePageRender,
|
|
100
110
|
// onDonePageRender: onDonePageRender,
|
|
101
|
-
beasties
|
|
111
|
+
beasties,
|
|
102
112
|
config: { logger: { info: (msg) => {
|
|
103
113
|
parentPort.postMessage({ type: "log", args: [msg] });
|
|
104
114
|
} } },
|
|
105
115
|
...opts
|
|
106
116
|
};
|
|
107
|
-
|
|
117
|
+
const resultPromise = cancelablePromise(executeTaskFn(newOpts));
|
|
118
|
+
const cancel = async () => {
|
|
119
|
+
resultPromise.cancel();
|
|
120
|
+
};
|
|
121
|
+
process.once("beforeExit", cancel);
|
|
122
|
+
process.once("SIGINT", cancel);
|
|
123
|
+
process.once("SIGTERM", cancel);
|
|
124
|
+
return resultPromise;
|
|
108
125
|
},
|
|
109
126
|
onFinished,
|
|
110
127
|
buildClient: async (...args) => {
|
|
@@ -1184,6 +1184,10 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1184
1184
|
...createProxyOptions,
|
|
1185
1185
|
workerId: "client"
|
|
1186
1186
|
});
|
|
1187
|
+
clientWorker.on("unhandledRejection", (error) => {
|
|
1188
|
+
console.error(error);
|
|
1189
|
+
clientWorker.terminate();
|
|
1190
|
+
});
|
|
1187
1191
|
const cpBuildClient = execInWorker(clientWorker, buildClient, config, viteConfig).finally(() => clientWorker.terminate());
|
|
1188
1192
|
buildPromises.push(cpBuildClient);
|
|
1189
1193
|
}
|
|
@@ -1132,7 +1132,7 @@ async function buildServer(config, viteConfig, { ssrEntry, ssgOut, format, mock
|
|
|
1132
1132
|
}
|
|
1133
1133
|
function createProxy(options) {
|
|
1134
1134
|
const workerExt = options.format === "esm" ? ".mjs" : ".cjs";
|
|
1135
|
-
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.
|
|
1135
|
+
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.e58a8d97.cjs', document.baseURI).href))), {
|
|
1136
1136
|
env: process__default.env,
|
|
1137
1137
|
workerData: options
|
|
1138
1138
|
});
|
|
@@ -1193,6 +1193,10 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1193
1193
|
...createProxyOptions,
|
|
1194
1194
|
workerId: "client"
|
|
1195
1195
|
});
|
|
1196
|
+
clientWorker.on("unhandledRejection", (error) => {
|
|
1197
|
+
console.error(error);
|
|
1198
|
+
clientWorker.terminate();
|
|
1199
|
+
});
|
|
1196
1200
|
const cpBuildClient = execInWorker(clientWorker, buildClient, config, viteConfig).finally(() => clientWorker.terminate());
|
|
1197
1201
|
buildPromises.push(cpBuildClient);
|
|
1198
1202
|
}
|
|
@@ -1257,7 +1261,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1257
1261
|
return worker;
|
|
1258
1262
|
};
|
|
1259
1263
|
const serverEntry = prefix + node_path.join(ssgOut, node_path.parse(ssrEntry).name + ext).replace(/\\/g, "/");
|
|
1260
|
-
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.
|
|
1264
|
+
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.e58a8d97.cjs', document.baseURI).href)));
|
|
1261
1265
|
const { createApp, includedRoutes: serverEntryIncludedRoutes } = format === "esm" ? await import(serverEntry) : _require(serverEntry);
|
|
1262
1266
|
const includedRoutes = serverEntryIncludedRoutes || configIncludedRoutes;
|
|
1263
1267
|
const { routes } = await createApp(false);
|