unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
To: 75190@debbugs.gnu.org
Subject: [bug#75190] [PATCH] Bump esbuild to 0.23.0 and fix node module
Date: Mon, 30 Dec 2024 09:36:51 +0000	[thread overview]
Message-ID: <CAADuFn+i-a+UZVnqQDF-HZs+p+K9Fcc72XBV+sF_oRPiP26M6Q@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 8275 bytes --]

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 <d.khodabakhsh@gmail.com>
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 <code@greghogan.com>
 ;;; Copyright © 2024 Marco Baggio <guix@mawumag.com>
 ;;; Copyright © 2024 Spencer King <spencer.king@geneoscopy.com>
+;;; Copyright © 2024 Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
 ;;;
 ;;; 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 <contact@dhruvin.dev>
 ;;; Copyright © 2022 Nicolas Graves <ngraves@ngraves.fr>
 ;;; Copyright © 2023 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2024 Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
 ;;;
 ;;; 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 <~@wolfsden.cz>
 ;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
 ;;; Copyright © 2024 Artyom V. Poptsov <poptsov.artyom@gmail.com>
+;;; Copyright © 2024 Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
 ;;;
 ;;; 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

[-- Attachment #2: 0001-Bump-esbuild-to-0.23.0.patch --]
[-- Type: text/x-patch, Size: 8382 bytes --]

From d0b5815b57fff2e226a7191829c8aedf23552b36 Mon Sep 17 00:00:00 2001
Message-ID: <d0b5815b57fff2e226a7191829c8aedf23552b36.1735550962.git.d.khodabakhsh@gmail.com>
From: Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
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 <d.khodabakhsh@gmail.com>
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 <code@greghogan.com>
 ;;; Copyright © 2024 Marco Baggio <guix@mawumag.com>
 ;;; Copyright © 2024 Spencer King <spencer.king@geneoscopy.com>
+;;; Copyright © 2024 Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
 ;;;
 ;;; 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 <contact@dhruvin.dev>
 ;;; Copyright © 2022 Nicolas Graves <ngraves@ngraves.fr>
 ;;; Copyright © 2023 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2024 Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
 ;;;
 ;;; 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 <~@wolfsden.cz>
 ;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
 ;;; Copyright © 2024 Artyom V. Poptsov <poptsov.artyom@gmail.com>
+;;; Copyright © 2024 Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
 ;;;
 ;;; 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


                 reply	other threads:[~2024-12-30  9:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAADuFn+i-a+UZVnqQDF-HZs+p+K9Fcc72XBV+sF_oRPiP26M6Q@mail.gmail.com \
    --to=d.khodabakhsh@gmail.com \
    --cc=75190@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).