[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27449: [PATCH] gnu: Add js-respond.
From: |
Ricardo Wurmus |
Subject: |
bug#27449: [PATCH] gnu: Add js-respond. |
Date: |
Fri, 23 Jun 2017 08:20:58 +0200 |
User-agent: |
mu4e 0.9.18; emacs 25.2.1 |
Ludovic Courtès <address@hidden> writes:
> Ricardo Wurmus <address@hidden> skribis:
>
>> * gnu/packages/javascript.scm (js-respond): New variable.
>
> LGTM.
Thanks. Pushed to master with b37b48f81.
>> + (build-system trivial-build-system)
>> + (arguments
>> + `(#:modules ((guix build utils))
>> + #:builder
>> + (begin
>> + (use-modules (guix build utils)
>> + (ice-9 match)
>> + (ice-9 popen)
>> + (srfi srfi-26))
>> + (set-path-environment-variable
>> + "PATH" '("bin") (map (match-lambda
>> + ((_ . input)
>> + input))
>> + %build-inputs))
>> + (let ((install-directory (string-append %output
>> +
>> "/share/javascript/respond/")))
>> + (system* "tar" "xvf"
>> + (assoc-ref %build-inputs "source")
>> + "--strip" "1")
>> + (mkdir-p install-directory)
>> + (let* ((file "src/respond.js")
>> + (installed (string-append install-directory
>> "respond.min.js")))
>> + (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
>> + (call-with-output-file installed
>> + (cut dump-port minified <>)))))
>> + #t)))
>
> Should we turn this into a ‘javascript-build-system’?
This is a simplified version of what js-mathjax does, so that seems like
a good template for minifying JavaScript files. I’m just not sure how
to generalise this, because projects don’t always put all their
unminified .js files in a single directory and we can’t just minify all
.js files, because
a) they might already be minified,
b) they might require compilation / concatenation.
Maybe we should wait until we have some more experience with how other
JS projects handle this. I’m going to package a few more JS things for
r-shiny; if a pattern should pop up I’m going to poor it into a build
system.
-- Ricardo