4.1.2 • Published 17 days ago

@vue/repl v4.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
17 days ago

@vue/repl

Vue SFC REPL as a Vue 3 component.

Basic Usage

Note: @vue/repl >= 2 now supports Monaco Editor, but also requires explicitly passing in the editor to be used for tree-shaking.

With CodeMirror Editor

Basic editing experience with no intellisense. Lighter weight, fewer network requests, better for embedding use cases.

<script setup>
import { Repl } from '@vue/repl'
import CodeMirror from '@vue/repl/codemirror-editor'
// import '@vue/repl/style.css'
// ^ no longer needed after 3.0
</script>

<template>
  <Repl :editor="CodeMirror" />
</template>

With Monaco Editor

With Volar support, autocomplete, type inference, and semantic highlighting. Heavier bundle, loads dts files from CDN, better for standalone use cases.

<script setup>
import { Repl } from '@vue/repl'
import Monaco from '@vue/repl/monaco-editor'
// import '@vue/repl/style.css'
// ^ no longer needed after 3.0
</script>

<template>
  <Repl :editor="Monaco" />
</template>

Advanced Usage

Customize the behavior of the REPL by manually initializing the store.

See v4 Migration Guide

<script setup>
import { watchEffect, ref } from 'vue'
import { Repl, useStore, useVueImportMap } from '@vue/repl'
import Monaco from '@vue/repl/monaco-editor'

// retrieve some configuration options from the URL
const query = new URLSearchParams(location.search)

const {
  importMap: builtinImportMap,
  vueVersion,
  productionMode,
} = useVueImportMap({
  // specify the default URL to import Vue runtime from in the sandbox
  // default is the CDN link from jsdelivr.com with version matching Vue's version
  // from peerDependency
  runtimeDev: 'cdn link to vue.runtime.esm-browser.js',
  runtimeProd: 'cdn link to vue.runtime.esm-browser.prod.js',
  serverRenderer: 'cdn link to server-renderer.esm-browser.js',
})

const store = useStore(
  {
    // pre-set import map
    builtinImportMap,
    vueVersion,
    // starts on the output pane (mobile only) if the URL has a showOutput query
    showOutput: ref(query.has('showOutput')),
    // starts on a different tab on the output pane if the URL has a outputMode query
    // and default to the "preview" tab
    outputMode: ref(query.get('outputMode') || 'preview'),
  },
  // initialize repl with previously serialized state
  location.hash,
)

// persist state to URL hash
watchEffect(() => history.replaceState({}, '', store.serialize()))

// use a specific version of Vue
vueVersion.value = '3.2.8'
// production mode is enabled
productionMode.value = true
</script>

<template>
  <Repl :store="store" :editor="Monaco" :showCompileOutput="true" />
</template>
4.1.2

17 days ago

4.1.1

3 months ago

4.0.1

3 months ago

4.0.2

3 months ago

4.1.0

3 months ago

4.0.0

3 months ago

4.0.0-beta.0

3 months ago

4.0.0-alpha.1

4 months ago

3.4.0

4 months ago

4.0.0-alpha.0

4 months ago

3.3.0

4 months ago

3.2.0

4 months ago

3.1.1

4 months ago

3.1.0

5 months ago

3.0.1

5 months ago

2.6.1

7 months ago

2.8.1

6 months ago

2.6.3

6 months ago

2.8.0

6 months ago

2.6.2

6 months ago

2.5.6

10 months ago

2.5.5

10 months ago

2.5.8

9 months ago

2.5.7

9 months ago

3.0.0

6 months ago

2.5.0

10 months ago

2.7.0

6 months ago

2.5.2

10 months ago

2.5.1

10 months ago

2.9.0

6 months ago

2.5.4

10 months ago

2.5.3

10 months ago

2.4.0

11 months ago

2.2.0

11 months ago

2.0.0

11 months ago

1.5.0

11 months ago

2.3.0

11 months ago

2.1.2

11 months ago

2.1.1

11 months ago

2.1.4

11 months ago

2.1.3

11 months ago

2.1.0

11 months ago

1.3.6

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.0.0

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.5

2 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.7

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago