Comment

Melroy van den Berg

Actually is quite easy. You first need to add SWC (core + cli) to your project: `npm i -D @swc/cli @swc/core`

Add an new `.swcrc` to your root folder, with the content:

```json
{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false,
      "decorators": false,
      "dynamicImport": false
    },
    "target": "esnext"
  },
  "module": {
    "type": "es6"
  },
  "sourceMaps": true
}

```

Changing your package.json to use swc could be as simple as:

```json
"main": "dist/index.js",
"scripts": {
    "start": "swc ./src -d dist --strip-leading-paths && node .",
    ....
    ....
}
```

In this example above I will use `swc` command to compile the src directory, outputs into the dist directory. I also don't want the leading path (eg. /src) but you can remove that flag if you wish.
Then I just run node, which will execute the "main" from package.json (aka dist/index.js file created by SWC...).

In your `tsconfig.json` file you can configure also ts-node if you wish to use SWC with ts-node with nodemon or something like that:

```
  "ts-node": {
    "files": true,
    "swc": true,
    "esm": true,
  },
```

More info: https://swc.rs/docs/getting-started. And yes you're right NextJS also has support for it: https://docs.nestjs.com/recipes/swc

Parent comment

Peter Bengtsson

"our TypeScript environment"? I've never actually understood how SWC works. There was talk about it being enabled by default in Next.js but Next.js is slow. "using Fastify, that can be run on various runtimes" Yeah, that's awesome!