guix_mirror_bot pushed a commit to branch master
in repository guix.

commit 9d3861b8904bc73e7290ad8412d6e667b9d0b35a
Author: Maxim Cournoyer <[email protected]>
AuthorDate: Sun Jun 7 16:08:09 2026 +0900

    import: npm-binary: Simplify deletion of development dependencies.
    
    * guix/build/node-build-system.scm (delete-dev-dependencies): Include
    peerDependencies as well.
    * guix/import/npm-binary.scm (npm-package->package-sexp): Use it to delete 
all
    development dependencies, instead of listing them.
    * doc/guix.texi (Invoking guix import): Document this special treatment.
    
    Change-Id: I97b20aa59db67dc0297e0514e8ae083ac2088cb2
---
 doc/guix.texi                    | 11 +++++++++++
 guix/build/node-build-system.scm |  3 ++-
 guix/import/npm-binary.scm       | 16 +++++-----------
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index f1e5c78a0b..d974a5cdf2 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -15715,6 +15715,8 @@ in Guix.
 @end table
 
 @item npm-binary
+@cindex npm-binary, importer
+@cindex importer for node packages
 @cindex npm
 @cindex Node.js
 Import metadata from the @uref{https://registry.npmjs.org, npm
@@ -15737,6 +15739,15 @@ refer to transpiled or generated files, instead of 
being built from
 source.
 @end quotation
 
+@quotation Note
+Currently, the generated package definition contains a phase to delete
+the development dependencies (@code{devDependencies}) from the
+@file{package.json} file, if there are such dependencies, to reduce the
+occurrences of circular dependencies.  Also note that
+@code{peerDependencies} are treated as development dependencies and
+removed for the same reason.
+@end quotation
+
 Additional options include:
 
 @table @code
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 05940bc997..1a614c2201 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -221,7 +221,8 @@ only after the 'patch-dependencies' phase."
     #:strict? strict?))
 
 (define (delete-dev-dependencies)
-  (delete-fields (list "devDependencies") #:strict? #f))
+  (delete-fields (list "devDependencies" "peerDependencies")
+                 #:strict? #f))
 
 ;;;
 ;;; Phases.
diff --git a/guix/import/npm-binary.scm b/guix/import/npm-binary.scm
index d186ea4f42..b924ebdf0a 100644
--- a/guix/import/npm-binary.scm
+++ b/guix/import/npm-binary.scm
@@ -239,8 +239,8 @@
       (if (string=? dist-url versioned-url)
           `(string-append ,(string-append (%npm-registry)
                                           (if scope
-                                             (string-append "/" scope "/")
-                                             "/")
+                                              (string-append "/" scope "/")
+                                              "/")
                                           name)
                           ,(string-append "/-/" name "-")  version ".tgz")
           dist-url)))
@@ -261,21 +261,15 @@
             (resolved-deps (map resolve-spec
                                 (append dependencies peer-dependencies)))
             (peer-names (map versioned-package-name peer-dependencies))
-            ;; lset-difference for treating peer-dependencies as dependencies,
-            ;; which leads to dependency cycles.  lset-union for treating them 
as
-            ;; (ignored) dev-dependencies, which leads to broken packages.
-            (dev-names
-             (lset-union string=
-                         (map versioned-package-name dev-dependencies)
-                         peer-names))
+            (dev-names (append (map versioned-package-name dev-dependencies)
+                               peer-names))
             (extra-phases
              (match dev-names
                (() '())
                ((dev-names ...)
                 `((add-after 'patch-dependencies 'delete-dev-dependencies
                     (lambda _
-                      (modify-json
-                       (delete-dependencies '(,@(reverse dev-names)))))))))))
+                      (modify-json (delete-dev-dependencies)))))))))
        (values
         `(package
            (name ,name)

Reply via email to