Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tsx files are not getting compile with swc?

I have the following swc configuration in place, but when I compile them with nest.js swc, the tsx files are not compiled at all and no artifact is created for them.

{
  "$schema": "https://json.schemastore.org/swcrc",
  "sourceMaps": true,
  "module": {
    "type": "commonjs"
  },
  "jsc": {
    "target": "es2017",
    "parser": {
      "syntax": "typescript",
      "tsx": true,
      "decorators": true,
      "dynamicImport": true,
    },
    "transform": {
      "legacyDecorator": true,
      "decoratorMetadata": true,
      "react": {
        "refresh": true
      }
    },
    "keepClassNames": true,
    "baseUrl": "./"
  },
  "minify": false
}

Trying to figure out what am I doing wrong?

like image 631
Kerem Kusmezer Avatar asked Oct 30 '25 05:10

Kerem Kusmezer


1 Answers

Set the extensions in your nest-cli.json file.

"compilerOptions": {
  "builder": {
    "type": "swc",
    "options": {
      "extensions": [".js", ".ts", ".jsx", ".tsx"]
    }
  }
}
like image 82
Wannnnn Avatar answered Nov 01 '25 20:11

Wannnnn