Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

--config doesn't handle anything with commas  #145

@walkerburgin

Description

@walkerburgin

I'm attempting to configure swc to use a custom plugin via the command line as part of a larger build process. Essentially I'm trying to replicate this .swcrc:

{
    "jsc": {
        "experimental": {
            "plugins": [
                ["./my_plugin.wasm", {}]
            ]
        }
    }
}

Calling swc --out-dir=dist --config=jsc.experimental.plugins=[[\"my_plugin.wasm\", {}]] src/ fails with an error like this:

invalid type: string "[[\"my_plugin.wasm\"", expected a sequence at line 1 column 187
Failed to compile 1 file with swc.
Error: Failed to compile:
test/index.ts
    at initialCompilation (/Users/wburgin/.nvm/versions/node/v12.20.2/pnpm-global/4/node_modules/.pnpm/@swc/[email protected]_@[email protected]/node_modules/@swc/cli/lib/swc/dir.js:172:19)
    at async dir (/Users/wburgin/.nvm/versions/node/v12.20.2/pnpm-global/4/node_modules/.pnpm/@swc/[email protected]_@[email protected]/node_modules/@swc/cli/lib/swc/dir.js:16:5)

I poked around a little bit, and here's what swcOptions ends up set to:

{
  jsc: {
    parser: undefined,
    transform: {},
    experimental: { plugins: '[["my_plugin.wasm"' }
  },
  sourceFileName: undefined,
  sourceRoot: undefined,
  configFile: undefined,
  swcrc: true,
  '': true
}

I think the collect() function (here) splitting the input on commas is causing the truncation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions