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

vue-repl-enhance

v1.2.3

Published

Can enable Vue repl to support Vue2/3 playaround

Readme

vue-repl-enhance

一个功能增强版的 Vue REPL 组件,支持 Vue 2 和 Vue 3 的在线编辑与预览。基于 @vue/repl 开发,增加了对 Vue 2 的支持以及更多配置选项。

特性

  • ⚡️ 多版本支持:无缝切换 Vue 2 (2.7+) 和 Vue 3 (3.x)。
  • 📝 编辑器支持:内置 Monaco Editor 支持,提供强大的代码编辑体验。
  • 🛠 TypeScript 支持:内置 TypeScript 编译支持。
  • 📦 依赖管理:支持 Import Map,可自定义依赖包路径。
  • 🖥 灵活布局:支持左右分栏、仅编辑器、仅预览等多种布局模式。
  • 🎨 主题定制:支持亮色 (Light) 和暗色 (Dark) 主题。

安装

npm install vue-repl-enhance
# 或
pnpm add vue-repl-enhance
# 或
yarn add vue-repl-enhance

使用指南

基础用法

<script setup lang="ts">
import { onMounted } from 'vue'
import { Repl, ReplStore } from 'vue-repl-enhance'
import MonacoEditor from 'vue-repl-enhance/monaco-editor'

// 初始化 Store
const store = new ReplStore({
  defaultVueVersion: '3.3.4', // 默认 Vue 版本
  defaultTypescriptVersion: '5.0.2',
})

// 设置初始文件
onMounted(() => {
  store.setFiles({
    'App.vue': `
<template>
  <h1>Hello Vue Repl!</h1>
</template>
`
  })
})
</script>

<template>
  <Repl
    :store="store"
    :editor="MonacoEditor"
    :showCompileOutput="false"
  />
</template>

<style>
/* 确保容器有高度 */
.vue-repl {
  height: 100vh;
}
</style>

Vue 2 支持

要支持 Vue 2,需要在初始化 Store 时指定 Vue 版本为 2.x,并确保提供了 Vue 2 的运行时 URL。

const store = new ReplStore({
  defaultVueVersion: '2.7.16',
  // 如果需要,可以手动指定运行时 URL
  // defaultVueRuntimeURL: '...' 
})

API 文档

Repl 组件 Props

| 属性名 | 类型 | 默认值 | 说明 | |Ref |Ref |Ref |Ref | | editor | Component | Required | 编辑器组件 (如 MonacoEditor) | | store | ReplStore | new ReplStore() | REPL 状态管理实例 | | theme | 'light' \| 'dark' | 'light' | 主题模式 | | layout | 'horizontal' \| 'vertical' | - | 布局方向 | | layoutMode | 'both' \| 'editor' \| 'preview' | 'both' | 显示模式 | | split | number | - | 分栏初始比例 | | autoResize | boolean | true | 是否自动响应容器大小变化 | | showCompileOutput | boolean | false | 是否显示编译输出 | | showImportMap | boolean | false | 是否显示 Import Map 编辑器 | | showTsConfig | boolean | false | 是否显示 tsconfig.json 编辑器 | | showError | boolean | true | 是否显示错误提示 | | showFileSelector | boolean | true | 是否显示文件选择器 | | showMessageToggle | boolean | true | 是否显示消息切换按钮 | | clearConsole | boolean | true | 运行前是否清空控制台 | | ssr | boolean | false | 是否启用 SSR 预览模式 | | previewOptions | Object | - | 预览 iframe 的高级配置 |

ReplStore 配置选项

interface StoreOptions {
  serializedState?: string;            // 从 URL hash 恢复的状态字符串
  showOutput?: boolean;                // 初始是否显示编译输出
  outputMode?: 'preview' | 'js' | 'css' | 'ssr'; // 初始输出模式
  defaultVueVersion?: string;          // 默认 Vue 版本
  defaultTypescriptVersion?: string;   // 默认 TypeScript 版本
  defaultVueRuntimeURL?: string;       // 自定义 Vue 运行时 URL
  defaultVueServerRendererURL?: string;// 自定义 Vue SSR 渲染器 URL
  latestVersions?: Record<string, string>; // 依赖包的最新版本映射
}

开发与构建

启动开发服务器

npm run dev

构建

npm run build

Nginx 配置

如果使用 Nginx 部署,需要确保 .mjs 文件被正确识别为 application/javascript 类型,否则可能会遇到 MIME type 错误。

nginx.confmime.types 中添加以下配置:

http {
    include       mime.types;
    types {
        application/javascript mjs;
    }
    # ... 其他配置
}

许可证

MIT