From f84b832e61e6e349f67ea52cbe6c906d888acb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Tue, 10 Dec 2024 13:57:13 +0100 Subject: [PATCH] Add elaborating comment to analyze --- waspc/src/Wasp/Project/WaspFile.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/waspc/src/Wasp/Project/WaspFile.hs b/waspc/src/Wasp/Project/WaspFile.hs index fc94cbb547..f1d16299f8 100644 --- a/waspc/src/Wasp/Project/WaspFile.hs +++ b/waspc/src/Wasp/Project/WaspFile.hs @@ -117,9 +117,23 @@ compileWaspTsFile waspProjectDir tsconfigNodeFileInWaspProjectDir waspFilePath = ( runNodeCommandAsJob waspProjectDir "npx" + -- We're using tsc to compile the *.wasp.ts file into a JS file. + -- + -- The compilation rules mostly come from tsconfig.wasp.json but also + -- include several overrides: + -- - We don't keep all the rules in tsconfig.wasp.json because it + -- would give users a way to break things. + -- - We don't keep all the rules here (inline) because users would + -- suffer bad DX (no IDE support in *.wasp.ts file). [ "tsc", "-p", fromAbsFile (waspProjectDir tsconfigNodeFileInWaspProjectDir), + -- The tsconfig.wasp.json file has the noEmit flag on. + -- The file only exists IDE support, and we don't want users to + -- accidentally chage the outDir. + -- + -- Here, to actually generate the JS file in the desired location, + -- we must turn off the noEmit flag and specify the outDir. "--noEmit", "false", "--outDir", @@ -133,6 +147,8 @@ compileWaspTsFile waspProjectDir tsconfigNodeFileInWaspProjectDir waspFilePath = ExitSuccess -> Right absCompiledWaspJsFile where outDir = waspProjectDir dotWaspDirInWaspProjectDir + -- We know this will be the output JS file's location because it's how TSC + -- works (assuming we've specified the outDir, which we did). absCompiledWaspJsFile = outDir compiledWaspJsFileInDotWaspDir compiledWaspJsFileInDotWaspDir = castFile $