mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-14 05:29:20 +03:00
typescript: prefer npmjs for src
This commit is contained in:
parent
050d2ca17a
commit
38b1b87e90
5 changed files with 5494 additions and 104 deletions
|
@ -1,15 +0,0 @@
|
||||||
Disable dprint on dstBundler
|
|
||||||
|
|
||||||
dprint fails on sandbox, because it requires internet access to install its
|
|
||||||
plugins.
|
|
||||||
|
|
||||||
--- a/scripts/dtsBundler.mjs
|
|
||||||
+++ b/scripts/dtsBundler.mjs
|
|
||||||
@@ -430,5 +430,5 @@
|
|
||||||
return result.replace(/\r\n/g, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
-fs.writeFileSync(output, dprint(publicContents));
|
|
||||||
-fs.writeFileSync(internalOutput, dprint(internalContents));
|
|
||||||
+fs.writeFileSync(output, publicContents);
|
|
||||||
+fs.writeFileSync(internalOutput, internalContents);
|
|
5445
pkgs/by-name/ty/typescript/package-lock.json
generated
Normal file
5445
pkgs/by-name/ty/typescript/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,52 +1,38 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
buildNpmPackage,
|
buildNpmPackage,
|
||||||
fetchFromGitHub,
|
fetchurl,
|
||||||
replaceVars,
|
|
||||||
versionCheckHook,
|
versionCheckHook,
|
||||||
nix-update-script,
|
writeShellApplication,
|
||||||
|
nodejs,
|
||||||
|
gnutar,
|
||||||
|
nix-update,
|
||||||
|
prefetch-npm-deps,
|
||||||
|
gnused,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildNpmPackage (finalAttrs: {
|
buildNpmPackage (finalAttrs: {
|
||||||
pname = "typescript";
|
pname = "typescript";
|
||||||
version = "5.8.3";
|
version = "5.8.3";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
# Prefer npmjs over the GitHub repository for source code.
|
||||||
owner = "microsoft";
|
# The TypeScript project typically publishes stable, versioned code to npmjs,
|
||||||
repo = "TypeScript";
|
# whereas GitHub tags may sometimes include development versions.
|
||||||
tag = "v${finalAttrs.version}";
|
# For example:
|
||||||
hash = "sha256-/XxjZO/pJLLAvsP7x4TOC+XDbOOR+HHmdpn+8qP77L8=";
|
# - https://github.com/microsoft/TypeScript/pull/61218#issuecomment-2911264050
|
||||||
|
# - https://github.com/microsoft/TypeScript/pull/60150#issuecomment-2648791588, 5.8.3 includes this 5.9 breaking change
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://registry.npmjs.org/typescript/-/typescript-${finalAttrs.version}.tgz";
|
||||||
|
hash = "sha256-cuddvrksLm65o0y1nXT6tcLubzKgMkqJQF9hZdWgg3Q=";
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = [
|
|
||||||
./disable-dprint-dstBundler.patch
|
|
||||||
|
|
||||||
# Should be removed in next 5.9.X TypeScript update: https://github.com/microsoft/TypeScript/pull/61218#issuecomment-2911264050
|
|
||||||
(replaceVars ./revert-bump-to-v5.9.patch {
|
|
||||||
inherit (finalAttrs) version;
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
# The test run in the build script is redundant with checkPhase
|
ln -s '${./package-lock.json}' package-lock.json
|
||||||
substituteInPlace package.json \
|
|
||||||
--replace-fail ' && npm run build:tests' ""
|
|
||||||
|
|
||||||
# Should be removed in next 5.9.X TypeScript update
|
|
||||||
substituteInPlace src/compiler/corePublic.ts \
|
|
||||||
--replace-fail 'versionMajorMinor = "5.9"' 'versionMajorMinor = "5.8"'
|
|
||||||
substituteInPlace tests/baselines/reference/api/typescript.d.ts \
|
|
||||||
--replace-fail 'versionMajorMinor = "5.9"' 'versionMajorMinor = "5.8"'
|
|
||||||
|
|
||||||
# Imported from https://github.com/microsoft/TypeScript/blob/b504a1eed45e35b5f54694a1e0a09f35d0a5663c/.github/workflows/set-version.yaml#L75
|
|
||||||
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${finalAttrs.version}" as string;/g' src/compiler/corePublic.ts
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
npmDepsHash = "sha256-BHJGezzZensC/WFsUumJSk6TYAqbS50Inuvw2nV5vUk=";
|
npmDepsHash = "sha256-Y/+QPAVOQWKxrHBNEejC3UZrYKQNm7CleR0whFm2sLw=";
|
||||||
|
|
||||||
postBuild = ''
|
dontNpmBuild = true;
|
||||||
npx hereby lkg
|
|
||||||
'';
|
|
||||||
|
|
||||||
nativeInstallCheckInputs = [
|
nativeInstallCheckInputs = [
|
||||||
versionCheckHook
|
versionCheckHook
|
||||||
|
@ -56,11 +42,21 @@ buildNpmPackage (finalAttrs: {
|
||||||
versionCheckProgramArg = "--version";
|
versionCheckProgramArg = "--version";
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
updateScript = nix-update-script {
|
updateScript = lib.getExe (writeShellApplication {
|
||||||
extraArgs = [
|
name = "${finalAttrs.pname}-updater";
|
||||||
"--version-regex=^v([\\d.]+)$"
|
runtimeInputs = [
|
||||||
|
nodejs
|
||||||
|
gnutar
|
||||||
|
nix-update
|
||||||
|
prefetch-npm-deps
|
||||||
|
gnused
|
||||||
];
|
];
|
||||||
};
|
runtimeEnv = {
|
||||||
|
PNAME = finalAttrs.pname;
|
||||||
|
PKG_DIR = builtins.toString ./.;
|
||||||
|
};
|
||||||
|
text = builtins.readFile ./update.bash;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
From fb5da5ae2622c4f7bb421f4d9ac6881b07ee220c Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kenichi Kamiya <kachick1@gmail.com>
|
|
||||||
Date: Tue, 27 May 2025 16:09:56 +0900
|
|
||||||
Subject: [PATCH] Revert 1fdf78aee644afd2702d69c148754a7fc1aff910
|
|
||||||
|
|
||||||
This was an unintended slipped commit into v5.8.n
|
|
||||||
Should be removed until actually release 5.9
|
|
||||||
|
|
||||||
See https://github.com/microsoft/TypeScript/pull/61218#issuecomment-2911264050 for detail
|
|
||||||
|
|
||||||
Intentionally omitted to patch corePublic.ts and the d.ts
|
|
||||||
Including CRLF causes patching error in nixpkgs
|
|
||||||
---
|
|
||||||
package-lock.json | 4 ++--
|
|
||||||
package.json | 2 +-
|
|
||||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/package-lock.json b/package-lock.json
|
|
||||||
index d4d2c055cc..63a0b372d2 100644
|
|
||||||
--- a/package-lock.json
|
|
||||||
+++ b/package-lock.json
|
|
||||||
@@ -1,12 +1,12 @@
|
|
||||||
{
|
|
||||||
"name": "typescript",
|
|
||||||
- "version": "5.9.0",
|
|
||||||
+ "version": "@version@",
|
|
||||||
"lockfileVersion": 2,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"name": "typescript",
|
|
||||||
- "version": "5.9.0",
|
|
||||||
+ "version": "@version@",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"bin": {
|
|
||||||
"tsc": "bin/tsc",
|
|
||||||
diff --git a/package.json b/package.json
|
|
||||||
index ef2c80f8b9..0972bb4648 100644
|
|
||||||
--- a/package.json
|
|
||||||
+++ b/package.json
|
|
||||||
@@ -2,7 +2,7 @@
|
|
||||||
"name": "typescript",
|
|
||||||
"author": "Microsoft Corp.",
|
|
||||||
"homepage": "https://www.typescriptlang.org/",
|
|
||||||
- "version": "5.9.0",
|
|
||||||
+ "version": "@version@",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"description": "TypeScript is a language for application scale JavaScript development",
|
|
||||||
"keywords": [
|
|
||||||
--
|
|
||||||
2.49.0
|
|
||||||
|
|
16
pkgs/by-name/ty/typescript/update.bash
Normal file
16
pkgs/by-name/ty/typescript/update.bash
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
cd "$PKG_DIR"
|
||||||
|
|
||||||
|
# Update lockfile
|
||||||
|
version="$(npm view typescript version)"
|
||||||
|
npm pack typescript
|
||||||
|
tar xvf "typescript-${version}.tgz"
|
||||||
|
mv package/package.json ./
|
||||||
|
npm install --package-lock-only
|
||||||
|
npmDepsHash=$(prefetch-npm-deps ./package-lock.json)
|
||||||
|
rm -rf ./package ./package.json ./"typescript-${version}.tgz"
|
||||||
|
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# Update version and hashes
|
||||||
|
nix-update "$PNAME" --version "$version"
|
||||||
|
sed -E 's#\bnpmDepsHash = ".*?"#npmDepsHash = "'"$npmDepsHash"'"#' -i "$PKG_DIR/package.nix"
|
Loading…
Add table
Add a link
Reference in a new issue