nitropack-nightly 2.13.0-20260107-191028-be316b49 → 2.13.0-20260107-221335-d463e948
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/_chunks/parallel.mjs +30 -0
- package/dist/core/index.mjs +1 -26
- package/dist/meta/index.mjs +1 -1
- package/dist/presets/vercel/utils.mjs +4 -1
- package/dist/rollup/index.mjs +38 -25
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
async function runParallel(inputs, cb, opts) {
|
|
2
|
+
const errors = [];
|
|
3
|
+
const tasks = /* @__PURE__ */ new Set();
|
|
4
|
+
function queueNext() {
|
|
5
|
+
const route = inputs.values().next().value;
|
|
6
|
+
if (!route) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
inputs.delete(route);
|
|
10
|
+
const task = (opts.interval ? new Promise((resolve) => setTimeout(resolve, opts.interval)) : Promise.resolve()).then(() => cb(route)).catch((error) => {
|
|
11
|
+
console.error(error);
|
|
12
|
+
errors.push(error);
|
|
13
|
+
});
|
|
14
|
+
tasks.add(task);
|
|
15
|
+
return task.then(() => {
|
|
16
|
+
tasks.delete(task);
|
|
17
|
+
if (inputs.size > 0) {
|
|
18
|
+
return refillQueue();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function refillQueue() {
|
|
23
|
+
const workers = Math.min(opts.concurrency - tasks.size, inputs.size);
|
|
24
|
+
return Promise.all(Array.from({ length: workers }, () => queueNext()));
|
|
25
|
+
}
|
|
26
|
+
await refillQueue();
|
|
27
|
+
return { errors };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { runParallel as r };
|
package/dist/core/index.mjs
CHANGED
|
@@ -39,6 +39,7 @@ import { generateTypes, resolveSchema } from 'untyped';
|
|
|
39
39
|
import { version } from 'nitropack/meta';
|
|
40
40
|
import { gzipSize } from 'gzip-size';
|
|
41
41
|
import prettyBytes from 'pretty-bytes';
|
|
42
|
+
import { r as runParallel } from '../_chunks/parallel.mjs';
|
|
42
43
|
import { getProperty } from 'dot-prop';
|
|
43
44
|
import zlib from 'node:zlib';
|
|
44
45
|
import { walk, parse } from 'ultrahtml';
|
|
@@ -1521,32 +1522,6 @@ function startRollupWatcher(nitro, rollupConfig) {
|
|
|
1521
1522
|
|
|
1522
1523
|
const presetsWithConfig = ["awsAmplify", "awsLambda", "azure", "cloudflare", "firebase", "netlify", "vercel"];
|
|
1523
1524
|
|
|
1524
|
-
async function runParallel(inputs, cb, opts) {
|
|
1525
|
-
const tasks = /* @__PURE__ */ new Set();
|
|
1526
|
-
function queueNext() {
|
|
1527
|
-
const route = inputs.values().next().value;
|
|
1528
|
-
if (!route) {
|
|
1529
|
-
return;
|
|
1530
|
-
}
|
|
1531
|
-
inputs.delete(route);
|
|
1532
|
-
const task = (opts.interval ? new Promise((resolve) => setTimeout(resolve, opts.interval)) : Promise.resolve()).then(() => cb(route)).catch((error) => {
|
|
1533
|
-
console.error(error);
|
|
1534
|
-
});
|
|
1535
|
-
tasks.add(task);
|
|
1536
|
-
return task.then(() => {
|
|
1537
|
-
tasks.delete(task);
|
|
1538
|
-
if (inputs.size > 0) {
|
|
1539
|
-
return refillQueue();
|
|
1540
|
-
}
|
|
1541
|
-
});
|
|
1542
|
-
}
|
|
1543
|
-
function refillQueue() {
|
|
1544
|
-
const workers = Math.min(opts.concurrency - tasks.size, inputs.size);
|
|
1545
|
-
return Promise.all(Array.from({ length: workers }, () => queueNext()));
|
|
1546
|
-
}
|
|
1547
|
-
await refillQueue();
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
1525
|
async function generateFSTree(dir, options = {}) {
|
|
1551
1526
|
if (isTest) {
|
|
1552
1527
|
return;
|
package/dist/meta/index.mjs
CHANGED
|
@@ -271,11 +271,14 @@ function getObservabilityRoutes(nitro) {
|
|
|
271
271
|
staticRoutes.push(route);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
+
const prerendered = nitro._prerenderedRoutes || [];
|
|
274
275
|
return [
|
|
275
276
|
...normalizeRoutes(staticRoutes),
|
|
276
277
|
...normalizeRoutes(dynamicRoutes),
|
|
277
278
|
...normalizeRoutes(catchAllRoutes)
|
|
278
|
-
]
|
|
279
|
+
].filter((route) => {
|
|
280
|
+
return !prerendered.some((r) => route.src === r.route);
|
|
281
|
+
});
|
|
279
282
|
}
|
|
280
283
|
function normalizeRoutes(routes) {
|
|
281
284
|
return routes.sort(
|
package/dist/rollup/index.mjs
CHANGED
|
@@ -34,6 +34,7 @@ import { readFile } from 'node:fs/promises';
|
|
|
34
34
|
import createEtag from 'etag';
|
|
35
35
|
import mime from 'mime';
|
|
36
36
|
import { withTrailingSlash } from 'ufo';
|
|
37
|
+
import { r as runParallel } from '../_chunks/parallel.mjs';
|
|
37
38
|
import _replace from '@rollup/plugin-replace';
|
|
38
39
|
import { normalizeKey, builtinDrivers } from 'unstorage';
|
|
39
40
|
|
|
@@ -1233,31 +1234,43 @@ function publicAssets(nitro) {
|
|
|
1233
1234
|
absolute: false,
|
|
1234
1235
|
dot: true
|
|
1235
1236
|
});
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
mimeType
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
encoding
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1237
|
+
const { errors } = await runParallel(
|
|
1238
|
+
new Set(files),
|
|
1239
|
+
async (id) => {
|
|
1240
|
+
let mimeType = mime.getType(id.replace(/\.(gz|br)$/, "")) || "text/plain";
|
|
1241
|
+
if (mimeType.startsWith("text")) {
|
|
1242
|
+
mimeType += "; charset=utf-8";
|
|
1243
|
+
}
|
|
1244
|
+
const fullPath = resolve(nitro.options.output.publicDir, id);
|
|
1245
|
+
const [assetData, stat] = await Promise.all([
|
|
1246
|
+
promises.readFile(fullPath),
|
|
1247
|
+
promises.stat(fullPath)
|
|
1248
|
+
]);
|
|
1249
|
+
const etag = createEtag(assetData);
|
|
1250
|
+
const assetId = "/" + decodeURIComponent(id);
|
|
1251
|
+
let encoding;
|
|
1252
|
+
if (id.endsWith(".gz")) {
|
|
1253
|
+
encoding = "gzip";
|
|
1254
|
+
} else if (id.endsWith(".br")) {
|
|
1255
|
+
encoding = "br";
|
|
1256
|
+
}
|
|
1257
|
+
assets[assetId] = {
|
|
1258
|
+
type: nitro._prerenderMeta?.[assetId]?.contentType || mimeType,
|
|
1259
|
+
encoding,
|
|
1260
|
+
etag,
|
|
1261
|
+
mtime: stat.mtime.toJSON(),
|
|
1262
|
+
size: stat.size,
|
|
1263
|
+
path: relative(nitro.options.output.serverDir, fullPath),
|
|
1264
|
+
data: nitro.options.serveStatic === "inline" ? assetData.toString("base64") : void 0
|
|
1265
|
+
};
|
|
1266
|
+
},
|
|
1267
|
+
{ concurrency: 25 }
|
|
1268
|
+
);
|
|
1269
|
+
if (errors.length > 0) {
|
|
1270
|
+
throw new Error(
|
|
1271
|
+
`Failed to process some public assets:
|
|
1272
|
+
- ${errors.map((e) => e instanceof Error ? e.message : String(e)).join("\n- ")}`
|
|
1273
|
+
);
|
|
1261
1274
|
}
|
|
1262
1275
|
for (const key in assets) {
|
|
1263
1276
|
if (/\.(gz|br)$/.test(key)) {
|
package/package.json
CHANGED