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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-vue2-script-jsx

v1.0.2

Published

这是一个自动批量帮你添加 jsx 标签的脚本文件, 主要是解决vite下 vue2中vue文件无法使用jsx的情况

Readme

请注意这是一个脚本, 不是vite的插件, 这个脚本用于解决在Vue2 + Webpack的项目迁移至Vite的时候, Vite无法识别JSX语法的场景.

具体抛错信息如下:

[Vite] The JSX syntax extension is not currently enabled

error.png

目前该抛错一下的解决办法:

  1. vite配置文件加上该plugin(对我无用)
vite.config.js => plugins: [createVuePlugin({ jsx: true })]
  1. 如果是在js文件中带有jsx语法, 则将改为.jsx扩展名文件
.js(has jsx) => .jsx
  1. 如果是在.vue文件中带有jsx语法, 则在script标签下增加该标识
.vue(has jsx) => <script lang="jsx">

如果你的文件特别少的话就可以手动通过上述更改解决, 无需下载本脚本. 如果你需要更改的文件同我一样, 有成百上千个, 那本脚本就可以帮你自动添加了.

resolve

<script>
export default {
    methods: {
        demo() {
            return (
                <div>test</div>
            )
        }
    }
}
</script>

to

<script lang="jsx">
export default {
    methods: {
        demo() {
            return (
                <div>test</div>
            )
        }
    }
}
</script>

Usage

本脚本将一次性为带有jsx语法, 并以.vue解决的文件中的script标签自动加上 lang="jsx"

$ npm i vite-vue2-script-jsx

在你项目的入口文件内, 引入该脚本, 并给它传入你需要处理的文件夹绝对路径

// index.js
import vue2JSX from 'vite-vue2-script-jsx'
import { fileURLToPath } from 'url'
import path from 'path'
// 拿到当前文件的文件夹
const absolutePath = fileURLToPath(import.meta.url)
const basename = path.basename(absolutePath)
const aimPath = absolutePath.replace(`/${basename}`, '')
const aimFolder = aimPath + '/example'

vue2JSX({
    basePath: aimFolder, 
    includes: ['view', 'components']
})

参数介绍

|Name|Description|Default |---|---|---| |basePath|required string需要处理的文件夹绝对路径|null| |includes| array 只处理该文件夹内的哪些文件夹|[]|

因为src文件夹下可能有很多无须处理的文件夹, 所以传入第二个参数, 可以提高效率.

请注意这个插件将会实际的变更你的文件, 所以最好清空一下工作区, 方便看到执行后被变更的文件