guix_mirror_bot pushed a commit to branch javascript-team
in repository guix.

commit 208d0708e0c27a9f74dc7fdb412d73520e680eef
Author: Maxim Cournoyer <[email protected]>
AuthorDate: Thu Jun 11 15:50:48 2026 +0900

    build/node: Preserve field order of modified JSON files.
    
    * guix/build/node-build-system.scm (with-atomic-json-file-replacement): Call
    json->scm with #:ordered #t.
    * tests/node.scm ("modify-json, ordering"): New test.
    ("delete-dev-dependencies/except"): Adjust expected output accordingly.
    
    Change-Id: I9cf0475a7bac0cad8f5fd3d479c50eb35eac3f32
---
 guix/build/node-build-system.scm |  2 +-
 tests/node.scm                   | 13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 5ee4f9a37d..a02f2df26b 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -58,7 +58,7 @@ argument---the result of parsing FILE's contents as 
JSON---and should produce
 a value to be written as JSON to the replacement FILE."
   (with-atomic-file-replacement file
     (lambda (in out)
-      (scm->json (proc (json->scm in)) out #:pretty #t))))
+      (scm->json (proc (json->scm in #:ordered #t)) out #:pretty #t))))
 
 (define* (modify-json #:key (file "package.json") #:rest all-arguments)
   "Provide package.json modifying callbacks such as (delete-dependencies ...)"
diff --git a/tests/node.scm b/tests/node.scm
index 5159d530a1..7328ac91e8 100644
--- a/tests/node.scm
+++ b/tests/node.scm
@@ -76,6 +76,15 @@ It also returns the data as an alist directly."
 
 (test-begin "node related tests")
 
+(test-equal "modify-json, ordering"
+  '(("mkdirp" . ">=1.0.0")
+    ("react" . "^16.8.0"))
+  (assoc-ref (modify-json* (modify-json-fields
+                            '("peerDependencies.react")
+                            (lambda (field-path data key)
+                              data)))
+             "peerDependencies"))
+
 (test-equal "delete-dependencies"
   '(("domelementtype" . "^3.0.0"))
   (assoc-ref (modify-json*
@@ -89,8 +98,8 @@ It also returns the data as an alist directly."
              "dependencies"))
 
 (test-equal "delete-dev-dependencies/except"
-  '(("@types/node" . "^25.9.2")
-    ("typescript" . "^5.9.3"))
+  '(("typescript" . "^5.9.3")
+    ("@types/node" . "^25.9.2"))
   (assoc-ref (modify-json*
               (delete-dev-dependencies/except
                '("typescript" "@types/node")))

Reply via email to