swc: @swc/cli --ignore option is not working
Describe the bug
–ignore option with -d option does not exclude given file from compile.
To reproduce:
- Create a directory
test
- Make two arbitrary js files (
a.js
,b.js
) insidetest
, and make a syntax error witha.js
- run
npx swc test -d out --ignore a.js
- See error messages caused by
a.js
Input code
No response
Config
Default (no .swcrc)
Playground link
No response
Expected behavior
Given files should not be compiled.
Actual behavior
Given files were tried to compile.
Version
@swc/cli: 0.1.55, @swc/core: 1.2.139
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 17
By using exclude in swcrc, you lose the ability to run tests with @swc/jest.
I think this discussion should be moved to @swc/cli. There is already an open issue about this problem –only and --ignore clarity.
@reintroducing
"exclude": [".spec.js"],
this works 🟩it is really counter intuitive for swc to handle it like that and not using globs/ crashing.
if you use
exclude
in the config it works, FYI. Ran into this same issue and that worked for me.@alexn-s Sorry, I just realized i did accomplish it in another repo, by doing the following:
"exclude": [".spec.js"],
Duplicated of https://github.com/swc-project/cli/issues/20
Thanks, but I don’t have authority to do that 😢
You can close the issue with a comment saying “closed in favor of …” or “duplicate of …”. Replace dots with a link to the
swc-project/cli
. Also change the labels of this issue tostale
&duplicate
😃@Phryxia
@alexn-s I tried something similar and found that exclude will not take globs, only directories as far as I could tell. Luckily my stories and tests are in
stories
andtests
folders so I was able to do"exclude": ["tests/", "stories/"],
but when using globs like you show in your code, it was failing.I have a same problem 😭
npx swc src --ignore **/*.stories.tsx --out-dir dist
does not ignore*.stories.tsx
files…