@@ -96,6 +96,15 @@ STORED_VERSION_FILE := VERSION
96
96
GITHUB_REF_TYPE ?= branch
97
97
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
98
98
99
+ # Enable typescript support in Node.js before 22.18
100
+ # TODO: Remove this once we can raise the minimum Node.js version to 22.18 (alpine >= 3.23)
101
+ NODE_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell node -v 2>/dev/null | cut -c2- | tr '.' ' ') )
102
+ ifeq ($(shell test "$(NODE_VERSION ) " -lt "022018000"; echo $$? ) ,0)
103
+ NODE_VARS := NODE_OPTIONS="--experimental-strip-types"
104
+ else
105
+ NODE_VARS :=
106
+ endif
107
+
99
108
ifneq ($(GITHUB_REF_TYPE ) ,branch)
100
109
VERSION ?= $(subst v,,$(GITHUB_REF_NAME))
101
110
GITEA_VERSION ?= $(VERSION)
@@ -217,7 +226,6 @@ git-check:
217
226
node-check :
218
227
$(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.* [0-9.]+"' package.json | sed -n 's/.* [^0-9.]\([0-9.]* \) "/1円/p') )
219
228
$(eval MIN_NODE_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell echo '$(MIN_NODE_VERSION_STR ) ' | tr '.' ' ') ) )
220
- $(eval NODE_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell node -v | cut -c2- | tr '.' ' ') ;) )
221
229
$(eval PNPM_MISSING := $(shell hash pnpm > /dev/null 2>&1 || echo 1) )
222
230
@if [ " $( NODE_VERSION) " -lt " $( MIN_NODE_VERSION) " ]; then \
223
231
echo " Gitea requires Node.js $( MIN_NODE_VERSION_STR) or greater to build. You can get it at https://nodejs.org/en/download/" ; \
@@ -338,29 +346,29 @@ lint-backend-fix: lint-go-fix lint-go-gitea-vet lint-editorconfig ## lint backen
338
346
339
347
.PHONY : lint-js
340
348
lint-js : node_modules # # lint js files
341
- pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES )
342
- pnpm exec vue-tsc
349
+ $( NODE_VARS ) pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES )
350
+ $( NODE_VARS ) pnpm exec vue-tsc
343
351
344
352
.PHONY : lint-js-fix
345
353
lint-js-fix : node_modules # # lint js files and fix issues
346
- pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES ) --fix
347
- pnpm exec vue-tsc
354
+ $( NODE_VARS ) pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES ) --fix
355
+ $( NODE_VARS ) pnpm exec vue-tsc
348
356
349
357
.PHONY : lint-css
350
358
lint-css : node_modules # # lint css files
351
- pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES )
359
+ $( NODE_VARS ) pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES )
352
360
353
361
.PHONY : lint-css-fix
354
362
lint-css-fix : node_modules # # lint css files and fix issues
355
- pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES ) --fix
363
+ $( NODE_VARS ) pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES ) --fix
356
364
357
365
.PHONY : lint-swagger
358
366
lint-swagger : node_modules # # lint swagger files
359
- pnpm exec spectral lint -q -F hint $(SWAGGER_SPEC )
367
+ $( NODE_VARS ) pnpm exec spectral lint -q -F hint $(SWAGGER_SPEC )
360
368
361
369
.PHONY : lint-md
362
370
lint-md : node_modules # # lint markdown files
363
- pnpm exec markdownlint * .md
371
+ $( NODE_VARS ) pnpm exec markdownlint * .md
364
372
365
373
.PHONY : lint-spell
366
374
lint-spell : # # lint spelling
@@ -421,7 +429,7 @@ watch: ## watch everything and continuously rebuild
421
429
.PHONY : watch-frontend
422
430
watch-frontend : node-check node_modules # # watch frontend files and continuously rebuild
423
431
@rm -rf $(WEBPACK_DEST_ENTRIES )
424
- NODE_ENV=development pnpm exec webpack --watch --progress --disable-interpret
432
+ NODE_ENV=development $( NODE_VARS ) pnpm exec webpack --watch --progress --disable-interpret
425
433
426
434
.PHONY : watch-backend
427
435
watch-backend : go-check # # watch backend files and continuously rebuild
@@ -437,7 +445,7 @@ test-backend: ## test backend files
437
445
438
446
.PHONY : test-frontend
439
447
test-frontend : node_modules # # test frontend files
440
- pnpm exec vitest
448
+ $( NODE_VARS ) pnpm exec vitest
441
449
442
450
.PHONY : test-check
443
451
test-check :
@@ -580,7 +588,7 @@ test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test
580
588
581
589
.PHONY : playwright
582
590
playwright : deps-frontend
583
- pnpm exec playwright install $(PLAYWRIGHT_FLAGS )
591
+ $( NODE_VARS ) pnpm exec playwright install $(PLAYWRIGHT_FLAGS )
584
592
585
593
.PHONY : test-e2e%
586
594
test-e2e% : TEST_TYPE ?= e2e
@@ -844,7 +852,7 @@ deps-tools: ## install tool dependencies
844
852
wait
845
853
846
854
node_modules : pnpm-lock.yaml
847
- pnpm install --frozen-lockfile
855
+ $( NODE_VARS ) pnpm install --frozen-lockfile
848
856
@touch node_modules
849
857
850
858
.venv : uv.lock
@@ -856,16 +864,16 @@ update: update-js update-py ## update js and py dependencies
856
864
857
865
.PHONY : update-js
858
866
update-js : node-check | node_modules # # update js dependencies
859
- pnpm exec updates -u -f package.json
867
+ $( NODE_VARS ) pnpm exec updates -u -f package.json
860
868
rm -rf node_modules pnpm-lock.yaml
861
- pnpm install
862
- pnpm exec nolyfill install
863
- pnpm install
869
+ $( NODE_VARS ) pnpm install
870
+ $( NODE_VARS ) pnpm exec nolyfill install
871
+ $( NODE_VARS ) pnpm install
864
872
@touch node_modules
865
873
866
874
.PHONY : update-py
867
875
update-py : node-check | node_modules # # update py dependencies
868
- pnpm exec updates -u -f pyproject.toml
876
+ $( NODE_VARS ) pnpm exec updates -u -f pyproject.toml
869
877
rm -rf .venv uv.lock
870
878
uv sync
871
879
@touch .venv
@@ -877,7 +885,7 @@ $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) pnpm-lock.yaml
877
885
@$(MAKE ) -s node-check node_modules
878
886
@rm -rf $(WEBPACK_DEST_ENTRIES )
879
887
@echo " Running webpack..."
880
- @BROWSERSLIST_IGNORE_OLD_DATA=true pnpm exec webpack --disable-interpret
888
+ @BROWSERSLIST_IGNORE_OLD_DATA=true $( NODE_VARS ) pnpm exec webpack --disable-interpret
881
889
@touch $(WEBPACK_DEST )
882
890
883
891
.PHONY : svg
@@ -897,7 +905,7 @@ svg-check: svg
897
905
898
906
.PHONY : lockfile-check
899
907
lockfile-check :
900
- pnpm install --frozen-lockfile
908
+ $( NODE_VARS ) pnpm install --frozen-lockfile
901
909
@diff=$$(git diff --color=always pnpm-lock.yaml ) ; \
902
910
if [ -n " $$ diff" ]; then \
903
911
echo " pnpm-lock.yaml is inconsistent with package.json" ; \
0 commit comments