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

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

Open
walkerburgin opened this issue Jul 4, 2022 · 0 comments
Open

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

walkerburgin opened this issue Jul 4, 2022 · 0 comments

Comments

@walkerburgin
Copy link
Contributor

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/cli@0.1.57_@swc+core@1.2.208/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/cli@0.1.57_@swc+core@1.2.208/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.

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

1 participant