Open
Description
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
}
Metadata
Metadata
Assignees
Labels
No labels