swc icon indicating copy to clipboard operation
swc copied to clipboard

.swcrc doesn't seem to be picked up and used in @swc/core transform or weback swc-loader

Open stephencranedesign opened this issue 2 years ago • 2 comments

Describe the bug

running transform from @swc/core and webpack swc-loader doesn't seem to pickup the typescript jsc.parser syntax defined in the .swcrc file.

if i take the same jsc.parser config from the .swcrc file and use it directly in the options for @swc/core or swc-loader, then swc recongizes the typescript and doesn't throw an error.

Input code

No response

Config

[
    {
        "env": {
            "targets": "defaults"
        }
    },
    {
        "test": ".tsx?$",
        "jsc": {
            "parser": {
                "syntax": "typescript",
                "tsx": true
            }
        }
    },
    {
        "test": ".jsx?$",
        "jsc": {
            "parser": {
                "syntax": "ecmascript",
                "jsx": true
            }
        }
    }
]

Playground link (or link to the minimal reproduction)

https://github.com/stephencranedesign/swc-example

SWC Info output

Operating System: Platform: darwin Arch: x64 Machine Type: x86_64 Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64 CPU: (8 cores) Models: Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz

Binaries:
    Node: 20.9.0
    npm: 10.1.0
    Yarn: N/A
    pnpm: N/A

Relevant Packages:
    @swc/core: 1.3.100
    @swc/helpers: N/A
    @swc/types: 0.1.5


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

Next.js info:
    output: N/A

Expected behavior

since I'm defining jsc.parser.syntax as typescript in the .swcrc file, I'd expect that when swc is used anywhere, whether with the transform function from @swc/core or the webpack loader function that it'd respect the swc config.

Actual behavior

.swcrc file doesn't seem to be used.

Version

1.3.100

Additional context

No response

stephencranedesign avatar Dec 11 '23 15:12 stephencranedesign

Array in .swcrc is buggy, and it's a known issue.

kdy1 avatar Dec 11 '23 16:12 kdy1

I'll close this with a PR for documentation

kdy1 avatar Dec 11 '23 16:12 kdy1