@normed/bundle 4.5.5 → 4.5.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 CHANGED
@@ -6,6 +6,10 @@ 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.5.6
10
+
11
+ * PATCH: Fix pug and less file reference paths to be relative to the HTML output location. Previously, paths could be absolute or incorrect when files were in subdirectories. Now paths like `./css/styles.less` are correctly rewritten to `css/styles-hash.css` relative to the HTML file.
12
+
9
13
  # 4.5.5
10
14
 
11
15
  * PATCH: Fix `url()` references in less files referenced from pug templates not being processed. Less files are now built through esbuild's CSS pipeline, which properly resolves `url()` references, copies assets to the output directory, and rewrites paths to hashed filenames.
@@ -69669,22 +69669,26 @@ var ts = __toESM(require("typescript"));
69669
69669
  var import_path8 = __toESM(require("path"));
69670
69670
  var import_fs7 = __toESM(require("fs"));
69671
69671
  import_chalk3.default.level = 3;
69672
- function rewritePugReferencesInHtml(html, pugReferences, pugToOutputPath) {
69672
+ function rewritePugReferencesInHtml(html, pugReferences, pugToOutputPath, htmlOutputDir, outdir) {
69673
69673
  let result = html;
69674
69674
  for (const ref of pugReferences) {
69675
69675
  const outputPath = pugToOutputPath.get(ref.absolutePath);
69676
69676
  if (outputPath) {
69677
- result = result.split(ref.originalHref).join(outputPath);
69677
+ const absoluteOutputPath = import_path8.default.join(outdir, outputPath);
69678
+ const relativePath = import_path8.default.relative(htmlOutputDir, absoluteOutputPath);
69679
+ result = result.split(ref.originalHref).join(relativePath);
69678
69680
  }
69679
69681
  }
69680
69682
  return result;
69681
69683
  }
69682
- function rewriteLessReferencesInHtml(html, lessReferences, lessToOutputPath) {
69684
+ function rewriteLessReferencesInHtml(html, lessReferences, lessToOutputPath, htmlOutputDir, outdir) {
69683
69685
  let result = html;
69684
69686
  for (const ref of lessReferences) {
69685
69687
  const outputPath = lessToOutputPath.get(ref.absolutePath);
69686
69688
  if (outputPath) {
69687
- result = result.split(ref.originalHref).join(outputPath);
69689
+ const absoluteOutputPath = import_path8.default.join(outdir, outputPath);
69690
+ const relativePath = import_path8.default.relative(htmlOutputDir, absoluteOutputPath);
69691
+ result = result.split(ref.originalHref).join(relativePath);
69688
69692
  }
69689
69693
  }
69690
69694
  return result;
@@ -69998,7 +70002,7 @@ var esbuilder = {
69998
70002
  );
69999
70003
  for (const lessSourcePath of newEntryPoints) {
70000
70004
  processedLessFiles.add(lessSourcePath);
70001
- const entryNames = finalConfig.assetNames?.replace("[ext]", "") || "[name]-[hash]";
70005
+ const entryNames = finalConfig.assetNames?.replace("[ext]", "") || "[dir]/[name]-[hash]";
70002
70006
  const lessConfig = {
70003
70007
  ...finalConfig,
70004
70008
  entryPoints: [lessSourcePath],
@@ -70025,18 +70029,23 @@ var esbuilder = {
70025
70029
  const htmlWriters = [];
70026
70030
  for (const [_sourcePath, output] of pugHtmlOutputs.entries()) {
70027
70031
  let html = output.content;
70032
+ const htmlOutputDir = import_path8.default.dirname(output.outputPath);
70028
70033
  if (output.pugReferences.length > 0) {
70029
70034
  html = rewritePugReferencesInHtml(
70030
70035
  html,
70031
70036
  output.pugReferences,
70032
- pugToOutputPath
70037
+ pugToOutputPath,
70038
+ htmlOutputDir,
70039
+ outdir
70033
70040
  );
70034
70041
  }
70035
70042
  if (output.lessReferences.length > 0) {
70036
70043
  html = rewriteLessReferencesInHtml(
70037
70044
  html,
70038
70045
  output.lessReferences,
70039
- lessToOutputPath
70046
+ lessToOutputPath,
70047
+ htmlOutputDir,
70048
+ outdir
70040
70049
  );
70041
70050
  }
70042
70051
  const promise = fileWriter.writeFile(output.outputPath, html, {