# drop-reactivity-transform

> a tool that helps you drop reactivity transform in seconds.

Latest version **0.1.0** (published 2023-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install drop-reactivity-transform
pnpm add drop-reactivity-transform
yarn add drop-reactivity-transform
bun add drop-reactivity-transform
```

Provides the command `dropReactivityTransform`.

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-11-24 |
| First published | 2023-06-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 96 |
| Author | Edison1105 |
| Maintainers | daiwei1105 |
| Keywords | drop-reactivity-transform, reactivity-transform |

## Links

- npm: https://www.npmjs.com/package/drop-reactivity-transform
- Repository: https://github.com/edison1105/drop-reactivity-transform
- Homepage: https://github.com/edison1105/drop-reactivity-transform#readme
- Issues: https://github.com/edison1105/drop-reactivity-transform/issues
- npm.io page: https://npm.io/package/drop-reactivity-transform

## Dependencies (1)

- [vue](https://npm.io/package/vue.md) ^3.3.4

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2023-11-24
- 0.0.16 — 2023-08-12
- 0.0.15 — 2023-06-28
- 0.0.14 — 2023-06-28
- 0.0.13 — 2023-06-28
- 0.0.11 — 2023-06-27
- 0.0.10 — 2023-06-27
- 0.0.4 — 2023-06-27
- 0.0.3 — 2023-06-27
- 0.0.1 — 2023-06-27

## README

# drop-reactivity-transform 

`drop-reactivity-transform` is a powerful tool that enables you to quickly remove reactivity transform from your code base. It automatically scans all the `.vue`, `.ts`, and `.js` files in your target folder, transforms the code, and replaces the original code as needed - all in a matter of seconds.

![screenshot](screenshot.png)

## Installation
```bash
npm i -g drop-reactivity-transform
```
## Usage

To utilize drop-reactivity-transform, simply specify the target directory name as the first parameter. If no directory name is provided, the tool will default to using the current working directory. Here is an example:
```bash
dropReactivityTransform [target directory name]

# transform files in the src directory
dropReactivityTransform src

# transform files in the working directory
dropReactivityTransform . 

```
If you use [unplugin-auto-import](https://github.com/antfu/unplugin-auto-import) and don't want to import these APIs from Vue, you can use the `--nonInjectImport` flag as a second parameter. Here's an example:
```bash
dropReactivityTransform src --nonInjectImport
```
> Please note that the `--nonInjectImport` option only works for `.vue` files. For both `.ts` and `.js` files, the tool will always inject the import regardless of whether this option is specified or not.

# Why use this tool?
Reactivity Transform was an experimental feature and has now been deprecated. It will be removed from Vue core in version 3.4. see [[⚠️ Dropped] Reactivity Transform
](https://github.com/vuejs/rfcs/discussions/369). If you don't want to use it anymore, this tool will help you convert your code and remove it.


# How it works?
The `drop-reactivity-transform` tool converts the following reactivity transform APIs to reactivity APIs:
- `$ref` -> `ref`
- `$computed` -> `computed`
- `$shallowRef` -> `shallowRef`
- `$customRef` -> `customRef`
- `$toRef` -> `toRef`

The [reactivity-transform](https://github.com/vuejs/core/tree/main/packages/reactivity-transform) module has already implemented the code to internally convert the above APIs to the reactivity API. This tool leverages that code and makes necessary modifications to it.

# Examples of transformation
Here's some examples of the transformation:

### Before
```vue
<script setup lang="ts">
  let count = $ref<number>(0)
  console.log(count)
</script>
```
### After
```vue
<script setup lang="ts">
  import { ref } from 'vue'

  let count = ref<number>(0)
  console.log(count.value)
</script>
```

Here's an example of using the `--nonInjectImport` flag:
### Before
```vue
<script setup lang="ts">
  let count = $ref<number>(0)
  console.log(count)
</script>
```
### After
```vue
<script setup lang="ts">
  let count = ref<number>(0)
  console.log(count.value)
</script>
```

Object destructure
### Before
```ts
const { client } = $(useMasto())
```
### After
```ts
const __$temp_1 = (useMasto()),
  client = toRef(__$temp_1, 'client');
```
> Please note that for this usage scenario, you will need to format the code and manually modify the variable name `_$temp_` yourself

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=edison1105/drop-reactivity-transform&type=Date)](https://star-history.com/#edison1105/drop-reactivity-transform&Date)

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