@webpackon/use-swc
v1.0.3
Published
Webpackon use swc
Downloads
2
Maintainers
Readme
@webpackon/use-swc
Features:
- adds swc support
- simple transpiling of modules
Install
npm i @webpackon/use-swc --save
yarn add @webpackon/use-swc
API
const { useSwc } = require('@webpackon/use-swc');
useSwc(params?: UseSwcParams)(config: WebpackConfig)
UseSwcParams
export type UseSwcParams = {
transpileModules?: string[];
useTs?: boolean;
loaderParams?: {
options?: Record<string, any>;
};
};
- transpileModules
useSwc({
transpileModules: ['lodash-es', 'antd']
})
useTs - enables ts support for swc-loader
loaderParams.options - swc-loader options
TS example
Full examples are here
webpack.config.js
const path = require('path');
const { compose } = require('@webpackon/core');
const { useTs } = require('@webpackon/use-ts');
const { useSwc } = require('@webpackon/use-swc');
module.exports = (_, { mode }) =>
compose(
useSwc({ useTs: true, transpileModules: ['my-module'] }),
useTs(),
)({
target: 'web',
entry: path.resolve(__dirname, 'src', 'index.tsx'),
});
.swcrc
{
"env": {
"mode": "usage",
"coreJs": 3
},
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true
},
"transform": {
"react": { "runtime": "automatic" }
}
}
}