Jelajahi Sumber

mkpstm: actually unlink duplicate statum.js references during expansion

Duplicate legacy references were counted (for the warning) but left in the tree, so the generic pstm-res rewrite turned each into a live /_statum/resource/statum.js script tag that 404s at runtime. Unlink them alongside the subsumed module tags. Verified with synthetic mixed and module-only pages: a page mixing statum.js with explicit module refs yields exactly the four canonical tags (plus any plain src scripts) and one warning naming the dedupe; a module-only page passes through silent and untouched.
saddle-ClankerSaddle 3 minggu lalu
induk
melakukan
f4b8b9e792
1 mengubah file dengan 7 tambahan dan 4 penghapusan
  1. 7 4
      tools/statum-mkpstm/statum-mkpstm.vala

+ 7 - 4
tools/statum-mkpstm/statum-mkpstm.vala

@@ -472,6 +472,9 @@ namespace Statum.Tools {
                 }
                 node->unlink();
             }
+            foreach (var node in refs.duplicates) {
+                node->unlink();
+            }
             legacy->unlink();
 
             // Exactly one build warning per page, naming the page and the
@@ -482,8 +485,8 @@ namespace Statum.Tools {
             if (subsumed.length > 0) {
                 stderr.printf("; subsumed explicit module tag(s): %s", string.joinv(", ", subsumed));
             }
-            if (refs.duplicates > 0) {
-                stderr.printf("; dropped %d duplicate statum.js reference(s)", refs.duplicates);
+            if (refs.duplicates.length > 0) {
+                stderr.printf("; dropped %d duplicate statum.js reference(s)", refs.duplicates.length);
             }
             stderr.printf("\n");
         }
@@ -505,7 +508,7 @@ namespace Statum.Tools {
                         if (refs.legacy == null) {
                             refs.legacy = node;
                         } else {
-                            refs.duplicates++;
+                            refs.duplicates += node;
                         }
                     } else if (is_client_module((!)res)) {
                         refs.modules += node;
@@ -980,7 +983,7 @@ namespace Statum.Tools {
         private class ClientRefs : Object {
             public Xml.Node* legacy = null;
             public Xml.Node*[] modules = new Xml.Node*[0];
-            public int duplicates = 0;
+            public Xml.Node*[] duplicates = new Xml.Node*[0];
         }
 
         private class VariantData : Object {