@moku-labs/web 0.5.0 → 0.5.2
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/index.cjs +15 -10
- package/dist/index.mjs +15 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3339,14 +3339,15 @@ function resolveJsEntrypoints(ctx) {
|
|
|
3339
3339
|
* @param runner - The bundler runner to invoke.
|
|
3340
3340
|
* @param kind - The asset kind label (`"css"` / `"js"`) — used as the cache key.
|
|
3341
3341
|
* @param entrypoints - Resolved entry files (skipped when empty).
|
|
3342
|
-
* @param
|
|
3342
|
+
* @param outDir - The publish root; stored asset paths are made relative to it.
|
|
3343
|
+
* @param outdir - The bundler output directory (`<outDir>/assets`).
|
|
3343
3344
|
* @param minify - Whether to minify.
|
|
3344
3345
|
* @example
|
|
3345
3346
|
* ```ts
|
|
3346
3347
|
* await runOne(ctx, runner, "css", ["a.css"], "dist", true);
|
|
3347
3348
|
* ```
|
|
3348
3349
|
*/
|
|
3349
|
-
async function runOne(ctx, runner, kind, entrypoints, outdir, minify) {
|
|
3350
|
+
async function runOne(ctx, runner, kind, entrypoints, outDir, outdir, minify) {
|
|
3350
3351
|
if (entrypoints.length === 0) return;
|
|
3351
3352
|
const result = await runner({
|
|
3352
3353
|
entrypoints,
|
|
@@ -3355,7 +3356,10 @@ async function runOne(ctx, runner, kind, entrypoints, outdir, minify) {
|
|
|
3355
3356
|
});
|
|
3356
3357
|
if (!result.success) throw new Error(`[web] build.bundle ${kind} build failed`);
|
|
3357
3358
|
const hashed = {};
|
|
3358
|
-
for (const output of result.outputs)
|
|
3359
|
+
for (const output of result.outputs) {
|
|
3360
|
+
const webPath = node_path$1.default.relative(node_path$1.default.resolve(outDir), node_path$1.default.resolve(output.path)).split(node_path$1.default.sep).join("/");
|
|
3361
|
+
hashed[node_path$1.default.basename(output.path)] = webPath;
|
|
3362
|
+
}
|
|
3359
3363
|
ctx.state.buildCache.set(kind, hashed);
|
|
3360
3364
|
ctx.log.debug("build:bundle", {
|
|
3361
3365
|
kind,
|
|
@@ -3380,8 +3384,8 @@ async function bundle(ctx, options = {}) {
|
|
|
3380
3384
|
const { minify, outDir } = ctx.config;
|
|
3381
3385
|
const cssEntrypoints = options.cssEntrypoints ?? resolveEntrypoints(CSS_ENTRY_CANDIDATES);
|
|
3382
3386
|
const jsEntrypoints = options.jsEntrypoints ?? resolveJsEntrypoints(ctx);
|
|
3383
|
-
await runOne(ctx, runner, "css", cssEntrypoints, node_path$1.default.join(outDir, "assets"), minify);
|
|
3384
|
-
await runOne(ctx, runner, "js", jsEntrypoints, node_path$1.default.join(outDir, "assets"), minify);
|
|
3387
|
+
await runOne(ctx, runner, "css", cssEntrypoints, outDir, node_path$1.default.join(outDir, "assets"), minify);
|
|
3388
|
+
await runOne(ctx, runner, "js", jsEntrypoints, outDir, node_path$1.default.join(outDir, "assets"), minify);
|
|
3385
3389
|
}
|
|
3386
3390
|
//#endregion
|
|
3387
3391
|
//#region src/plugins/build/phases/content.ts
|
|
@@ -3607,13 +3611,14 @@ async function expandRedirects(definition, entry, defaultLocale) {
|
|
|
3607
3611
|
const parameterSets = definition._handlers.generate ? await definition._handlers.generate(defaultLocale) : [{}];
|
|
3608
3612
|
const jobs = [];
|
|
3609
3613
|
for (const raw of parameterSets) {
|
|
3610
|
-
const
|
|
3611
|
-
|
|
3614
|
+
const bareParams = { ...raw ?? {} };
|
|
3615
|
+
delete bareParams.lang;
|
|
3616
|
+
const file = entry.toFile(bareParams);
|
|
3612
3617
|
const target = entry.toUrl({
|
|
3613
|
-
...
|
|
3618
|
+
...bareParams,
|
|
3614
3619
|
lang: defaultLocale
|
|
3615
3620
|
});
|
|
3616
|
-
if (target !== entry.toUrl(
|
|
3621
|
+
if (target !== entry.toUrl(bareParams)) jobs.push({
|
|
3617
3622
|
file,
|
|
3618
3623
|
target
|
|
3619
3624
|
});
|
|
@@ -3956,7 +3961,7 @@ async function generateOgImages(ctx, options = {}) {
|
|
|
3956
3961
|
try {
|
|
3957
3962
|
const png = await renderPng(input);
|
|
3958
3963
|
await (0, node_fs_promises.mkdir)(outDir, { recursive: true });
|
|
3959
|
-
await (0, node_fs_promises.writeFile)(node_path.default.join(outDir, `${
|
|
3964
|
+
await (0, node_fs_promises.writeFile)(node_path.default.join(outDir, `${article.computed.slug}.png`), png);
|
|
3960
3965
|
cache.set(key, hash);
|
|
3961
3966
|
rendered += 1;
|
|
3962
3967
|
} finally {
|
package/dist/index.mjs
CHANGED
|
@@ -3326,14 +3326,15 @@ function resolveJsEntrypoints(ctx) {
|
|
|
3326
3326
|
* @param runner - The bundler runner to invoke.
|
|
3327
3327
|
* @param kind - The asset kind label (`"css"` / `"js"`) — used as the cache key.
|
|
3328
3328
|
* @param entrypoints - Resolved entry files (skipped when empty).
|
|
3329
|
-
* @param
|
|
3329
|
+
* @param outDir - The publish root; stored asset paths are made relative to it.
|
|
3330
|
+
* @param outdir - The bundler output directory (`<outDir>/assets`).
|
|
3330
3331
|
* @param minify - Whether to minify.
|
|
3331
3332
|
* @example
|
|
3332
3333
|
* ```ts
|
|
3333
3334
|
* await runOne(ctx, runner, "css", ["a.css"], "dist", true);
|
|
3334
3335
|
* ```
|
|
3335
3336
|
*/
|
|
3336
|
-
async function runOne(ctx, runner, kind, entrypoints, outdir, minify) {
|
|
3337
|
+
async function runOne(ctx, runner, kind, entrypoints, outDir, outdir, minify) {
|
|
3337
3338
|
if (entrypoints.length === 0) return;
|
|
3338
3339
|
const result = await runner({
|
|
3339
3340
|
entrypoints,
|
|
@@ -3342,7 +3343,10 @@ async function runOne(ctx, runner, kind, entrypoints, outdir, minify) {
|
|
|
3342
3343
|
});
|
|
3343
3344
|
if (!result.success) throw new Error(`[web] build.bundle ${kind} build failed`);
|
|
3344
3345
|
const hashed = {};
|
|
3345
|
-
for (const output of result.outputs)
|
|
3346
|
+
for (const output of result.outputs) {
|
|
3347
|
+
const webPath = path.relative(path.resolve(outDir), path.resolve(output.path)).split(path.sep).join("/");
|
|
3348
|
+
hashed[path.basename(output.path)] = webPath;
|
|
3349
|
+
}
|
|
3346
3350
|
ctx.state.buildCache.set(kind, hashed);
|
|
3347
3351
|
ctx.log.debug("build:bundle", {
|
|
3348
3352
|
kind,
|
|
@@ -3367,8 +3371,8 @@ async function bundle(ctx, options = {}) {
|
|
|
3367
3371
|
const { minify, outDir } = ctx.config;
|
|
3368
3372
|
const cssEntrypoints = options.cssEntrypoints ?? resolveEntrypoints(CSS_ENTRY_CANDIDATES);
|
|
3369
3373
|
const jsEntrypoints = options.jsEntrypoints ?? resolveJsEntrypoints(ctx);
|
|
3370
|
-
await runOne(ctx, runner, "css", cssEntrypoints, path.join(outDir, "assets"), minify);
|
|
3371
|
-
await runOne(ctx, runner, "js", jsEntrypoints, path.join(outDir, "assets"), minify);
|
|
3374
|
+
await runOne(ctx, runner, "css", cssEntrypoints, outDir, path.join(outDir, "assets"), minify);
|
|
3375
|
+
await runOne(ctx, runner, "js", jsEntrypoints, outDir, path.join(outDir, "assets"), minify);
|
|
3372
3376
|
}
|
|
3373
3377
|
//#endregion
|
|
3374
3378
|
//#region src/plugins/build/phases/content.ts
|
|
@@ -3594,13 +3598,14 @@ async function expandRedirects(definition, entry, defaultLocale) {
|
|
|
3594
3598
|
const parameterSets = definition._handlers.generate ? await definition._handlers.generate(defaultLocale) : [{}];
|
|
3595
3599
|
const jobs = [];
|
|
3596
3600
|
for (const raw of parameterSets) {
|
|
3597
|
-
const
|
|
3598
|
-
|
|
3601
|
+
const bareParams = { ...raw ?? {} };
|
|
3602
|
+
delete bareParams.lang;
|
|
3603
|
+
const file = entry.toFile(bareParams);
|
|
3599
3604
|
const target = entry.toUrl({
|
|
3600
|
-
...
|
|
3605
|
+
...bareParams,
|
|
3601
3606
|
lang: defaultLocale
|
|
3602
3607
|
});
|
|
3603
|
-
if (target !== entry.toUrl(
|
|
3608
|
+
if (target !== entry.toUrl(bareParams)) jobs.push({
|
|
3604
3609
|
file,
|
|
3605
3610
|
target
|
|
3606
3611
|
});
|
|
@@ -3943,7 +3948,7 @@ async function generateOgImages(ctx, options = {}) {
|
|
|
3943
3948
|
try {
|
|
3944
3949
|
const png = await renderPng(input);
|
|
3945
3950
|
await mkdir(outDir, { recursive: true });
|
|
3946
|
-
await writeFile(path.join(outDir, `${
|
|
3951
|
+
await writeFile(path.join(outDir, `${article.computed.slug}.png`), png);
|
|
3947
3952
|
cache.set(key, hash);
|
|
3948
3953
|
rendered += 1;
|
|
3949
3954
|
} finally {
|
package/package.json
CHANGED