Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

drop-reactivity-transform

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drop-reactivity-transform

a tool that helps you drop reactivity transform in seconds.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

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

Installation

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:

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 and don't want to import these APIs from Vue, you can use the --nonInjectImport flag as a second parameter. Here's an example:

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 . 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 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

<script setup lang="ts">
  let count = $ref<number>(0)
  console.log(count)
</script>

After

<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

<script setup lang="ts">
  let count = $ref<number>(0)
  console.log(count)
</script>

After

<script setup lang="ts">
  let count = ref<number>(0)
  console.log(count.value)
</script>

Object destructure

Before

const { client } = $(useMasto())

After

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

Keywords

FAQs

Package last updated on 24 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc