Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excluded files throw errors when compiling #80

Open
JeremyGrieshop opened this issue Oct 27, 2021 · 2 comments
Open

Excluded files throw errors when compiling #80

JeremyGrieshop opened this issue Oct 27, 2021 · 2 comments

Comments

@JeremyGrieshop
Copy link

JeremyGrieshop commented Oct 27, 2021

Here's my configuration .swcrc:

 [ 
  {
    "test": ".*.js$",
    "exclude": [
        "__tests__"
    ],
    "module": {
      "type": "commonjs"
    },
    "jsc": {
      "parser": {
        "syntax": "ecmascript",
        "jsx": true
      },
      "transform": {
          "react": {
              "runtime": "automatic"
          }
      },
      "loose": true
    }
  },
  {
    "test": ".*.ts$",
    "exclude": [
        "__tests__"
    ],
    "module": {
      "type": "commonjs"
    },
    "jsc": {
      "parser": {
        "syntax": "typescript",
        "tsx": true
      },
      "transform": {
          "react": {
              "runtime": "automatic"
          }
      },
      "loose": true
    }
  }
]

The strategy is pretty simple: For .js files, use ecmascript syntax and compile to commonjs module. For .ts files, use typescript syntax and also compile to commonjs module format. In both cases, just ignore __tests__.

When I run:

npx swc src -d lib -s --sync

It tries to compile .test.js files, but complain that there's no matching configuration for them:

failed to process js file

Caused by:
    0: failed to load config for file 'Real("src/__tests__/AfwClient.test.js")'
    1: failed to read swcrc file (src/__tests__/AfwClient.test.js)
    2: failed to process config file
    3: .swcrc exists but not matched

Do I need to match .test.js files in another entry and figure out how to noop them? Using --exclude doesn't seem to help, either. The docs are not very thorough about how configuration all works together. Especially with multiple entries.

npx swc --version

@swc/cli: 0.1.51
@swc/core: 1.2.103
@theogravity
Copy link

Having this problem too on cli 0.1.57 and core 1.2.177

@pp0rtal
Copy link

pp0rtal commented May 15, 2023

Having the issue with core 1.3.53.
I believe exclude is core, where my ticket in swc-project/swc#7325

I have created a minim project to reproduce the issue https://github.com/pp0rtal/swc-bug-node_modules-interfer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants