vite-ssg-optimized 0.24.2-optimized.3 → 0.24.2-optimized.5
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 +12 -1
- package/dist/shared/build.worker.d.cts +1 -0
- package/dist/shared/build.worker.d.mts +1 -0
- package/dist/shared/build.worker.d.ts +1 -0
- package/dist/shared/build.worker.mjs +12 -1
- package/dist/shared/{vite-ssg-optimized.31f4c9de.cjs → vite-ssg-optimized.46e3caf6.cjs} +10 -7
- package/dist/shared/{vite-ssg-optimized.dc2a4a38.mjs → vite-ssg-optimized.62fed880.mjs} +8 -5
- 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.46e3caf6.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.62fed880.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.46e3caf6.cjs');
|
|
6
6
|
const kolorist = require('kolorist');
|
|
7
7
|
const vite = require('vite');
|
|
8
8
|
require('node:path');
|
|
@@ -14,6 +14,17 @@ require('html5parser');
|
|
|
14
14
|
|
|
15
15
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
16
16
|
(async () => {
|
|
17
|
+
const fnLog = (level = "info", msg) => {
|
|
18
|
+
node_worker_threads.parentPort.postMessage({ type: "log", args: [msg], level });
|
|
19
|
+
};
|
|
20
|
+
globalThis.console = Object.assign(globalThis.console, {
|
|
21
|
+
info: fnLog.bind(globalThis.console, "info"),
|
|
22
|
+
warn: fnLog.bind(globalThis.console, "warn"),
|
|
23
|
+
error: fnLog.bind(globalThis.console, "error"),
|
|
24
|
+
log: fnLog.bind(globalThis.console, "log"),
|
|
25
|
+
trace: fnLog.bind(globalThis.console, "trace"),
|
|
26
|
+
debug: fnLog.bind(globalThis.console, "debug")
|
|
27
|
+
});
|
|
17
28
|
const { serverEntry, out, beastiesOptions, viteConfig, mode, format, dirStyle, ...extraOpts } = node_worker_threads.workerData;
|
|
18
29
|
const nodeEnv = process.env.NODE_ENV || "production";
|
|
19
30
|
const config = await vite.resolveConfig(viteConfig, "build", mode, nodeEnv);
|
|
@@ -1,6 +1,6 @@
|
|
|
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.
|
|
3
|
+
import { g as getBeastiesOrCritters, e as executeTaskFn } from './vite-ssg-optimized.62fed880.mjs';
|
|
4
4
|
import { gray, blue } from 'kolorist';
|
|
5
5
|
import { resolveConfig } from 'vite';
|
|
6
6
|
import 'node:path';
|
|
@@ -11,6 +11,17 @@ import './vite-ssg-optimized.579feabb.mjs';
|
|
|
11
11
|
import 'html5parser';
|
|
12
12
|
|
|
13
13
|
(async () => {
|
|
14
|
+
const fnLog = (level = "info", msg) => {
|
|
15
|
+
parentPort.postMessage({ type: "log", args: [msg], level });
|
|
16
|
+
};
|
|
17
|
+
globalThis.console = Object.assign(globalThis.console, {
|
|
18
|
+
info: fnLog.bind(globalThis.console, "info"),
|
|
19
|
+
warn: fnLog.bind(globalThis.console, "warn"),
|
|
20
|
+
error: fnLog.bind(globalThis.console, "error"),
|
|
21
|
+
log: fnLog.bind(globalThis.console, "log"),
|
|
22
|
+
trace: fnLog.bind(globalThis.console, "trace"),
|
|
23
|
+
debug: fnLog.bind(globalThis.console, "debug")
|
|
24
|
+
});
|
|
14
25
|
const { serverEntry, out, beastiesOptions, viteConfig, mode, format, dirStyle, ...extraOpts } = workerData;
|
|
15
26
|
const nodeEnv = process.env.NODE_ENV || "production";
|
|
16
27
|
const config = await resolveConfig(viteConfig, "build", mode, nodeEnv);
|
|
@@ -1060,8 +1060,8 @@ class BuildWorkerProxy {
|
|
|
1060
1060
|
return;
|
|
1061
1061
|
const fn = console[level]?.bind(console);
|
|
1062
1062
|
let msg = args.map((arg) => typeof arg === "object" && !!arg ? "[object]" : arg).join(" ");
|
|
1063
|
-
|
|
1064
|
-
fn?.(msg);
|
|
1063
|
+
const workerId = options.workerData.workerId;
|
|
1064
|
+
fn?.(`[woker #${workerId}] ${msg}`);
|
|
1065
1065
|
});
|
|
1066
1066
|
this.worker.on("message", (message) => {
|
|
1067
1067
|
const { id, type, result = void 0, error = void 0 } = message;
|
|
@@ -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.46e3caf6.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,9 +1219,11 @@ 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.
|
|
1222
|
+
const createProxy = (index) => {
|
|
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.46e3caf6.cjs', document.baseURI).href))), {
|
|
1224
|
+
env: process__default.env,
|
|
1224
1225
|
workerData: {
|
|
1226
|
+
workerId: index,
|
|
1225
1227
|
serverEntry,
|
|
1226
1228
|
ssrManifest,
|
|
1227
1229
|
format,
|
|
@@ -1240,7 +1242,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1240
1242
|
return workerProxy;
|
|
1241
1243
|
};
|
|
1242
1244
|
const numberOfWorkers = 5;
|
|
1243
|
-
const workers = Array.from({ length: numberOfWorkers }, createProxy);
|
|
1245
|
+
const workers = Array.from({ length: numberOfWorkers }, (_, index) => createProxy(index));
|
|
1244
1246
|
let workerIndex = 0;
|
|
1245
1247
|
for (const route of routesPaths) {
|
|
1246
1248
|
await queue.onSizeLessThan(concurrency + 5);
|
|
@@ -1346,8 +1348,9 @@ async function executeTaskFn(opts) {
|
|
|
1346
1348
|
const filename = dirStyle === "nested" ? node_path.join(route.replace(/^\//g, ""), "index.html") : relativeRouteFile;
|
|
1347
1349
|
await fs__default.ensureDir(node_path.join(out, node_path.dirname(filename)));
|
|
1348
1350
|
return fs__default.writeFile(node_path.join(out, filename), formatted, "utf-8").then(() => {
|
|
1351
|
+
const outDir = out.replace(process__default.cwd(), "").replace(/^\//, "");
|
|
1349
1352
|
config.logger.info(
|
|
1350
|
-
`${kolorist.dim(`${
|
|
1353
|
+
`${kolorist.dim(`${outDir}/`)}${kolorist.cyan(filename.padEnd(15, " "))} ${kolorist.dim(getSize(formatted))}`
|
|
1351
1354
|
);
|
|
1352
1355
|
onDonePageRender?.(route, html, appCtx);
|
|
1353
1356
|
return { route, html };
|
|
@@ -1051,8 +1051,8 @@ class BuildWorkerProxy {
|
|
|
1051
1051
|
return;
|
|
1052
1052
|
const fn = console[level]?.bind(console);
|
|
1053
1053
|
let msg = args.map((arg) => typeof arg === "object" && !!arg ? "[object]" : arg).join(" ");
|
|
1054
|
-
|
|
1055
|
-
fn?.(msg);
|
|
1054
|
+
const workerId = options.workerData.workerId;
|
|
1055
|
+
fn?.(`[woker #${workerId}] ${msg}`);
|
|
1056
1056
|
});
|
|
1057
1057
|
this.worker.on("message", (message) => {
|
|
1058
1058
|
const { id, type, result = void 0, error = void 0 } = message;
|
|
@@ -1210,9 +1210,11 @@ 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 = (index) => {
|
|
1214
1214
|
const workerProxy = new BuildWorkerProxy(new URL(`./build.worker${workerExt}`, import.meta.url), {
|
|
1215
|
+
env: process$1.env,
|
|
1215
1216
|
workerData: {
|
|
1217
|
+
workerId: index,
|
|
1216
1218
|
serverEntry,
|
|
1217
1219
|
ssrManifest,
|
|
1218
1220
|
format,
|
|
@@ -1231,7 +1233,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1231
1233
|
return workerProxy;
|
|
1232
1234
|
};
|
|
1233
1235
|
const numberOfWorkers = 5;
|
|
1234
|
-
const workers = Array.from({ length: numberOfWorkers }, createProxy);
|
|
1236
|
+
const workers = Array.from({ length: numberOfWorkers }, (_, index) => createProxy(index));
|
|
1235
1237
|
let workerIndex = 0;
|
|
1236
1238
|
for (const route of routesPaths) {
|
|
1237
1239
|
await queue.onSizeLessThan(concurrency + 5);
|
|
@@ -1337,8 +1339,9 @@ async function executeTaskFn(opts) {
|
|
|
1337
1339
|
const filename = dirStyle === "nested" ? join(route.replace(/^\//g, ""), "index.html") : relativeRouteFile;
|
|
1338
1340
|
await fs.ensureDir(join(out, dirname(filename)));
|
|
1339
1341
|
return fs.writeFile(join(out, filename), formatted, "utf-8").then(() => {
|
|
1342
|
+
const outDir = out.replace(process$1.cwd(), "").replace(/^\//, "");
|
|
1340
1343
|
config.logger.info(
|
|
1341
|
-
`${dim(`${
|
|
1344
|
+
`${dim(`${outDir}/`)}${cyan(filename.padEnd(15, " "))} ${dim(getSize(formatted))}`
|
|
1342
1345
|
);
|
|
1343
1346
|
onDonePageRender?.(route, html, appCtx);
|
|
1344
1347
|
return { route, html };
|