mirror of
https://codeberg.org/guix/guix.git
synced 2026-01-25 03:55:08 -06:00
gnu: Add node-typescript.
* gnu/packages/node-xyz.scm (node-typescript): New variable. Change-Id: Ief680a973c6f4f98837db3b2b15109c10fda8c6e
This commit is contained in:
parent
ef49a01921
commit
8fa77b2b8f
1 changed files with 124 additions and 1 deletions
|
|
@ -25,9 +25,10 @@
|
|||
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (gnu packages node-xyz)
|
||||
#:use-module (gnu packages base) ; sed
|
||||
#:use-module (gnu packages sqlite)
|
||||
#:use-module (gnu packages python)
|
||||
#:use-module (gnu packages web)
|
||||
#:use-module (gnu packages web) ; node-esbuild
|
||||
#:use-module (guix build-system node)
|
||||
#:use-module (guix gexp)
|
||||
#:use-module (guix git-download)
|
||||
|
|
@ -2929,6 +2930,128 @@ tablets.
|
|||
"1p2kakd1mhcps5c19wl65w9gkafd13qdy9hszriak4xpad8a2nz7"
|
||||
(delay (list node-source-map))))
|
||||
|
||||
(define-public node-typescript
|
||||
(package
|
||||
(name "node-typescript")
|
||||
(version "5.8.3")
|
||||
(source (origin
|
||||
(method git-fetch)
|
||||
(uri (git-reference
|
||||
(url "https://github.com/microsoft/TypeScript")
|
||||
(commit (string-append "v" version))))
|
||||
(file-name (git-file-name name version))
|
||||
(sha256
|
||||
(base32 "1gzczfiz5zlrfvk73y4iwdnc7r8brs2cgyy3pv0b4979xxj66z7x"))))
|
||||
(build-system node-build-system)
|
||||
(native-inputs (list
|
||||
node-dprint-formatter ; 0.x
|
||||
node-esbuild ; 0.x
|
||||
node-fast-xml-parser ; 4.x
|
||||
node-glob ; 10.x
|
||||
node-hereby ; 1.x
|
||||
node-jsonc-parser
|
||||
node-minimist ; 1.x
|
||||
node-picocolors ; 1.x
|
||||
node-source-map-support ; 0.x
|
||||
node-types-node ; Match the version of node
|
||||
node-types-source-map-support
|
||||
node-which ; 3.x
|
||||
sed))
|
||||
(arguments (list
|
||||
#:tests? #f ; FIXME: Tests require 'chai', 'mocha', and 'eslint'.
|
||||
#:phases #~(modify-phases %standard-phases
|
||||
(add-before 'patch-dependencies 'modify-package (lambda _
|
||||
(modify-json
|
||||
(delete-dependencies (list
|
||||
; TODO @dprint/typescript needs a rust build but it's only required to
|
||||
; format the .d.ts files, however they're already somewhat formatted.
|
||||
"@dprint/typescript"
|
||||
"@esfx/canceltoken"
|
||||
"@eslint/js"
|
||||
"@octokit/rest"
|
||||
"@types/chai"
|
||||
"@types/diff"
|
||||
"@types/minimist"
|
||||
"@types/mocha"
|
||||
"@types/ms"
|
||||
"@types/which"
|
||||
"@typescript-eslint/rule-tester"
|
||||
"@typescript-eslint/type-utils"
|
||||
"@typescript-eslint/utils"
|
||||
"azure-devops-node-api"
|
||||
"c8"
|
||||
"chai"
|
||||
"chokidar"
|
||||
"diff"
|
||||
"dprint"
|
||||
"eslint"
|
||||
"eslint-formatter-autolinkable-stylish"
|
||||
"eslint-plugin-regexp"
|
||||
"globals"
|
||||
"knip"
|
||||
"mocha"
|
||||
"mocha-fivemat-progress-reporter"
|
||||
"monocart-coverage-reports"
|
||||
"ms"
|
||||
"playwright"
|
||||
"tslib"
|
||||
"typescript"
|
||||
"typescript-eslint")))
|
||||
|
||||
; Remove imports of dependencies that are not used in building.
|
||||
(substitute*
|
||||
(list
|
||||
"Herebyfile.mjs"
|
||||
"scripts/build/tests.mjs"
|
||||
"scripts/build/utils.mjs")
|
||||
(("^import .* from \"(@esfx/canceltoken|chokidar|glob)\".*") ""))
|
||||
|
||||
; Replace @esfx/canceltoken CancelError
|
||||
(substitute* "scripts/build/utils.mjs"
|
||||
(("CancelError\\(\\)")
|
||||
"(function() {const error = new Error(\"Operation was canceled\");\
|
||||
error.name=\"CancelError\";return error})()"))
|
||||
|
||||
; TODO: Once @dprint/typescript is added, remove these modifications
|
||||
; to format typescript.d.ts.
|
||||
(define dtsBundler "scripts/dtsBundler.mjs")
|
||||
(substitute* dtsBundler
|
||||
(("^import .* from \"@dprint/typescript\".*") "")
|
||||
(("^import .* from \"typescript\";")
|
||||
"import * as ts from \"../built/local/typescript.js\";")
|
||||
(("^const buffer =.*") "")
|
||||
(("^const formatter =.*") ""))
|
||||
(invoke "sed" "-i" "/^formatter/,/;/d" dtsBundler)
|
||||
(invoke "sed" "-i"
|
||||
"/^function dprint(/,/^}/c\\function dprint(contents) {return contents;}"
|
||||
dtsBundler)))
|
||||
(replace 'build (lambda _
|
||||
; First build tsc so it can be used in the rest of the build.
|
||||
(invoke "hereby" "tsc" "--bundle" "--no-typecheck")
|
||||
(invoke "hereby" "lkg" "--bundle" "--no-typecheck" "--built")))
|
||||
(add-after 'check 'prepare-package (lambda _
|
||||
(define output "output")
|
||||
(mkdir output)
|
||||
(for-each
|
||||
(lambda (file) (install-file file output))
|
||||
(list
|
||||
"LICENSE.txt"
|
||||
"package.json"
|
||||
"README.md"
|
||||
"SECURITY.md"
|
||||
"ThirdPartyNoticeText.txt"))
|
||||
(for-each
|
||||
(lambda (dir) (copy-recursively dir (string-append output "/" dir)))
|
||||
(list "bin" "lib"))
|
||||
(chdir output))))))
|
||||
(synopsis "TypeScript language for application scale JavaScript development")
|
||||
(description "TypeScript is a language for application-scale JavaScript. TypeScript\
|
||||
adds optional types to JavaScript that support tools for large-scale JavaScript\
|
||||
applications for any browser, for any host, on any OS. TypeScript compiles to readable,\
|
||||
standards-based JavaScript.")
|
||||
(home-page "https://www.typescriptlang.org/")
|
||||
(license license:expat)))
|
||||
|
||||
(define-public node-typical
|
||||
(package
|
||||
(name "node-typical")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue