From 587f2e0800a55e58b2579758d4278a4129b609c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 1 Nov 2023 21:30:23 +0100 Subject: feat: precompile JSX (#20962) Co-authored-by: Marvin Hagemeister --- cli/tsc/99_main_compiler.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'cli/tsc') diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index a2079c01e..4c750cfe7 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -862,12 +862,25 @@ delete Object.prototype.__proto__; } } + /** @param {Record} config */ + function normalizeConfig(config) { + // the typescript compiler doesn't know about the precompile + // transform at the moment, so just tell it we're using react-jsx + if (config.jsx === "precompile") { + config.jsx = "react-jsx"; + } + return config; + } + /** The API that is called by Rust when executing a request. * @param {Request} request */ function exec({ config, debug: debugFlag, rootNames, localOnly }) { setLogDebug(debugFlag, "TS"); performanceStart(); + + config = normalizeConfig(config); + if (logDebug) { debug(">>> exec start", { rootNames }); debug(config); @@ -983,8 +996,9 @@ delete Object.prototype.__proto__; return respond(id, true); } case "$configure": { + const config = normalizeConfig(args[0]); const { options, errors } = ts - .convertCompilerOptionsFromJson(args[0], ""); + .convertCompilerOptionsFromJson(config, ""); Object.assign(options, { allowNonTsExtensions: true, allowImportingTsExtensions: true, -- cgit v1.2.3