Files
paradox-save-parser-frontend/scripts/replace-tsc6-with-tsc7.mjs
T
2026-09-22 19:31:51 +02:00

33 lines
908 B
JavaScript

/**
Replaces tsc6 script which is called by next.js to run tsc 7,
which is a native executable written in go and works faster.
The problem is typescript 7 is supported with nextjs,
but is not supported by eslint which we use for static code analysis.
This script solves the problem.
*/
import { createRequire } from 'node:module'
import { writeFileSync } from 'node:fs'
import path from 'node:path'
const require = createRequire(import.meta.url)
const tsc6 = path.join(
path.dirname(require.resolve('typescript/package.json')),
'bin',
'tsc6'
)
const nativeTsc = path.join(
path.dirname(require.resolve('@typescript/native/package.json')),
'lib',
'tsc.js'
)
const specifier = path
.relative(path.dirname(tsc6), nativeTsc)
.split(path.sep)
.join('/')
writeFileSync(tsc6, `#!/usr/bin/env node\nimport('${specifier}')\n`)
console.log(`patched ${tsc6} -> ${nativeTsc}`)