# craco-swc

Latest version **0.5.1** (published 2022-04-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install craco-swc
pnpm add craco-swc
yarn add craco-swc
bun add craco-swc
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2022-04-01 |
| First published | 2020-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 128 |
| Author | Leo Pradel <pradel.leo@gmail.com> |
| Maintainers | leopradel |

## Links

- npm: https://www.npmjs.com/package/craco-swc
- Repository: https://github.com/pradel/create-react-app-swc.git
- npm.io page: https://npm.io/package/craco-swc

## Dependencies (4)

- [@swc/core](https://npm.io/package/@swc/core.md) ^1.2.161
- [@swc/jest](https://npm.io/package/@swc/jest.md) ^0.2.20
- [swc-loader](https://npm.io/package/swc-loader.md) ^0.1.15
- [@swc/helpers](https://npm.io/package/@swc/helpers.md) ^0.3.8

## Recent versions

- 0.5.1 (latest) — 2022-04-01
- 0.5.0 — 2022-03-29
- 0.4.0 — 2022-03-29
- 0.3.0 — 2022-03-29
- 0.2.0 — 2021-12-01
- 0.1.3 — 2021-07-25
- 0.1.0 — 2020-10-12
- 0.0.3 — 2020-10-09
- 0.0.2 — 2020-10-09
- 0.0.1 — 2020-10-09

## README

# 🚀 craco-swc 🚀

Use [swc](https://swc.rs/) in your [create-react-app](https://create-react-app.dev/) with [craco](https://github.com/gsoft-inc/craco) for faster compilation, development and tests.

## Features

- Replace babel-loader with swc during development
- Replace babel-loader with swc for faster build time
- Use swc when running jest

## Installation

Run the following command to install `craco-swc` in your project:

```sh
yarn add --dev craco-swc @craco/craco

# OR

npm install --save-dev craco-swc @craco/craco
```

## Usage

Add this configuration to your `craco.config.js` configuration file:

```js
// craco.config.js
const CracoSwcPlugin = require('craco-swc');

module.exports = {
  plugins: [{ plugin: CracoSwcPlugin }],
};
```

To use `craco` instead of `react-scripts` to manage our application, edit the `scripts` section of your `package.json`.

```diff
/* package.json */

"scripts": {
-   "start": "react-scripts start",
+   "start": "craco start",
-   "build": "react-scripts build",
+   "build": "craco build"
-   "test": "react-scripts test",
+   "test": "craco test"
}
```

## Configuration

If your project contains a `.swcrc` file, it will be used by the `swc` loader configuration.
Take a look at https://swc.rs/docs/configuring-swc#jsc to see the list of available options.

You can also configure the options of the plugin by passing an `options` object.

- `swcLoaderOptions`: customise the options passed down to the `swc` loader. _Note: This will be used only by webpack_

For example add this configuration to your `craco.config.js` configuration file:

```js
// craco.config.js
const CracoSwcPlugin = require('craco-swc');

module.exports = {
  plugins: [
    {
      plugin: CracoSwcPlugin,
      options: {
        swcLoaderOptions: {
          jsc: {
            externalHelpers: true,
            target: 'es2015',
            parser: {
              syntax: 'ecmascript',
              jsx: true,
              dynamicImport: true,
              exportDefaultFrom: true,
            },
          },
        },
      },
    },
  ],
};
```

## License

MIT © [Léo Pradel](https://www.leopradel.com/)

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