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

@vureact/compiler-core

v1.10.0

Published

A smart compiler for migrating Vue to React

Downloads

384

Readme

@vureact/compiler-core

@vureact/compiler-core 是专为 Vue 迁移 React 设计的智能编译器,也是 VuReact 的 CLI 与核心编译包。 它用于将 Vue 3 单文件组件・脚本・样式完整转为纯 React(非运行时桥接)代码并输出工程化产物,覆盖 <script setup> 核心全特性,支持渐进式迁移与 Vue+React 混合开发。

Npm Downloads Coverage Node License: MIT

简体中文 | English

这个包适合谁

  • 项目需从 Vue 3 渐进式迁移到 React,但不想从头重写,优先寻找现有解决方案
  • 部分开发者以 Vue 为主技术栈,习惯其心智模型,认为 React 的额外负担比 Vue 更重
  • 后端开发者不想学习双框架,Vue 上手快、符合直觉,不愿接触 React
  • 转换后的 React 需完全脱离 Vue 运行时,避免双框架运行时所带来的性能和体积问题

使用方式

💡 从零开始的官方指南:VuReact 快速入门

💡 混合项目迁移实践:客户支持协同后台(Vue + React)

1. 安装

npm install -D @vureact/compiler-core

也可以使用:

pnpm add -D @vureact/compiler-core
yarn add -D @vureact/compiler-core

2. 创建配置文件

在项目根目录新建 vureact.config.ts

import { defineConfig } from '@vureact/compiler-core';

export default defineConfig({
  exclude: ['src/main.ts'], // 排除 Vue 入口文件
});

如果你只想用默认工作区和输出目录,这样就够了。

如果需要显式指定输出配置,可以写成:

import { defineConfig } from '@vureact/compiler-core';

export default defineConfig({
  input: './src',
  exclude: ['src/main.ts'],
  output: {
    workspace: '.vureact',
    outDir: 'react-app',
    bootstrapVite: true,
  },
});

如果项目使用 Vue Router,通常还会补上:

router: {
  configFile: 'src/router/index.ts',
}

3. 先从单文件试点

如果你想先验证一个组件能否稳定转换,可以先只编译单个 SFC:

export default defineConfig({
  input: './src/your-component.vue',
  exclude: ['src/main.ts'],
});

这适合:

  • 先验证编译约定
  • 先看生成结果
  • 先小范围试点,而不是直接全仓推进

4. 再扩展到整个项目

当单文件试点通过后,再把 input 指向目录:

export default defineConfig({
  input: './src',
  exclude: ['src/main.ts'],
});

这会递归处理目录下的 Vue / Script / Style 文件。

注意:VuReact 优先支持基于 <script setup> 的现代 Vue 3 写法。
如果你的项目使用 Vue Router,请同时查看 路由适配指南

5. 执行编译

# 一次性编译
npx vureact build

# 监听模式
npx vureact watch

如果你更喜欢脚本命令,也可以写进 package.json

{
  "scripts": {
    "vr:build": "vureact build",
    "vr:watch": "vureact watch"
  }
}

6. 查看输出结果

默认情况下,VuReact 会生成:

  • .vureact/cache:编译缓存
  • .vureact/react-app:React 工程产物
  • 与源目录结构对应的 .tsx / .css 文件

目录大致如下:

vue-project/
├── .vureact/
│   ├── cache/
│   ├── react-app/
│   │   ├── src/
│   │   ├── package.json
│   │   ├── vite.config.ts
├── src/
├── package.json
└── vureact.config.ts

进入产物目录后可直接运行:

cd .vureact/react-app
npm install
npm run dev

如果你想更系统地了解 build/watch 的差异,可以继续阅读:

这个包不负责什么

  • 它不是 Vue in React / React in Vue 的运行时桥接层
  • 它不是对任意 Vue 代码都“零约定”生效的通用 codemod
  • 它更适合遵循 VuReact 编译约定的工程化项目

相关包

文档入口

仓库与许可证

MIT License © 2025 Ruihong Zhong (Ryan John)