npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

drop-reactivity-transform

v0.1.0

Published

a tool that helps you drop reactivity transform in seconds.

Downloads

32

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

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