swc-loader

Webpack plugin for swc

MIT 23 个版本
安装
npm install swc-loader
yarn add swc-loader
pnpm add swc-loader
bun add swc-loader
README

swc-loader

This package allows transpiling JavaScript files using swc and webpack.

Installation

npm i --save-dev @swc/core swc-loader webpack

Usage

module: {
    rules: [
        {
            test: /\.m?js$/,
            exclude: /(node_modules|bower_components)/,
            use: {
                // Use `.swcrc` to configure swc
                loader: "swc-loader"
            }
        }
    ];
}

You can pass options to the loader by using the option property.

module: {
    rules: [
        {
            test: /\.ts$/,
            exclude: /(node_modules|bower_components)/,
            use: {
                loader: "swc-loader",
                options: {
                    jsc: {
                        parser: {
                            syntax: "typescript"
                        }
                    }
                }
            }
        }
    ];
}

If you get an error while using swc-loader, you can pass sync: true to get correct error message.

module: {
    rules: [
        {
            test: /\.ts$/,
            exclude: /(node_modules|bower_components)/,
            use: {
                loader: "swc-loader",
                options: {
                    // This makes swc-loader invoke swc synchronously.
                    sync: true,
                    jsc: {
                        parser: {
                            syntax: "typescript"
                        }
                    }
                }
            }
        }
    ];
}

Configuration Reference

Refer https://swc.rs/docs/configuring-swc

版本列表
0.2.7 2026-01-14
0.2.6 2024-02-05
0.2.4 2024-02-01
0.2.3 2022-06-09
0.2.2 2022-06-08
0.2.1 2022-05-15
0.2.0 2022-04-13
0.1.16 2022-04-12
0.1.15 2021-09-14
0.1.14 2021-04-28
0.1.13 2021-04-16
0.1.12 2020-05-30
0.1.11 2020-05-24
0.1.10 2020-05-11
0.1.9 2020-03-29
0.1.8 2020-01-31
0.1.6 2019-04-26
0.1.5 2019-03-23
0.1.4 2019-02-15
0.1.3 2019-02-08
0.1.2 2019-01-22
0.1.1 2019-01-22
0.1.0 2019-01-16