swc-loader icon indicating copy to clipboard operation
swc-loader copied to clipboard

Will swc-loader add appendTsSuffixTo option

Open BppleMan opened this issue 2 years ago • 0 comments

Compiling ts with swc is blazingly fast, and its advantage over esbuild is that it supports decorate metadata, which is great.

I hope that swc-loader can support appendTsSuffixTo in the future, just like ts-loader appendTsSuffixTo, so that swc-loader can better support the compilation of .vue files

This is what I do now and it works fine so far. But I'm not sure if there are other problems with this。

// webpack.config.ts
// ...... other rules
{
    test: /\.ts$/i,
    exclude: ["/node_modules/"],
    use: [
        'swc-loader',
        resolve(__dirname, 'custom-loader')
    ],
},
// ...... other rules
// custom-loader.js
module.exports = function (content, sourceMap, meta) {
    if (sourceMap && this.resourcePath && this.resourcePath.endsWith(".vue")) {
        this.resourcePath += ".ts"
    }
    return content
}

This is what I do now and it works fine so far. But I'm not sure if there are other problems with this. If anyone can tell me how to add an option to swc-loader to do something similar, maybe I can submit a pull request

BppleMan avatar Aug 09 '22 10:08 BppleMan