rguerin
rguerin

Reputation: 2128

How to ignore files with @swc/cli?

I am using swc to transpile my Typescript code on a side project and am struggling ignoring the tests files from the final output using the cli --ignore option.

lib versions:

 @swc/cli: ^0.1.57
 @swc/core: ^1.2.173

command:

swc ./src --out-dir dist --ignore **/*.test.ts

.swrc config

{
  "jsc": {
    "target": "es5",
    "paths": {
      "@src/*": ["./src/*"]
    },
    "parser": {
      "syntax": "typescript",
      "decorators": true,
      "dynamicImport": true
    }
  },
  "minify": true,
}

I still saw all tests files in my dist output folder. Note that using the exclude property in the .swcrc like this "exclude": [".*\\.spec|test\\.(j|t)s$", "mocks", "types"] works, but how is the --ignore arg supposed to be used ?

Upvotes: 8

Views: 2545

Answers (1)

Oleg Abrazhaev
Oleg Abrazhaev

Reputation: 2839

Given the swc --help output

--ignore [list] list of glob paths to not compile

The expected format is the same as you would write in .swcrc file, as it is shown in docs: https://swc.rs/docs/usage/cli#--ignore

But there was an ongoing issue, that was solved only in January 2024.

Ignore CLI option and exclude in the config were not working properly. This is the issue you most likely faced.

Upvotes: 0

Related Questions