How to setup SWC compiler

182
February 07, 2022, at 10:10 PM

I'm using SWC for the first time and I'm not able to compile my ts files into normal js files.

When I run my command :

npx swc ./src -d dist

I got the error :

failed to process js file
Caused by:
    0: failed to read swcrc file (src/index.ts)
    1: failed to deserialize .swcrc (json) file: syntax error: 1:1
    2: expected value at line 1 column 1

Here is my.swcrc I have generated with the SWC Playground

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "commonjs"
  },
  "minify": false,
  "isModule": true,
  "sourceMaps": "inline"
}

My goal is to :

  • Take my ts files from my ./src dir
  • Compile and output it in a dist dir with source maps enabled
Rent Charter Buses Company
READ ALSO
html does not respect the font-family set in a style

html does not respect the font-family set in a style

I have reduced my problem to a trival example:

53
changing from old syntax of React Router: rendering white screen

changing from old syntax of React Router: rendering white screen

I have been following the Learning React: A Hands-On Guide to Building Web Applications Using React and Redux book but as it is the old book so some of its syntax have been changedNow, I am at the react router chapter and have to change old syntax to current...

112
Plot polygon with centroid located exterior/outside of polygon

Plot polygon with centroid located exterior/outside of polygon

How do I plot a polygon with the centroid located outside of the polygon in Python?

94