@webpackon/use-swc
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Webpackon

@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']
})

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" }
    }
  }
}

Package Sidebar

Install

npm i @webpackon/use-swc

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

6.49 kB

Total Files

9

Last publish

Collaborators

  • and_tem