UNPKG

@reliverse/rse

Version:

@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power

45 lines (44 loc) 1.57 kB
import path from "@reliverse/pathkit"; import fs from "@reliverse/relifso"; import { relinka } from "@reliverse/relinka"; import { defineTSConfig, writeTSConfig } from "pkg-types"; export async function createTSConfig(projectPath, isLib, isDev) { const tsconfig = defineTSConfig({ compilerOptions: { esModuleInterop: true, skipLibCheck: true, target: "es2022", allowJs: true, resolveJsonModule: true, moduleDetection: "force", isolatedModules: true, verbatimModuleSyntax: true, strict: true, noUncheckedIndexedAccess: true, noImplicitOverride: true, ...isLib ? { lib: ["es2022"] } : { module: "preserve", noEmit: true, lib: ["es2022", "dom", "dom.iterable"] } }, ...isLib ? { include: ["**/*.ts"] } : { include: ["**/*.ts", "**/*.tsx"] }, exclude: ["node_modules"] }); const useTxt = isDev && projectPath.includes("tests-runtime"); const filename = useTxt ? "tsconfig.txt" : "tsconfig.json"; const tsconfigPath = path.join(projectPath, filename); if (useTxt) { const rawContent = JSON.stringify(tsconfig, null, 2); await fs.writeFile(tsconfigPath, rawContent, "utf-8"); } else { await writeTSConfig(tsconfigPath, tsconfig); const content = await fs.readFile(tsconfigPath, "utf-8"); const formatted = JSON.stringify(JSON.parse(content), null, 2); await fs.writeFile(tsconfigPath, formatted, "utf-8"); } relinka( "verbose", `Created ${filename} with ${isLib ? "library" : "application"} configuration` ); }