feat: replace ts-node with tsx (#59019)

This commit is contained in:
Naomi
2025-03-11 19:55:54 +00:00
committed by GitHub
parent c444541a0b
commit 0b96c09e84
11 changed files with 4501 additions and 1853 deletions
-6
View File
@@ -1,9 +1,3 @@
// We need to use the triple-slash directive to ensure that ts-node uses the
// reset.d.ts file. It's not possible to import the file directly because it
// is not included in the build (it's a dev dependency).
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="./reset.d.ts" />
import './instrument';
import { randomBytes } from 'crypto';
+5 -6
View File
@@ -24,17 +24,17 @@
"build:scripts": "pnpm run -F=browser-scripts build",
"clean": "gatsby clean",
"common-setup": "pnpm -w run create:shared && pnpm run create:env && pnpm run create:trending && pnpm run create:search-placeholder",
"create:env": "DEBUG=fcc:* ts-node ./tools/create-env.ts",
"create:trending": "ts-node ./tools/download-trending.ts",
"create:search-placeholder": "ts-node ./tools/generate-search-placeholder",
"create:env": "DEBUG=fcc:* tsx ./tools/create-env.ts",
"create:trending": "tsx ./tools/download-trending.ts",
"create:search-placeholder": "tsx ./tools/generate-search-placeholder",
"predevelop": "pnpm run common-setup && pnpm run build:scripts --env development",
"develop": "NODE_OPTIONS=\"--max-old-space-size=7168\" gatsby develop --inspect=9230",
"lint": "ts-node ./i18n/schema-validation.ts",
"lint": "tsx ./i18n/schema-validation.ts",
"serve": "gatsby serve -p 8000",
"serve-ci": "serve -l 8000 -c serve.json public",
"prestand-alone": "pnpm run prebuild",
"stand-alone": "gatsby develop",
"validate-keys": "ts-node --project ../tsconfig.json ../tools/scripts/lint/validate-keys"
"validate-keys": "tsx --tsconfig ../tsconfig.json ../tools/scripts/lint/validate-keys"
},
"dependencies": {
"@babel/plugin-proposal-export-default-from": "7.23.3",
@@ -169,7 +169,6 @@
"react-test-renderer": "17.0.2",
"redux-saga-test-plan": "4.0.6",
"serve": "13.0.4",
"ts-node": "10.9.2",
"webpack": "5.90.3"
}
}
+1 -8
View File
@@ -22,12 +22,5 @@
"utils/**/*",
"tools/**/*",
"config/**/*"
], // since ts-node compiles ts on the fly and then uses node, it needs to
// compile the scripts to commonjs (or node will complain about the requires)
"ts-node": {
"compilerOptions": {
"module": "commonjs"
},
"transpileOnly": true
}
]
}
+19 -19
View File
@@ -18,26 +18,26 @@
"homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme",
"author": "freeCodeCamp <team@freecodecamp.org>",
"scripts": {
"build": "ts-node --project ../tsconfig.json ../tools/scripts/build/build-curriculum",
"create-empty-steps": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/create-empty-steps",
"create-next-challenge": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/create-next-challenge",
"create-this-challenge": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/create-this-challenge",
"create-next-step": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/create-next-step",
"create-next-task": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/create-next-task",
"insert-challenge": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/insert-challenge",
"insert-step": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/insert-step",
"insert-task": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/insert-task",
"build": "tsx --tsconfig ../tsconfig.json ../tools/scripts/build/build-curriculum",
"create-empty-steps": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/create-empty-steps",
"create-next-challenge": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/create-next-challenge",
"create-this-challenge": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/create-this-challenge",
"create-next-step": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/create-next-step",
"create-next-task": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/create-next-task",
"insert-challenge": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/insert-challenge",
"insert-step": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/insert-step",
"insert-task": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/insert-task",
"install-puppeteer": "puppeteer browsers install chrome",
"delete-step": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/delete-step",
"delete-challenge": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/delete-challenge",
"delete-task": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/delete-task",
"lint": "ts-node --project ../tsconfig.json lint-localized",
"repair-meta": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/repair-meta",
"reorder-tasks": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/reorder-tasks",
"update-challenge-order": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/update-challenge-order",
"update-step-titles": "CALLING_DIR=$INIT_CWD ts-node --project ../tsconfig.json ../tools/challenge-helper-scripts/update-step-titles",
"test": "NODE_OPTIONS='--max-old-space-size=7168' ts-node ./node_modules/mocha/bin/mocha.js --delay --exit --reporter progress --bail",
"test:full-output": "NODE_OPTIONS='--max-old-space-size=7168' FULL_OUTPUT=true ts-node ./node_modules/mocha/bin/mocha.js --delay --reporter progress"
"delete-step": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/delete-step",
"delete-challenge": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/delete-challenge",
"delete-task": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/delete-task",
"lint": "tsx --tsconfig ../tsconfig.json lint-localized",
"repair-meta": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/repair-meta",
"reorder-tasks": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/reorder-tasks",
"update-challenge-order": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/update-challenge-order",
"update-step-titles": "CALLING_DIR=$INIT_CWD tsx --tsconfig ../tsconfig.json ../tools/challenge-helper-scripts/update-step-titles",
"test": "NODE_OPTIONS='--max-old-space-size=7168' tsx ./node_modules/mocha/bin/mocha.js --delay --exit --reporter progress --bail",
"test:full-output": "NODE_OPTIONS='--max-old-space-size=7168' FULL_OUTPUT=true tsx ./node_modules/mocha/bin/mocha.js --delay --reporter progress"
},
"devDependencies": {
"@babel/core": "7.23.7",
+4 -4
View File
@@ -20,7 +20,7 @@
"main": "none",
"scripts": {
"preinstall": "npx -y only-allow pnpm",
"audit-challenges": "pnpm run create:shared && ts-node tools/challenge-auditor/index.ts",
"audit-challenges": "pnpm run create:shared && tsx tools/challenge-auditor/index.ts",
"analyze-bundle": "webpack-bundle-analyzer",
"prebuild": "npm-run-all create:shared",
"build": "npm-run-all -p build:*",
@@ -47,7 +47,7 @@
"format": "run-s format:eslint format:prettier",
"format:eslint": "eslint . --fix",
"format:prettier": "prettier --write .",
"i18n-sync": "ts-node ./tools/scripts/sync-i18n.ts",
"i18n-sync": "tsx ./tools/scripts/sync-i18n.ts",
"knip": "npx -y knip@5 --include files",
"knip:all": "npx -y knip@5 ",
"prelint": "pnpm run -F=client predevelop",
@@ -60,7 +60,7 @@
"reload:server": "pm2 reload api-server/ecosystem.config.js",
"preseed": "npm-run-all create:shared",
"playwright:install-build-tools": "npx playwright install --with-deps",
"rename-challenges": "ts-node tools/challenge-helper-scripts/rename-challenge-files.ts",
"rename-challenges": "tsx tools/challenge-helper-scripts/rename-challenge-files.ts",
"seed": "pnpm seed:surveys && pnpm seed:exams && DEBUG=fcc:* node ./tools/scripts/seed/seed-demo-user",
"seed:certified-user": "pnpm seed:surveys && pnpm seed:exams && pnpm seed:ms-username && DEBUG=fcc:* node ./tools/scripts/seed/seed-demo-user --certified-user",
"seed:exams": "DEBUG=fcc:* node tools/scripts/seed-exams/create-exams",
@@ -131,7 +131,7 @@
"prettier": "3.2.5",
"prismjs": "1.29.0",
"stylelint": "16.14.1",
"ts-node": "10.9.2",
"tsx": "4.19.1",
"typescript": "5.7.3",
"typescript-eslint": "^8.23.0",
"webpack-bundle-analyzer": "4.10.1",
+4467 -1795
View File
File diff suppressed because it is too large Load Diff
+2 -3
View File
@@ -4,7 +4,7 @@
"private": true,
"description": "Editor to help with new challenge structure",
"scripts": {
"start": "ts-node server.ts",
"start": "tsx server.ts",
"postinstall": "shx cp ./sample.env ./.env"
},
"author": "freeCodeCamp",
@@ -12,8 +12,7 @@
"dependencies": {
"cors": "2.8.5",
"express": "4.18.2",
"gray-matter": "4.0.3",
"ts-node": "10.9.2"
"gray-matter": "4.0.3"
},
"devDependencies": {
"@types/cors": "^2.8.13",
+1 -2
View File
@@ -20,7 +20,7 @@
"main": "utils.js",
"scripts": {
"test": "mocha --delay --reporter progress --bail",
"create-project": "ts-node create-project"
"create-project": "tsx create-project"
},
"devDependencies": {
"@types/glob": "^8.0.1",
@@ -30,7 +30,6 @@
"gray-matter": "4.0.3",
"inquirer": "8.2.6",
"prettier": "3.2.5",
"ts-node": "10.9.2",
"typescript": "5.2.2"
}
}
+1 -1
View File
@@ -2,7 +2,7 @@ import fs from 'fs';
import path from 'path';
/* This can be used to create NGINX maps for redirects. After running this
script with `npx ts-node redirect-gen`, the map should appear in the current
script with `npx tsx redirect-gen`, the map should appear in the current
directory.
*/
-8
View File
@@ -15,13 +15,5 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"types": ["node", "jest"]
},
// since ts-node compiles ts on the fly and then uses node, it needs to
// compile the scripts to commonjs (or node will complain about the requires)
"ts-node": {
"compilerOptions": {
"module": "commonjs"
},
"transpileOnly": true
}
}