Skip to content

How to compile both .js and .ts? #1877

Answered by marcenacp
marcenacp asked this question in Q&A
Discussion options

You must be logged in to vote

.swrc accepts a list of configurations, so you can add several parsers.

Example:

[
  {
    "test": ".tsx?$",
    "jsc": {
      "parser": {
        "syntax": "typescript",
        "tsx": true,
        "decorators": false,
        "dynamicImport": true
      },
      "transform": {
        "react": {
          "refresh": true
        }
      }
    }
  },
  {
    "test": ".jsx?$",
    "jsc": {
      "parser": {
        "syntax": "ecmascript",
        "jsx": true,
        "decorators": false,
        "dynamicImport": true
      },
      "transform": {
        "react": {
          "refresh": true
        }
      }
    }
  }
]

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@mrtnpro
Comment options

@sidhuko
Comment options

@DavFeng1
Comment options

@hugotox
Comment options

@kdy1
Comment options

Answer selected by marcenacp
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants