const konan = require("konan");
const path = require("path");
const localRequire = lib => {
  return require(require("path").join(
    process.env.PROJECTPATH,
    "node_modules",
    lib
  ));
};

module.exports = (file, code) => {
  var extname = path.extname(file).toLowerCase();
  if (extname === ".mdx" || extname === ".md") {
    const mdxTransform = localRequire("@mdx-js/mdx").sync;
    code = mdxTransform(code);
  }

  if (extname === ".ts" || extname === ".tsx") {
    const ts = localRequire("typescript");
    var result = ts.transpileModule(code, {
      compilerOptions: {
        module: ts.ModuleKind.CommonJS,
        jsx: ts.JsxEmit.Preserve
      }
    });

    code = result.outputText;
  }

  if (extname === ".vue") {
    const vue = localRequire("@vue/component-compiler-utils");
    const vueTemplateCompiler = localRequire("vue-template-compiler");
    var p = vue.parse({
      source: code,
      needMap: false,
      compiler: vueTemplateCompiler
    });
    code = p && p.script ? p.script.content : "";
  }

  return konan(code);
};

@@ -228,19 +228,21 @@
  =%3E %7B%0A  
-var
+const
  extname
@@ -522,45 +522,22 @@
     
-var result = ts.transpileModule(code,
+const config =
  %7B%0A 
@@ -602,22 +602,89 @@
 onJS
-,
 %0A      
-  jsx:
+%7D%0A    %7D;%0A%0A    if (extname === %22.tsx%22) %7B%0A      config.compilerOptions.jsx =
  ts.
@@ -699,30 +699,74 @@
 Preserve
+;
 %0A    
-  %7D%0A    %7D
+%7D%0A    const result = ts.transpileModule(code, config
 );%0A%0A    
@@ -966,11 +966,13 @@
     
-var
+const
  p =

Fix TS to not be parsed as TSX