@moku-labs/web 1.8.1 → 1.8.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 CHANGED
@@ -3550,6 +3550,23 @@ const FINGERPRINT_NAMING = {
3550
3550
  asset: "[name]-[hash].[ext]"
3551
3551
  };
3552
3552
  /**
3553
+ * Font url() references the CSS pass leaves EXTERNAL instead of bundling.
3554
+ * Bun's CSS bundler cannot emit url() assets as files — every resolvable
3555
+ * font reference is inlined as a base64 data URI, ballooning the stylesheet
3556
+ * (a site vendoring a font family ships every weight/subset render-blocking
3557
+ * on every page). Marking font extensions external passes the URL through
3558
+ * verbatim, so apps reference fonts root-relative (e.g. `/fonts/x.woff2`)
3559
+ * and serve the files statically via `publicDir`. CSS-only: a font import
3560
+ * left external in JS would be an unresolvable module at runtime.
3561
+ */
3562
+ const CSS_EXTERNAL_FONT_GLOBS = [
3563
+ "*.woff2",
3564
+ "*.woff",
3565
+ "*.ttf",
3566
+ "*.otf",
3567
+ "*.eot"
3568
+ ];
3569
+ /**
3553
3570
  * The default bundler runner — adapts the built-in `Bun.build`.
3554
3571
  *
3555
3572
  * @param options - Entry/outdir/minify/splitting/target/naming settings forwarded to `Bun.build`.
@@ -3562,10 +3579,11 @@ const FINGERPRINT_NAMING = {
3562
3579
  * @param options.naming.entry - Naming template for entry-point outputs.
3563
3580
  * @param options.naming.chunk - Naming template for lazy split chunks.
3564
3581
  * @param options.naming.asset - Naming template for additional emitted assets.
3582
+ * @param options.external - Import/url() globs left unresolved in the output.
3565
3583
  * @returns The structural build result.
3566
3584
  * @example
3567
3585
  * ```ts
3568
- * await defaultRunner({ entrypoints: ["a.css"], outdir: "dist", minify: true, splitting: true, target: "browser", naming: FINGERPRINT_NAMING });
3586
+ * await defaultRunner({ entrypoints: ["a.css"], outdir: "dist", minify: true, splitting: true, target: "browser", naming: FINGERPRINT_NAMING, external: [] });
3569
3587
  * ```
3570
3588
  */
3571
3589
  async function defaultRunner(options) {
@@ -3658,7 +3676,8 @@ async function runOne(ctx, runner, kind, entrypoints, outDir, outdir, minify) {
3658
3676
  minify,
3659
3677
  splitting: true,
3660
3678
  target: "browser",
3661
- naming: FINGERPRINT_NAMING
3679
+ naming: FINGERPRINT_NAMING,
3680
+ external: kind === "css" ? [...CSS_EXTERNAL_FONT_GLOBS] : []
3662
3681
  });
3663
3682
  if (!result.success) throw new Error(`[web] build.bundle ${kind} build failed`);
3664
3683
  const hashed = {};
package/dist/index.mjs CHANGED
@@ -3537,6 +3537,23 @@ const FINGERPRINT_NAMING = {
3537
3537
  asset: "[name]-[hash].[ext]"
3538
3538
  };
3539
3539
  /**
3540
+ * Font url() references the CSS pass leaves EXTERNAL instead of bundling.
3541
+ * Bun's CSS bundler cannot emit url() assets as files — every resolvable
3542
+ * font reference is inlined as a base64 data URI, ballooning the stylesheet
3543
+ * (a site vendoring a font family ships every weight/subset render-blocking
3544
+ * on every page). Marking font extensions external passes the URL through
3545
+ * verbatim, so apps reference fonts root-relative (e.g. `/fonts/x.woff2`)
3546
+ * and serve the files statically via `publicDir`. CSS-only: a font import
3547
+ * left external in JS would be an unresolvable module at runtime.
3548
+ */
3549
+ const CSS_EXTERNAL_FONT_GLOBS = [
3550
+ "*.woff2",
3551
+ "*.woff",
3552
+ "*.ttf",
3553
+ "*.otf",
3554
+ "*.eot"
3555
+ ];
3556
+ /**
3540
3557
  * The default bundler runner — adapts the built-in `Bun.build`.
3541
3558
  *
3542
3559
  * @param options - Entry/outdir/minify/splitting/target/naming settings forwarded to `Bun.build`.
@@ -3549,10 +3566,11 @@ const FINGERPRINT_NAMING = {
3549
3566
  * @param options.naming.entry - Naming template for entry-point outputs.
3550
3567
  * @param options.naming.chunk - Naming template for lazy split chunks.
3551
3568
  * @param options.naming.asset - Naming template for additional emitted assets.
3569
+ * @param options.external - Import/url() globs left unresolved in the output.
3552
3570
  * @returns The structural build result.
3553
3571
  * @example
3554
3572
  * ```ts
3555
- * await defaultRunner({ entrypoints: ["a.css"], outdir: "dist", minify: true, splitting: true, target: "browser", naming: FINGERPRINT_NAMING });
3573
+ * await defaultRunner({ entrypoints: ["a.css"], outdir: "dist", minify: true, splitting: true, target: "browser", naming: FINGERPRINT_NAMING, external: [] });
3556
3574
  * ```
3557
3575
  */
3558
3576
  async function defaultRunner(options) {
@@ -3645,7 +3663,8 @@ async function runOne(ctx, runner, kind, entrypoints, outDir, outdir, minify) {
3645
3663
  minify,
3646
3664
  splitting: true,
3647
3665
  target: "browser",
3648
- naming: FINGERPRINT_NAMING
3666
+ naming: FINGERPRINT_NAMING,
3667
+ external: kind === "css" ? [...CSS_EXTERNAL_FONT_GLOBS] : []
3649
3668
  });
3650
3669
  if (!result.success) throw new Error(`[web] build.bundle ${kind} build failed`);
3651
3670
  const hashed = {};
package/package.json CHANGED
@@ -118,5 +118,5 @@
118
118
  "test:build-e2e": "bun test src/plugins/build/__tests__/e2e/",
119
119
  "test:coverage": "vitest run --project unit --project integration --coverage"
120
120
  },
121
- "version": "1.8.1"
121
+ "version": "1.8.2"
122
122
  }