Subject: bug#75190: closed ()

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 01 May 2025 17:21:02 +0000

Your bug report

#75190: [PATCH] Bump esbuild to 0.23.0 and fix node module

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
75190: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75190
GNU Bug Tracking System
Contact [email-masked] with problems

From: Daniel Khodabakhsh <[email-masked]>
To: [email-masked]
Date: Thu, 1 May 2025 17:20:09 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Oleg!

Yes you're right. I've also rethought the approach: this one combined
version bumping and refactoring esbuild-node. I'm going to close this
one and create a new patch. Just did that now and here is the new
patch: #78183

Subject: [PATCH] Bump esbuild to 0.23.0 and fix node module
From: Daniel Khodabakhsh <[email-masked]>
To: [email-masked]
Date: Mon, 30 Dec 2024 09:36:51 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Bump esbuild to 0.23.0.
Also fix the current definition of esbuild-node by renaming it to node-esbuild,
 moving it to gnu/packages/node-xyz.scm and using the appropriate build-system.

Signed-off-by: Daniel Khodabakhsh <[email-masked]>
Change-Id: Idb7236362d6e488283222c734a4a096e869d6d2c
---
 gnu/packages/cran.scm     |  4 ++-
 gnu/packages/node-xyz.scm | 57 ++++++++++++++++++++++++++++++++++++++
 gnu/packages/web.scm      | 58 ++-------------------------------------
 3 files changed, 63 insertions(+), 56 deletions(-)

diff --git a/gnu/packages/cran.scm b/gnu/packages/cran.scm
index aa18931d92..99d14d7b65 100644
--- a/gnu/packages/cran.scm
+++ b/gnu/packages/cran.scm
@@ -39,6 +39,7 @@
 ;;; Copyright © 2022 Greg Hogan <[email-masked]>
 ;;; Copyright © 2024 Marco Baggio <[email-masked]>
 ;;; Copyright © 2024 Spencer King <[email-masked]>
+;;; Copyright © 2024 Daniel Khodabakhsh <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -97,6 +98,7 @@ (define-module (gnu packages cran)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages networking)
   #:use-module (gnu packages node)
+  #:use-module (gnu packages node-xyz)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages pdf)
   #:use-module (gnu packages perl)
