From 68649ebb5d7374dbc1e7eff5eeb42093ecab73c7 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Sat, 2 Nov 2024 21:27:49 +0000 Subject: [PATCH] [*] i really cant be arsed anymore --- Core/OtherLang/TS/TS.lua | 64 +++++++++++++++++++++++++++++++++++----- Public/settings.lua | 2 ++ 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/Core/OtherLang/TS/TS.lua b/Core/OtherLang/TS/TS.lua index 0fe3092..0cd2886 100644 --- a/Core/OtherLang/TS/TS.lua +++ b/Core/OtherLang/TS/TS.lua @@ -1,4 +1,5 @@ local kPathPrefix = "!" +local kOldMode = false local function processJson(meta, object, result) auMergeTable(object, @@ -72,6 +73,7 @@ local function processProject(meta, object) args = args .. ' --sourceMap' args = args .. ' --declarationMap' args = args .. ' --inlineSources' + args = args .. ' --resolveJsonModule' args = args .. ' --module ' .. object.module args = args .. ' --moduleDetection ' .. object.moduleDetection args = args .. ' --sourceRoot \"' .. rootdir .. "\"" @@ -148,11 +150,13 @@ local function processProject(meta, object) table.insert(ew3, rootdir .. "/" .. func:gsub("%*%*.", "**/*.")) table.insert(ew3, rootdir .. "/" .. func:gsub("%*%*.", "*.")) end) - - auAddBuildAction("pre", "cmd", "tsc", false, args) - + + if (kOldMode) then + auAddBuildAction("pre", "cmd", "tsc", false, args) + else + auAddBuildAction("pre", "cmd", "tsc", false, "--project \"" .. rootdir .. "\"") + end - local requiredDirs = {} local requiredCopies = {} @@ -167,6 +171,8 @@ local function processProject(meta, object) mkdir = "mkdir -p \"PATH\""; end + local primarySourceList = {} + local primaryTypeList = {} if (object.bundle) then else @@ -193,6 +199,8 @@ local function processProject(meta, object) local dbg2p = part .. ".d.ts.map" if (not isD) then + table.insert(primarySourceList, part) + auForEach(meta.out, function(dest) if (dest:starts(kPathPrefix)) then dest = Aurora.Settings.sAbsWd .. dest:sub(#kPathPrefix + 1) @@ -222,6 +230,8 @@ local function processProject(meta, object) path.translate(path.normalize(path.join(compilerPath, link)), path.getDefaultSeparator()), path.translate(path.normalize(path.join(linkPath, link2)), path.getDefaultSeparator()), pathSuffix)) else + table.insert(primaryTypeList, part) + prebuildcommands(string.format("{COPY} \"%s\" \"%s%s", file, path.translate(path.normalize(path.join(linkPath, link2)), path.getDefaultSeparator()), pathSuffix)) @@ -233,18 +243,58 @@ local function processProject(meta, object) local compilerOptions = {} auMergeTable(compilerOptions, object.flags) + + if (not kOldMode) then + table.remove(typeDirs, 1) + end + compilerOptions.typeRoots = typeDirs compilerOptions.target = object.targetVersion compilerOptions.module = object.module - compilerOptions.moduleDetection = object.moduleDetection + + if (not kOldMode) then + if (object.bundle) then + compilerOptions.outFile = path.normalize(path.join(compilerPath, meta.name)) .. ".js" + end + + compilerOptions.declaration = true + compilerOptions.moduleDetection = object.moduleDetection + compilerOptions.resolveJsonModule = true + compilerOptions.inlineSources = true + compilerOptions.declarationMap = true + compilerOptions.sourceMap = true + compilerOptions.sourceRoot = rootdir + compilerOptions.mapRoot = path.normalize(symPath) + compilerOptions.rootDir = rootdir + compilerOptions.outDir = compilerPath + compilerOptions.moduleResolution = "classic" + end local IDE = { - autogeneratedfile = "DO NOT MODIFY OR ATTEMPT TO COMPILE. IDE LINT, TOOLTIP, AND AUTOCOMPLETE USAGE ONLY", + --autogeneratedfile = "DO NOT MODIFY OR ATTEMPT TO COMPILE. IDE LINT, TOOLTIP, AND AUTOCOMPLETE USAGE ONLY", include = auMergeArray(ew3, ew2), compilerOptions = compilerOptions } + + local extended = { + base = IDE, + files = object.files, + out = meta.out, + typeSources = ew3, + expandedSources = ew2, + settings = Aurora.Settings, + dependsNoSource = object.depends2, + dependsWithSource = object.depends, + primarySourceList = primarySourceList, + primaryTypeList = primaryTypeList + } - io.writefile("tsconfig.json", json.encode(IDE, 4)) + io.writefile("tsconfig.json", json.encode_pretty(IDE)) + + if (Aurora.Settings.bWantExtendedTSConfig) then + io.writefile("tsconfig.extended.json", json.encode_pretty(extended)) + end + files "tsconfig.json" end end diff --git a/Public/settings.lua b/Public/settings.lua index 5586860..c94277a 100644 --- a/Public/settings.lua +++ b/Public/settings.lua @@ -126,6 +126,8 @@ auSetDefault(settings, "bForceWin32EscLd", true) auSetDefault(settings, "bActionsIncludeFull", false) +auSetDefault(settings, "bWantExtendedTSConfig", true) + -- Premake5 binary name to look for when when tied into cmake. Used by build actions and other lua scripted features auSetDefault(settings, "sDefaultCmakePremakeBin", "premake5")