build-system/minify: Use esbuild.
* guix/build-system/minify.scm (default-uglify-js): Replace this procedure... (default-esbuild): ...with this new procedure. (lower): Use it, and add "esbuild" to build inputs. * guix/build/minify-build-system.scm (minify): Invoke esbuild instead of setting up a pipe to uglifyjs. * gnu/packages/cran.scm (r-shiny)[native-inputs]: Replace node-uglify-js with esbuild. * gnu/packages/statistics.scm (r-dt)[native-inputs]: Same.master
parent
b19dfb9d3a
commit
9d4339afb1
|
@ -4591,7 +4591,7 @@ previewing themes in real time.")
|
||||||
(inputs
|
(inputs
|
||||||
(list js-datatables js-selectize js-strftime js-highlight))
|
(list js-datatables js-selectize js-strftime js-highlight))
|
||||||
(native-inputs
|
(native-inputs
|
||||||
`(("uglifyjs" ,node-uglify-js)
|
`(("esbuild" ,esbuild)
|
||||||
("gfortran" ,gfortran)
|
("gfortran" ,gfortran)
|
||||||
("js-bootstrap-accessibility"
|
("js-bootstrap-accessibility"
|
||||||
,(origin
|
,(origin
|
||||||
|
|
|
@ -4069,7 +4069,7 @@ using the multicore functionality of the parallel package.")
|
||||||
(list js-selectize))
|
(list js-selectize))
|
||||||
(native-inputs
|
(native-inputs
|
||||||
`(("r-knitr" ,r-knitr)
|
`(("r-knitr" ,r-knitr)
|
||||||
("uglifyjs" ,node-uglify-js)
|
("esbuild" ,esbuild)
|
||||||
("datatables-plugins"
|
("datatables-plugins"
|
||||||
,(let ((version "1.13.4"))
|
,(let ((version "1.13.4"))
|
||||||
(origin
|
(origin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
|
;;; Copyright © 2017, 2018, 2023 Ricardo Wurmus <rekado@elephly.net>
|
||||||
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
|
@ -41,15 +41,15 @@
|
||||||
`((guix build minify-build-system)
|
`((guix build minify-build-system)
|
||||||
,@%gnu-build-system-modules))
|
,@%gnu-build-system-modules))
|
||||||
|
|
||||||
(define (default-uglify-js)
|
(define (default-esbuild)
|
||||||
"Return the default package to minify JavaScript source files."
|
"Return the default package to minify JavaScript source files."
|
||||||
;; Lazily resolve the binding to avoid a circular dependency.
|
;; Lazily resolve the binding to avoid a circular dependency.
|
||||||
(let ((mod (resolve-interface '(gnu packages uglifyjs))))
|
(let ((mod (resolve-interface '(gnu packages web))))
|
||||||
(module-ref mod 'uglifyjs)))
|
(module-ref mod 'esbuild)))
|
||||||
|
|
||||||
(define* (lower name
|
(define* (lower name
|
||||||
#:key source inputs native-inputs outputs system
|
#:key source inputs native-inputs outputs system
|
||||||
(uglify-js (default-uglify-js))
|
(esbuild (default-esbuild))
|
||||||
#:allow-other-keys
|
#:allow-other-keys
|
||||||
#:rest arguments)
|
#:rest arguments)
|
||||||
"Return a bag for NAME."
|
"Return a bag for NAME."
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
'())
|
'())
|
||||||
,@inputs
|
,@inputs
|
||||||
,@(standard-packages)))
|
,@(standard-packages)))
|
||||||
(build-inputs `(("uglify-js" ,uglify-js)
|
(build-inputs `(("esbuild" ,esbuild)
|
||||||
,@native-inputs))
|
,@native-inputs))
|
||||||
(outputs outputs)
|
(outputs outputs)
|
||||||
(build minify-build)
|
(build minify-build)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
|
;;; Copyright © 2016, 2023 Ricardo Wurmus <rekado@elephly.net>
|
||||||
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
|
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
|
@ -24,7 +24,6 @@
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (ice-9 popen)
|
|
||||||
#:export (%standard-phases
|
#:export (%standard-phases
|
||||||
minify-build
|
minify-build
|
||||||
minify))
|
minify))
|
||||||
|
@ -39,14 +38,9 @@
|
||||||
(define* (minify file #:key target (directory ""))
|
(define* (minify file #:key target (directory ""))
|
||||||
(format #t "minifying ~a\n" file)
|
(format #t "minifying ~a\n" file)
|
||||||
(let* ((base (basename file ".js"))
|
(let* ((base (basename file ".js"))
|
||||||
(installed (or target (string-append directory base ".min.js")))
|
(installed (or target (string-append directory base ".min.js"))))
|
||||||
(minified (open-pipe* OPEN_READ "uglifyjs" file)))
|
(invoke "esbuild" file "--minify"
|
||||||
(call-with-output-file installed
|
(string-append "--outfile=" installed))))
|
||||||
(cut dump-port minified <>))
|
|
||||||
(match (close-pipe minified)
|
|
||||||
(0 #t)
|
|
||||||
(status
|
|
||||||
(error "uglify-js failed" status)))))
|
|
||||||
|
|
||||||
(define* (build #:key javascript-files
|
(define* (build #:key javascript-files
|
||||||
#:allow-other-keys)
|
#:allow-other-keys)
|
||||||
|
|
Reference in New Issue