Skip to content

Plugin is changing outputted code (not imports) #71

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

Open
gtjamesa opened this issue Dec 9, 2023 · 0 comments
Open

Plugin is changing outputted code (not imports) #71

gtjamesa opened this issue Dec 9, 2023 · 0 comments

Comments

@gtjamesa
Copy link

gtjamesa commented Dec 9, 2023

Using 1.0.0-alpha.5. The import statements are being added as expected, but I noticed some code was also being altered. This happens when using the API example .swcrc and also when no rules are configured

...

// typescript source
public static postRaw(req: Request<RawRenderRequest>, res: Response) {
  const chartData = req.body?.chart;
  if (!req.body || !chartData || !chartData?.data.length) {
    //
  }
}

// swc build
static postRaw(req, res) {
  const chartData = req.body?.chart;
  if (!req.body || !chartData || !chartData?.data.length) {
    //
  }
}

// swc build + this plugin
static postRaw(req, res) {
  const chartData = this?.;
  if (!req.body || !chartData || !this.?) {
    //
  }
}

...

.swcrc:

{
  "$schema": "http://json.schemastore.org/swcrc",
  "jsc": {
    "target": "es2022",
    "parser": {
      "syntax": "typescript"
    },
    "experimental": {
      "plugins": [
        [
          "swc-plugin-add-import-extension",
          {
            "^~.*$": {
              "extension": "js",
              "addIndex": true
            },
            "^\\..*": {
              "extension": "js",
              "addIndex": false
            }
          }
        ]
      ]
    }
  },
  "module": {
    "type": "es6",
    "strict": false,
    "strictMode": true,
    "lazy": false,
    "noInterop": false
  },
  "sourceMaps": true
}
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

1 participant