@normed/bundle 4.8.4 → 4.8.7

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/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
6
6
  2. MINOR version when you add functionality in a backwards compatible manner, and
7
7
  3. PATCH version when you make backwards compatible bug fixes.
8
8
 
9
+ # 4.8.6
10
+
11
+ * PATCH: Fix pug-to-pug auto-discovery failing for `<a href="...pug">` links (and other elements) because the AST-based asset collector only checked a hardcoded element whitelist. Linking attributes (`src`, `srcset`, `href`) are now matched universally on all elements, with element-specific extras (`video[poster]`, `form[action]`, `object[data]`).
12
+
13
+ # 4.8.5
14
+
15
+ * PATCH: Fix asset attribute regex in pug plugin incorrectly matching strings inside inline `<script>` blocks. Asset references are now resolved exclusively from the pug AST (via `createAssetCollectorPlugin`), which is element-aware and only matches attributes on actual asset-bearing elements.
16
+
9
17
  # 4.8.3
10
18
 
11
19
  * PATCH: Add `--short` CLI flag and automatic coding agent detection (`CLAUDECODE`, `CURSOR_AGENT`, `AGENT` env vars) for condensed build output — prints file counts instead of file lists. Respects the `NO_COLOR` convention. Internal warnings in the pug plugin now go through the logger instead of `console.warn`.
@@ -68797,19 +68797,17 @@ function computeContentHash(content) {
68797
68797
  const num = hash.readUInt32BE(0);
68798
68798
  return num.toString(36).toUpperCase().padStart(8, "0").slice(0, 8);
68799
68799
  }
68800
- var ASSET_ATTRIBUTES = {
68801
- img: ["src", "srcset"],
68802
- video: ["src", "poster"],
68803
- audio: ["src"],
68804
- source: ["src", "srcset"],
68805
- link: ["href"],
68806
- script: ["src"],
68800
+ var UNIVERSAL_LINKING_ATTRS = ["src", "srcset", "href"];
68801
+ var ELEMENT_SPECIFIC_LINKING_ATTRS = {
68802
+ form: ["action"],
68807
68803
  object: ["data"],
68808
- embed: ["src"],
68809
- track: ["src"],
68810
- input: ["src"]
68811
- // for type="image"
68804
+ video: ["poster"]
68812
68805
  };
68806
+ function getLinkingAttrs(elementName) {
68807
+ if (!elementName) return void 0;
68808
+ const extra = ELEMENT_SPECIFIC_LINKING_ATTRS[elementName];
68809
+ return extra ? [...UNIVERSAL_LINKING_ATTRS, ...extra] : UNIVERSAL_LINKING_ATTRS;
68810
+ }
68813
68811
  function isRelativeAssetPath(assetPath) {
68814
68812
  if (!assetPath) return false;
68815
68813
  if (assetPath.startsWith("#")) return false;
@@ -68948,7 +68946,7 @@ function computeHtmlAssetPath(opts) {
68948
68946
  }
68949
68947
  return path5.relative(opts.htmlOutputDir, opts.absoluteOutput);
68950
68948
  }
68951
- async function processHtmlAssets(html, pugFilePath, options2, webRoot, collectedReferences) {
68949
+ async function processHtmlAssets(html, pugFilePath, options2, webRoot, collectedReferences = []) {
68952
68950
  const assets = [];
68953
68951
  const pugReferences = [];
68954
68952
  const lessReferences = [];
@@ -68969,28 +68967,9 @@ async function processHtmlAssets(html, pugFilePath, options2, webRoot, collected
68969
68967
  );
68970
68968
  const processedAssets = /* @__PURE__ */ new Map();
68971
68969
  let modifiedHtml = html;
68972
- const matches = [];
68973
- if (collectedReferences && collectedReferences.length > 0) {
68974
- for (const ref of collectedReferences) {
68975
- matches.push({ attr: ref.attr, value: ref.value });
68976
- }
68977
- } else {
68978
- const allAttrs = [...new Set(Object.values(ASSET_ATTRIBUTES).flat())].join(
68979
- "|"
68980
- );
68981
- const attrRegex = new RegExp(
68982
- `(${allAttrs})\\s*=\\s*["']([^"']+)["']`,
68983
- "gi"
68984
- );
68985
- let match;
68986
- while ((match = attrRegex.exec(html)) !== null) {
68987
- const attr = match[1];
68988
- const value = match[2];
68989
- if (attr && value) {
68990
- matches.push({ attr: attr.toLowerCase(), value });
68991
- }
68992
- }
68993
- }
68970
+ const matches = collectedReferences.map(
68971
+ (ref) => ({ attr: ref.attr, value: ref.value })
68972
+ );
68994
68973
  const discoveredPugPaths = /* @__PURE__ */ new Set();
68995
68974
  const discoveredLessPaths = /* @__PURE__ */ new Set();
68996
68975
  const discoveredScriptPaths = /* @__PURE__ */ new Set();
@@ -69381,11 +69360,11 @@ function createRebaseAssetsPlugin(entryFilePath) {
69381
69360
  if (node.nodes) {
69382
69361
  pending.push(...node.nodes);
69383
69362
  }
69384
- const assetAttrs = ASSET_ATTRIBUTES[node.name];
69385
- if (!assetAttrs) continue;
69363
+ const linkingAttrs = getLinkingAttrs(node.name);
69364
+ if (!linkingAttrs) continue;
69386
69365
  if (!node.attrs) continue;
69387
69366
  for (const attr of node.attrs) {
69388
- if (!assetAttrs.includes(attr.name)) continue;
69367
+ if (!linkingAttrs.includes(attr.name)) continue;
69389
69368
  const sourceFile = attr.filename || node.filename;
69390
69369
  if (!sourceFile) continue;
69391
69370
  const sourceDir = path5.dirname(sourceFile);
@@ -69435,11 +69414,11 @@ function createAssetCollectorPlugin(collectedReferences) {
69435
69414
  if (node.nodes) {
69436
69415
  pending.push(...node.nodes);
69437
69416
  }
69438
- const assetAttrs = ASSET_ATTRIBUTES[node.name];
69439
- if (!assetAttrs) continue;
69417
+ const linkingAttrs = getLinkingAttrs(node.name);
69418
+ if (!linkingAttrs) continue;
69440
69419
  if (!node.attrs) continue;
69441
69420
  for (const attr of node.attrs) {
69442
- if (!assetAttrs.includes(attr.name)) continue;
69421
+ if (!linkingAttrs.includes(attr.name)) continue;
69443
69422
  const extracted = extractStaticString(attr.val);
69444
69423
  if (!extracted) continue;
69445
69424
  collectedReferences.push({