@@ -2648,7 +2650,7 @@ (define-public r-waiter
                        "inst/assets/garcon/garcon.min.js"))))))
       (propagated-inputs (list r-htmltools r-r6 r-shiny))
       (native-inputs
-       (list esbuild-node node-lts r-knitr
+       (list node-esbuild node-lts r-knitr
              (origin
                (method git-fetch)
                (uri (git-reference
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index e98eda2a01..c11b76495d 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2021 Dhruvin Gandhi <[email-masked]>
 ;;; Copyright © 2022 Nicolas Graves <[email-masked]>
 ;;; Copyright © 2023 Jelle Licht <[email-masked]>
+;;; Copyright © 2024 Daniel Khodabakhsh <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -376,6 +377,62 @@ (define-public node-env-variable
 @code{localStorage} fallbacks.")
     (license license:expat)))

+(define-public node-esbuild
+  (package
+    (name "node-esbuild")
+    (version "0.23.0")
+    (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference
+          (url "https://github.com/evanw/esbuild")
+          (commit (string-append "v" version))))
+        (file-name (git-file-name name version))
+        (sha256
+          (base32 "03014924aaksw5hm8h5j6d7v28vgyqbhhfcn4lfw12fg8bj1hzh0"))))
+    (build-system node-build-system)
+    (inputs (list esbuild))
+    (arguments `(
+      #:tests? #f
+      #:modules
+       ((guix build node-build-system)
+        (srfi srfi-1)
+        (ice-9 match)
+        (guix build utils))
+      #:phases (modify-phases %standard-phases
+        (add-after 'unpack 'chdir (lambda _
+          (chdir "npm/esbuild")))
+        (replace 'build (lambda* (#:key inputs #:allow-other-keys)
+          (let
+            ((esbuild-bin
+              (string-append (assoc-ref inputs "esbuild") "/bin/esbuild")))
+            (invoke
+              "node"
+              "../../scripts/esbuild.js"
+              esbuild-bin
+              "--neutral")
+            ; TODO: Once 74900 is merged, replace below with:
+            ; (modify-json (delete-fields '("optionalDependencies",
"scripts")))
+            (with-atomic-json-file-replacement "package.json"
+              (match-lambda
+                ((@ . pkg-meta-alist)
+                  (cons '@ (filter
+                    (match-lambda
+                      (("optionalDependencies" . _) #f)
+                      (("scripts" . _) #f)
+                      (_ #t))
+                    pkg-meta-alist)))))
+            (delete-file "install.js")
+            (delete-file "package-lock.json")
+            (copy-file esbuild-bin "bin/esbuild")))))))
+    (home-page "https://esbuild.github.io/")
+    (synopsis "Node module of ESBuild")
+    (description
+     "The esbuild tool provides a unified bundler, transpiler and
+minifier.  It packages up JavaScript and TypeScript code, along with JSON
+and other data, for distribution on the web.")
+    (license license:expat)))
+
 (define-public node-far
   (package
     (name "node-far")
diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index b278239c7d..cd427483cc 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -68,6 +68,7 @@
 ;;; Copyright © 2024 Tomas Volf <[email-masked]>
 ;;; Copyright © 2024 Zheng Junjie <[email-masked]>
 ;;; Copyright © 2024 Artyom V. Poptsov <[email-masked]>
+;;; Copyright © 2024 Daniel Khodabakhsh <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1950,7 +1951,7 @@ (define-public libpsl
 (define-public esbuild
   (package
     (name "esbuild")
-    (version "0.14.0")
+    (version "0.23.0")
     (source
      (origin
        (method git-fetch)
@@ -1959,7 +1960,7 @@ (define-public esbuild
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "09r1xy0kk6c9cpz6q0mxr4why373pwxbm439z2ihq3k1d5kk7x4w"))
+        (base32 "03014924aaksw5hm8h5j6d7v28vgyqbhhfcn4lfw12fg8bj1hzh0"))
        (modules '((guix build utils)))
        (snippet
         '(begin
@@ -2099,59 +2100,6 @@ (define-public websockify
 directions.")
     (license license:lgpl3)))

-;; This is a variant of esbuild that builds and installs the nodejs API.
-;; Eventually, this should probably be merged with the esbuild package.
-(define-public esbuild-node
-  (package
-    (inherit esbuild)
-    (name "esbuild-node")
-    (version (package-version esbuild))
-    (source
-     (origin
-       (method git-fetch)
-       (uri (git-reference
-             (url "https://github.com/evanw/esbuild")
-             (commit (string-append "v" version))))
-       (file-name (git-file-name name version))
-       (sha256
-        (base32 "09r1xy0kk6c9cpz6q0mxr4why373pwxbm439z2ihq3k1d5kk7x4w"))
-       (modules '((guix build utils)))
-       (snippet
-        ;; Remove prebuilt binaries
-        '(delete-file-recursively "lib/npm/exit0"))))
-    (arguments
-     (list
-      #:import-path "github.com/evanw/esbuild/cmd/esbuild"
-      #:unpack-path "github.com/evanw/esbuild"
-      #:phases
-      #~(modify-phases %standard-phases
-          (add-after 'build 'build-platform
-            (lambda* (#:key unpack-path #:allow-other-keys)
-              (with-directory-excursion (string-append "src/" unpack-path)
-                ;; Must be writable.
-                (for-each make-file-writable (find-files "." "."))
-                (invoke "node" "scripts/esbuild.js"
-                        (string-append #$output "/bin/esbuild"))
-                (let ((modules (string-append #$output
"/lib/node_modules/esbuild")))
-                  (mkdir-p modules)
-                  (copy-recursively "npm/esbuild" modules)))))
-          (replace 'check
-            (lambda* (#:key tests? unpack-path #:allow-other-keys)
-              (when tests?
-                ;; The "Go Race Detector" is only supported on 64-bit
-                ;; platforms, this variable disables it.
-                ;; TODO: Causes too many rebuilds, rewrite to limit to x86_64,
-                ;; aarch64 and ppc64le.
-                #$(if (target-riscv64?)
-                      `(setenv "ESBUILD_RACE" "")
-                      #~(unless #$(target-64bit?)
-                          (setenv "ESBUILD_RACE" "")))
-                (with-directory-excursion (string-append "src/" unpack-path)
-                  (invoke "make" "test-go"))))))))
-    (native-inputs
-     (modify-inputs (package-native-inputs esbuild)
-       (append node-lts)))))
-
 (define-public wwwoffle
   (package
     (name "wwwoffle")

base-commit: e16cdcf37d8223b3634ec5e658356c3b7f154859
-- 
2.46.0
From d0b5815b57fff2e226a7191829c8aedf23552b36 Mon Sep 17 00:00:00 2001
Message-ID: <d0b58[email-masked]>
From: Daniel Khodabakhsh <[email-masked]>
Date: Mon, 30 Dec 2024 01:29:11 -0800
Subject: [PATCH] Bump esbuild to 0.23.0 and fix node module.

Bump esbuild to 0.23.0.
Also fix the current definition of esbuild-node by renaming it to node-esbuild,
 moving it to gnu/packages/node-xyz.scm and using the appropriate build-system.

Signed-off-by: Daniel Khodabakhsh <[email-masked]>
Change-Id: Idb7236362d6e488283222c734a4a096e869d6d2c
---
 gnu/packages/cran.scm     |  4 ++-
 gnu/packages/node-xyz.scm | 57 ++++++++++++++++++++++++++++++++++++++
 gnu/packages/web.scm      | 58 ++-------------------------------------
 3 files changed, 63 insertions(+), 56 deletions(-)

diff --git a/gnu/packages/cran.scm b/gnu/packages/cran.scm
index aa18931d92..99d14d7b65 100644
--- a/gnu/packages/cran.scm
+++ b/gnu/packages/cran.scm
@@ -39,6 +39,7 @@
 ;;; Copyright © 2022 Greg Hogan <[email-masked]>
 ;;; Copyright © 2024 Marco Baggio <[email-masked]>
 ;;; Copyright © 2024 Spencer King <[email-masked]>
+;;; Copyright © 2024 Daniel Khodabakhsh <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -97,6 +98,7 @@ (define-module (gnu packages cran)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages networking)
   #:use-module (gnu packages node)
+  #:use-module (gnu packages node-xyz)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages pdf)
   #:use-module (gnu packages perl)
@@ -2648,7 +2650,7 @@ (define-public r-waiter
                        "inst/assets/garcon/garcon.min.js"))))))
       (propagated-inputs (list r-htmltools r-r6 r-shiny))
       (native-inputs
-       (list esbuild-node node-lts r-knitr
+       (list node-esbuild node-lts r-knitr
              (origin
                (method git-fetch)
                (uri (git-reference
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index e98eda2a01..c11b76495d 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2021 Dhruvin Gandhi <[email-masked]>
 ;;; Copyright © 2022 Nicolas Graves <[email-masked]>
 ;;; Copyright © 2023 Jelle Licht <[email-masked]>
+;;; Copyright © 2024 Daniel Khodabakhsh <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -376,6 +377,62 @@ (define-public node-env-variable
 @code{localStorage} fallbacks.")
     (license license:expat)))
 
+(define-public node-esbuild
+  (package
+    (name "node-esbuild")
+    (version "0.23.0")
+    (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference
+          (url "https://github.com/evanw/esbuild")
+          (commit (string-append "v" version))))
+        (file-name (git-file-name name version))
+        (sha256
+          (base32 "03014924aaksw5hm8h5j6d7v28vgyqbhhfcn4lfw12fg8bj1hzh0"))))
+    (build-system node-build-system)
+    (inputs (list esbuild))
+    (arguments `(
+      #:tests? #f
+      #:modules
+       ((guix build node-build-system)
+        (srfi srfi-1)
+        (ice-9 match)
+        (guix build utils))
+      #:phases (modify-phases %standard-phases
+        (add-after 'unpack 'chdir (lambda _
+          (chdir "npm/esbuild")))
+        (replace 'build (lambda* (#:key inputs #:allow-other-keys)
+          (let
+            ((esbuild-bin
+              (string-append (assoc-ref inputs "esbuild") "/bin/esbuild")))
+            (invoke
+              "node"
+              "../../scripts/esbuild.js"
+              esbuild-bin
+              "--neutral")
+            ; TODO: Once 74900 is merged, replace below with:
+            ; (modify-json (delete-fields '("optionalDependencies", "scripts")))
+            (with-atomic-json-file-replacement "package.json"
+              (match-lambda
+                ((@ . pkg-meta-alist)
+                  (cons '@ (filter
+                    (match-lambda
+                      (("optionalDependencies" . _) #f)
+                      (("scripts" . _) #f)
+                      (_ #t))
+                    pkg-meta-alist)))))
+            (delete-file "install.js")
+            (delete-file "package-lock.json")
+            (copy-file esbuild-bin "bin/esbuild")))))))
+    (home-page "https://esbuild.github.io/")
+    (synopsis "Node module of ESBuild")
+    (description
+     "The esbuild tool provides a unified bundler, transpiler and
+minifier.  It packages up JavaScript and TypeScript code, along with JSON
+and other data, for distribution on the web.")
+    (license license:expat)))
+
 (define-public node-far
   (package
     (name "node-far")
diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index b278239c7d..cd427483cc 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -68,6 +68,7 @@
 ;;; Copyright © 2024 Tomas Volf <[email-masked]>
 ;;; Copyright © 2024 Zheng Junjie <[email-masked]>
 ;;; Copyright © 2024 Artyom V. Poptsov <[email-masked]>
+;;; Copyright © 2024 Daniel Khodabakhsh <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1950,7 +1951,7 @@ (define-public libpsl
 (define-public esbuild
   (package
     (name "esbuild")
-    (version "0.14.0")
+    (version "0.23.0")
     (source
      (origin
        (method git-fetch)
@@ -1959,7 +1960,7 @@ (define-public esbuild
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "09r1xy0kk6c9cpz6q0mxr4why373pwxbm439z2ihq3k1d5kk7x4w"))
+        (base32 "03014924aaksw5hm8h5j6d7v28vgyqbhhfcn4lfw12fg8bj1hzh0"))
        (modules '((guix build utils)))
        (snippet
         '(begin
@@ -2099,59 +2100,6 @@ (define-public websockify
 directions.")
     (license license:lgpl3)))
 
-;; This is a variant of esbuild that builds and installs the nodejs API.
-;; Eventually, this should probably be merged with the esbuild package.
-(define-public esbuild-node
-  (package
-    (inherit esbuild)
-    (name "esbuild-node")
-    (version (package-version esbuild))
-    (source
-     (origin
-       (method git-fetch)
-       (uri (git-reference
-             (url "https://github.com/evanw/esbuild")
-             (commit (string-append "v" version))))
-       (file-name (git-file-name name version))
-       (sha256
-        (base32 "09r1xy0kk6c9cpz6q0mxr4why373pwxbm439z2ihq3k1d5kk7x4w"))
-       (modules '((guix build utils)))
-       (snippet
-        ;; Remove prebuilt binaries
-        '(delete-file-recursively "lib/npm/exit0"))))
-    (arguments
-     (list
-      #:import-path "github.com/evanw/esbuild/cmd/esbuild"
-      #:unpack-path "github.com/evanw/esbuild"
-      #:phases
-      #~(modify-phases %standard-phases
-          (add-after 'build 'build-platform
-            (lambda* (#:key unpack-path #:allow-other-keys)
-              (with-directory-excursion (string-append "src/" unpack-path)
-                ;; Must be writable.
-                (for-each make-file-writable (find-files "." "."))
-                (invoke "node" "scripts/esbuild.js"
-                        (string-append #$output "/bin/esbuild"))
-                (let ((modules (string-append #$output "/lib/node_modules/esbuild")))
-                  (mkdir-p modules)
-                  (copy-recursively "npm/esbuild" modules)))))
-          (replace 'check
-            (lambda* (#:key tests? unpack-path #:allow-other-keys)
-              (when tests?
-                ;; The "Go Race Detector" is only supported on 64-bit
-                ;; platforms, this variable disables it.
-                ;; TODO: Causes too many rebuilds, rewrite to limit to x86_64,
-                ;; aarch64 and ppc64le.
-                #$(if (target-riscv64?)
-                      `(setenv "ESBUILD_RACE" "")
-                      #~(unless #$(target-64bit?)
-                          (setenv "ESBUILD_RACE" "")))
-                (with-directory-excursion (string-append "src/" unpack-path)
-                  (invoke "make" "test-go"))))))))
-    (native-inputs
-     (modify-inputs (package-native-inputs esbuild)
-       (append node-lts)))))
-
 (define-public wwwoffle
   (package
     (name "wwwoffle")

base-commit: e16cdcf37d8223b3634ec5e658356c3b7f154859
-- 
2.46.0