@normed/bundle 4.3.2 → 4.4.0

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.
@@ -12,4 +12,4 @@ export declare const builders: {
12
12
  copy: Builder;
13
13
  };
14
14
  export declare const defaultBuilders: Builder[];
15
- export declare function getBuilder(builders: Builder[], ext: string): Builder | null;
15
+ export declare function getBuilder(builders: Builder[], ext: string, modifiers?: string[]): Builder | null;
@@ -0,0 +1,11 @@
1
+ import type * as esbuild from "esbuild";
2
+ /**
3
+ * Creates an esbuild plugin that marks URL patterns as external.
4
+ * This is useful for CSS files that reference runtime paths like /fonts/* or /images/*
5
+ * that should not be resolved at build time.
6
+ *
7
+ * @param patterns - Array of URL patterns to mark as external. Supports glob-style wildcards.
8
+ * e.g., ["/fonts/*", "/images/*", "https://*"]
9
+ */
10
+ export declare function createCssExternalUrlsPlugin(patterns: string[]): esbuild.Plugin;
11
+ export default createCssExternalUrlsPlugin;
@@ -1,3 +1,4 @@
1
1
  export { default as load_less } from "./load_less";
2
2
  export { default as load_pug } from "./load_pug";
3
3
  export { default as load_ts_js } from "./load_ts_js";
4
+ export { createCssExternalUrlsPlugin } from "./css_external_urls";
package/bundles/index.js CHANGED
@@ -68651,7 +68651,7 @@ async function copy(from, to) {
68651
68651
  }
68652
68652
  await import_fs_extra2.default.promises.copyFile(from, to);
68653
68653
  }
68654
- var contextModifiers = ["context"];
68654
+ var contextModifiers = ["context", "asset"];
68655
68655
  function __throw__(error) {
68656
68656
  throw error;
68657
68657
  }
@@ -68703,6 +68703,9 @@ var refineEntryConfig = makePartialRefinement({
68703
68703
  import_refinements2.refineString,
68704
68704
  refineESBuildOptions
68705
68705
  )
68706
+ }),
68707
+ css: makePartialRefinement({
68708
+ externalUrls: (0, import_refinements2.refineArrayOf)(import_refinements2.refineString)
68706
68709
  })
68707
68710
  });
