From 5b9376908af91ca723245b78d3146c1f17107ac4 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Fri, 5 Feb 2021 22:01:48 +1100 Subject: [PATCH] fix(cli/lsp): fix using jsx/tsx when not emitting via tsc (#9407) Closes #9308 Closes #9023 Closes #8993 --- cli/lsp/language_server.rs | 2 ++ cli/module_graph.rs | 2 +- cli/tests/bundle_jsx.out | 10 ++++++++++ cli/tests/integration_tests.rs | 5 +++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 cli/tests/bundle_jsx.out diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index d7d034db02..fa613f6962 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -431,8 +431,10 @@ impl Inner { let mark = self.performance.mark("update_tsconfig"); let mut tsconfig = TsConfig::new(json!({ "allowJs": true, + "esModuleInterop": true, "experimentalDecorators": true, "isolatedModules": true, + "jsx": "react", "lib": ["deno.ns", "deno.window"], "module": "esnext", "noEmit": true, diff --git a/cli/module_graph.rs b/cli/module_graph.rs index e7222289cb..5d1e514d06 100644 --- a/cli/module_graph.rs +++ b/cli/module_graph.rs @@ -799,6 +799,7 @@ impl Graph { // Enabled by default to align to transpile/swc defaults "experimentalDecorators": true, "incremental": true, + "jsx": "react", "isolatedModules": true, "lib": options.lib, "module": "esnext", @@ -811,7 +812,6 @@ impl Graph { // TODO(@kitsonk) consider enabling this by default // see: https://github.com/denoland/deno/issues/7732 "emitDecoratorMetadata": false, - "jsx": "react", "inlineSourceMap": true, "outDir": "deno://", "removeComments": true, diff --git a/cli/tests/bundle_jsx.out b/cli/tests/bundle_jsx.out new file mode 100644 index 0000000000..44c9e45559 --- /dev/null +++ b/cli/tests/bundle_jsx.out @@ -0,0 +1,10 @@ +[WILDCARD] +const React = { + createElement () { + } +}; +function app() { + return React.createElement("div", null, React.createElement("h2", null, "asdf")); +} +console.log(app); + diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index b158c9b55c..dd6b740e32 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2702,6 +2702,11 @@ console.log("finish"); output: "bundle.test.out", }); + itest!(bundle_jsx { + args: "bundle jsx_import_from_ts.ts", + output: "bundle_jsx.out", + }); + itest!(fmt_check_tests_dir { args: "fmt --check ./", output: "fmt/expected_fmt_check_tests_dir.out",