# @speedy-js/speedy-plugin-swc

> swc custom dev

Latest version **0.12.1-alpha.2** (published 2022-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @speedy-js/speedy-plugin-swc
pnpm add @speedy-js/speedy-plugin-swc
yarn add @speedy-js/speedy-plugin-swc
bun add @speedy-js/speedy-plugin-swc
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.12.1-alpha.2 |
| Published | 2022-04-24 |
| First published | 2021-12-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zhushijie.jayson |
| Maintainers | zhusj, upupming, amour1688, null~, thisispluto, zoolsher, ulivz, hardfist |
| Keywords | speedy-plugin, swc |

## Links

- npm: https://www.npmjs.com/package/@speedy-js/speedy-plugin-swc
- npm.io page: https://npm.io/package/@speedy-js/speedy-plugin-swc

## Dependencies (1)

- [@speedy-js/speedy-napi](https://npm.io/package/@speedy-js/speedy-napi.md) 0.8.4

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.12.1-alpha.2 (latest) — 2022-04-24
- 0.13.2-modern.5 (modern) — 2023-01-12
- 0.14.1-alpha.10 (alpha) — 2022-11-02
- 0.13.2-webpack.17 (webpack) — 2022-08-25
- 0.9.0-alpha.2 (beta) — 2022-01-12
- 0.13.2-modern.4 — 2022-11-24
- 0.13.2-modern.3 — 2022-11-16
- 0.13.2-modern.2 — 2022-11-16
- 0.13.2-alpha.20 — 2022-11-01
- 0.14.1-alpha.9 — 2022-10-12
- 0.14.1-alpha.8 — 2022-09-27
- 0.14.1-alpha.7 — 2022-09-26
- 0.13.2-modern.1 — 2022-09-22
- 0.13.2-modern.0 — 2022-09-21
- 0.14.1-alpha.6 — 2022-09-08
- … 103 more at https://npm.io/package/@speedy-js/speedy-plugin-swc/versions

## README

# @speedy-js/speedy-plugin-swc

## 插件性质
* 类似babel-plugin 利用 swc 替换babel 来实现 babel 类似功能的插件集合体

## 插件可选配置

* speedy-react-runtime 作用：自动填补 tsx 上 "import React from 'react'"
* speedy-react-babelimport 作用：代替babel-import-plugin

## speedy-react-runtime 配置示例
* exlude(选填): 正则数组 匹配则跳过 speedy-react-runtime 的处理
```typescript
import { defineConfig } from '@speedy-js/speedy-core';
import { SwcPlugin } from '@speedy-js/speedy-plugin-swc';

export = defineConfig({
  input: {
    main: './src/index.tsx',
  },
  plugins: [
    SwcPlugin([
      {
        name: "speedy-react-runtime",
        exclude: [/node_modules/],
      },
    ]),
  ]
});
```

## speedy-react-babelimport 配置示例
* exlude(选填): 正则数组 匹配则跳过 speedy-react-babelimport 的处理
* config[x].fromSource(必填): 替换 packagename 例如 "antd","@arco-design/web-react"
* config[x].replaceCss(选填): `Object`
* config[x].replaceCss.replaceExpr(必填): `string` 替换表达式 -> `antd/lib/{}/style/css` => `import "antd/lib/button/style/css"`
* config[x].replaceCss.lower(选填): `bool` 是否替换时进行小写转化
* config[x].replaceCss.ignoreStyleComponent(选填): `string[]` 填写忽略的组件名称
* config[x].replaceJs(选填): `Object`
* config[x].replaceJs.replaceExpr(必填): `string` 替换表达式 -> `antd/es/{}/index.js` => `import button from "antd/es/button/index.js"`
* config[x].replaceJs.lower(选填): `bool` 是否替换时进行小写转化
* config[x].replaceJs.ignoreEsComponent(选填): `string[]` 填写忽略的组件名称 

```typescript
import { defineConfig } from '@speedy-js/speedy-core';
import { SwcPlugin } from '@speedy-js/speedy-plugin-swc';

export = defineConfig({
  input: {
    main: './src/index.tsx',
  },
  plugins: [
    SwcPlugin([
      {
        name: 'speedy-react-babelimport',
        exclude: [/node_modules/],
        config: [
          {
            fromSource: 'antd',
            replaceCss: {
              ignoreStyleComponent: ['button'],
              replaceExpr: `antd/lib/{}/style/css`,
              lower: true,
            },
            replaceJs: {
              ignoreEsComponent: ['button'],
              lower: true,
              replaceExpr: `antd/es/{}/index.js`,
            },
          },
        ],
      },
    ]),
  ],
});
```

## 综合使用示例
```typescript
import { defineConfig } from '@speedy-js/speedy-core';
import { SwcPlugin } from '@speedy-js/speedy-plugin-swc';

export = defineConfig({
  input: {
    main: './src/index.tsx',
  },
  plugins: [
    SwcPlugin([
      {
        name: "speedy-react-runtime",
        exclude: [/node_modules/],
      },
      {
        name: 'speedy-react-babelimport',
        exclude: [/node_modules/],
        config: [
          {
            fromSource: 'antd',
            replaceCss: {
              ignoreStyleComponent: ['button'],
              replaceExpr: `antd/lib/{}/style/css`,
              lower: true,
            },
            replaceJs: {
              ignoreEsComponent: ['button'],
              lower: true,
              replaceExpr: `antd/es/{}/index.js`,
            },
          },
        ],
      },
    ]),
  ],
});
```

---
_Source: https://npm.io/package/@speedy-js/speedy-plugin-swc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