68708
68711
  var refinePackageJSONBuildConfig = makePartialRefinement({
@@ -69378,6 +69381,33 @@ var plugin3 = (options) => {
69378
69381
  };
69379
69382
  var load_ts_js_default = plugin3;
69380
69383
 
69384
+ // pnp:/builds/normed/bundle/packages/bundle/src/esbuild-plugins/css_external_urls.ts
69385
+ function createCssExternalUrlsPlugin(patterns) {
69386
+ const name3 = "css-external-urls";
69387
+ const regexPatterns = patterns.map((pattern) => {
69388
+ const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
69389
+ const regexStr = "^" + escaped.replace(/\*/g, ".*") + "$";
69390
+ return new RegExp(regexStr);
69391
+ });
69392
+ return {
69393
+ name: name3,
69394
+ setup(build2) {
69395
+ build2.onResolve({ filter: /.*/ }, (args) => {
69396
+ const path12 = args.path;
69397
+ for (const regex of regexPatterns) {
69398
+ if (regex.test(path12)) {
69399
+ return {
69400
+ path: path12,
69401
+ external: true
69402
+ };
69403
+ }
69404
+ }
69405
+ return void 0;
69406
+ });
69407
+ }
69408
+ };
69409
+ }
69410
+
69381
69411
  // pnp:/builds/normed/bundle/packages/bundle/src/builders/esbuilder.ts
69382
69412
  var import_esbuild_plugin_pnp = __toESM(require_lib15());
69383
69413
  var ts = __toESM(require("typescript"));
@@ -69458,6 +69488,7 @@ var esbuilder = {
69458
69488
  ([k, v]) => `${v.entrypoint.infile.relative} -> ${k}`
69459
69489
  )
69460
69490
  );
69491
+ const externalUrlsPlugin = exampleFile.entryconfig.css?.externalUrls?.length ? createCssExternalUrlsPlugin(exampleFile.entryconfig.css.externalUrls) : null;
69461
69492
  const finalConfig = {
69462
69493
  ...baseConfig,
69463
69494
  plugins: [
@@ -69465,6 +69496,7 @@ var esbuilder = {
69465
69496
  load_less_default,
69466
69497
  load_pug_default,
69467
69498
  load_ts_js_default({ sourceRelativeDirnameFilename: true, basedir: indir }),
69499
+ ...externalUrlsPlugin ? [externalUrlsPlugin] : [],
69468
69500
  (0, import_esbuild_plugin_pnp.pnpPlugin)()
69469
69501
  // if running in yarn/other pnp env
69470
69502
  ],
@@ -69690,7 +69722,10 @@ var builders = {
69690
69722
  copy: copyBuilder
69691
69723
  };
69692
69724
  var defaultBuilders = [builders.es, builders.copy];
69693
- function getBuilder(builders2, ext) {
69725
+ function getBuilder(builders2, ext, modifiers) {
69726
+ if (modifiers?.includes("asset")) {
69727
+ return copyBuilder;
69728
+ }
69694
69729
  for (const builder of builders2) {
69695
69730
  for (const inExt of builder.inExt) {
69696
69731
  if (inExt instanceof RegExp && inExt.test(ext) || inExt === ext) {
@@ -70209,7 +70244,10 @@ var EntryConfigInstance = class _EntryConfigInstance {
70209
70244
  analyse: merged.analyse ?? absurd(),
70210
70245
  tsconfig: merged.typescript?.tsconfig ?? absurd(),
70211
70246
  declarations: merged.typescript?.declarations ?? absurd(),
70212
- esbuild: merged.javascript?.esbuild ?? absurd()
70247
+ esbuild: merged.javascript?.esbuild ?? absurd(),
70248
+ css: {
70249
+ externalUrls: merged.css?.externalUrls ?? []
70250
+ }
70213
70251
  };
70214
70252
  this.completed = complete;
70215
70253
  return complete;
@@ -70279,6 +70317,15 @@ var EntryConfigInstance = class _EntryConfigInstance {
70279
70317
  ...a.javascript?.esbuild,
70280
70318
  ...b.javascript?.esbuild
70281
70319
  }
70320
+ },
70321
+ css: {
70322
+ ...a.css,
70323
+ ...b.css,
70324
+ // Merge external URLs arrays
70325
+ externalUrls: [
70326
+ ...a.css?.externalUrls ?? [],
70327
+ ...b.css?.externalUrls ?? []
70328
+ ]
70282
70329
  }
70283
70330
  };
70284
70331
  }
@@ -70340,7 +70387,11 @@ async function pathToEntrypoint(buildConfig, file, source) {
70340
70387
  `WARN: Determined "${infile.relative}" is not a file, but continuing on as though it is`
70341
70388
  );
70342
70389
  }
70343
- const builder = getBuilder(buildConfig.builders, infile.extension);
70390
+ const builder = getBuilder(
70391
+ buildConfig.builders,
70392
+ infile.extension,
70393
+ infile.modifiers
70394
+ );
70344
70395
  if (!builder) {
70345
70396
  return new NoMatchingBuilder(infile.relative, infile.extension);
70346
70397
  }
@@ -70413,7 +70464,11 @@ async function discoveredEntrypoints(buildConfig) {
70413
70464
  parseModifiers: true,
70414
70465
  supportedModifiers: buildConfig.modifiers
70415
70466
  });
70416
- const builder = getBuilder(buildConfig.builders, infile.extension);
70467
+ const builder = getBuilder(
70468
+ buildConfig.builders,
70469
+ infile.extension,
70470
+ infile.modifiers
70471
+ );
70417
70472
  if (builder === null) {
70418
70473
  return new NoMatchingBuilder(infile.relative, infile.extension);
70419
70474
  }
@@ -70502,6 +70557,10 @@ async function getBuildConfig(options) {
70502
70557
  entrypoint: true,
70503
70558
  extends: "node"
70504
70559
  },
70560
+ asset: {
70561
+ entrypoint: true
70562
+ // No extends - files with .asset modifier are copied verbatim
70563
+ },
70505
70564
  web: {
70506
70565
  entrypoint: true,
70507
70566
  extends: "browser"
@@ -70556,7 +70615,23 @@ async function getBuildConfig(options) {
70556
70615
  sourcemap: "external",
70557
70616
  platform: "neutral",
70558
70617
  loader: {
70559
- // ".pug": "text",
70618
+ // Default loaders for common asset types
70619
+ ".png": "file",
70620
+ ".jpg": "file",
70621
+ ".jpeg": "file",
70622
+ ".gif": "file",
70623
+ ".webp": "file",
70624
+ ".svg": "file",
70625
+ ".ttf": "file",
70626
+ ".otf": "file",
70627
+ ".woff": "file",
70628
+ ".woff2": "file",
70629
+ ".eot": "file",
70630
+ ".ico": "file",
70631
+ ".mp4": "file",
70632
+ ".webm": "file",
70633
+ ".mp3": "file",
70634
+ ".wav": "file"
70560
70635
  },
70561
70636
  minify: false,
70562
70637
  external: [],