@normed/bundle 4.8.4 → 4.8.6
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 +8 -0
- package/bundles/bin/cli.js +19 -40
- package/bundles/bin/cli.js.map +2 -2
- package/bundles/esbuild-plugins/load_pug.d.ts +1 -0
- package/bundles/index.js +19 -40
- package/bundles/index.js.map +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as esbuild from "esbuild";
|
|
2
|
+
export declare function getLinkingAttrs(elementName: string): string[] | undefined;
|
|
2
3
|
export declare function findPackageRoot(filePath: string): string | null;
|
|
3
4
|
/**
|
|
4
5
|
* Resolve an asset path from a pug file, treating "/" as srcWebRoot (not filesystem root).
|
package/bundles/index.js
CHANGED
|
@@ -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
|
|
68801
|
-
|
|
68802
|
-
|
|
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
|
-
|
|
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, options, webRoot, collectedReferences) {
|
|
68949
|
+
async function processHtmlAssets(html, pugFilePath, options, webRoot, collectedReferences = []) {
|
|
68952
68950
|
const assets = [];
|
|
68953
68951
|
const pugReferences = [];
|
|
68954
68952
|
const lessReferences = [];
|
|
@@ -68969,28 +68967,9 @@ async function processHtmlAssets(html, pugFilePath, options, webRoot, collectedR
|
|
|
68969
68967
|
);
|
|
68970
68968
|
const processedAssets = /* @__PURE__ */ new Map();
|
|
68971
68969
|
let modifiedHtml = html;
|
|
68972
|
-
const matches =
|
|
68973
|
-
|
|
68974
|
-
|
|
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
|
|
69385
|
-
if (!
|
|
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 (!
|
|
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
|
|
69439
|
-
if (!
|
|
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 (!
|
|
69421
|
+
if (!linkingAttrs.includes(attr.name)) continue;
|
|
69443
69422
|
const extracted = extractStaticString(attr.val);
|
|
69444
69423
|
if (!extracted) continue;
|
|
69445
69424
|
collectedReferences.push({
|