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

Error when passing multiple entries to swcOptions #3

Closed
Saunved opened this issue Nov 17, 2021 · 1 comment
Closed

Error when passing multiple entries to swcOptions #3

Saunved opened this issue Nov 17, 2021 · 1 comment

Comments

@Saunved
Copy link

Saunved commented Nov 17, 2021

This is my swcOptions object:

[
  {
    test: ".*.js$",
    jsc: {
      parser: {
        jsx: true
      },
      target: "es5"
    },
    module: {
      type: "commonjs"
    }
  }
]

When running this, the task fails with this error:

Message:
    Failed to deserialize swc::config::Options from json string (`{"0":{"test":".*.js$","jsc":{"parser":{"jsx":true},"target":"es5"},"module":{"type":"commonjs"}},"filename":"/Users/username/repos/reponame/resources/static/scripts/requireConfig.js","sourceMaps":false,"caller":{"name":"gulp-swc"}}`)

Caused by:
    unknown field `0` at line 1 column 230

If I don't pass the test key, the JS transpiles, but I have two different module systems in the codebase, so the test option is necessary.

@konclave
Copy link
Owner

Why do you pass an array as the config?
It should be an object.
The following config works without any issues:

const config = {
    test: ".*.js$",
    jsc: {
      parser: {
        jsx: true
      },
      target: "es5"
    },
    module: {
      type: "commonjs"
    }
}

@konclave konclave closed this as completed Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants