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

Unable to parse file names starting with - #10146

Open
pullard opened this issue Mar 4, 2025 · 0 comments
Open

Unable to parse file names starting with - #10146

pullard opened this issue Mar 4, 2025 · 0 comments
Labels

Comments

@pullard
Copy link

pullard commented Mar 4, 2025

Describe the bug

The swc CLI fails to correctly parse filenames that start with a - (dash) character. Albeit an odd file name, it should still be treated as valid.

Input code

swc compile --config-file .swcrc --source-file-name -3-d-world.ts --out-file -3-d-world.js

Config

{
  "$schema": "https://json.schemastore.org/swcrc",
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "decorators": true
    },
    "transform": {
      "legacyDecorator": true,
      "decoratorMetadata": true
    }
  }
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.11.5&code=H4sIAAAAAAAAA0utKMgvKlEoqSxIVYg3dgnPL8pJUbBVUM8tTc5QV6hRUC%2FPL1e3BgAMZnHUJgAAAA%3D%3D&config=H4sIAAAAAAAAA1VPOw7DIAzdOQXy3KFi6NA79BCIOhERAYQdqSjK3QsJpM1mv4%2Ff8yqkhIkMPOVaxrJEnQjTuReEsmf9KQhwjkgm2chw6yxTpQbtCHdoOxhgnUbk6kJSd6WaA1wIhN3RsNl6O%2BT%2FTBPmmJDoKqxS7UeH10TRUmEO72Un2y%2B179HgAT9RDzsPg6VXd3JaUGxfBMLf3xcBAAA%3D

SWC Info output

Operating System:
Platform: linux
Arch: x64
Machine Type: x86_64
Version: #25~22.04.1-Ubuntu SMP Tue Jan 28 12:51:22 UTC 2025
CPU: (4 cores)
Models: Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz

Binaries:
    Node: 18.18.2
    npm: 9.8.1
    Yarn: N/A
    pnpm: 9.15.3

Relevant Packages:
    @swc/core: 1.11.5
    @swc/helpers: N/A
    @swc/types: N/A
    typescript: 5.1.6

SWC Config:
    output: N/A
    .swcrc path: N/A

Next.js info:
    output: N/A

Expected behavior

The CLI tool should correctly ingest and compile the file.

Actual behavior

Depending on the options passed I get the following errors:

First variation:

If you tried to supply `-3` as a value rather than a flag, use `-- -3`

USAGE:
    swc-linux-x64-gnu compile [OPTIONS] [FILES]...

Second variation:

error: unknown option '-3-d-world.ts'

Version

1.11.5

Additional context

No response

@pullard pullard added the C-bug label Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant