You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+168-2Lines changed: 168 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Vue SFC To ES Modules
2
2
3
-
> Compile Vue SFC File to ES Modules.
3
+
> Transpiled Vue SFC File to ES modules.
4
4
5
5
## ✨ Features
6
6
@@ -11,7 +11,7 @@
11
11
12
12
## 💡 Inspiration
13
13
14
-
This project is heavily inspired by [Vue Sfc Playground](https://github.com/vuejs/vue-next/tree/master/packages/sfc-playground)
14
+
This project is heavily inspired by [Vue SFC Playground](https://github.com/vuejs/vue-next/tree/master/packages/sfc-playground). Actually Copied from it.
15
15
16
16
17
17
## 📦 Installation
@@ -22,6 +22,164 @@ or
22
22
npm i vue-sfc2esm -S
23
23
```
24
24
25
+
## How it Works?
26
+
27
+
You could imagine that `vue-sfc2esm` has a virtual file system like vue project.
28
+
29
+
`vue-sfc2esm` will help you transpiled your sfc code base on `Vue 3` into es modules code blocks with [@vue/compiler-sfc](https://www.npmjs.com/package/@vue/compiler-sfc)
30
+
31
+
You could use these code blocks directly on the modern browser with `type="module"` in the `<script>` element.
32
+
33
+
### Example
34
+
35
+
```html
36
+
<scripttype="modules">
37
+
// ES Modules Code Blocks Here.
38
+
</script>
39
+
```
40
+
41
+
## 📖 Usage
42
+
43
+
### addFile
44
+
45
+
> Add a file into the store, ready for compilation.
46
+
47
+
```js
48
+
import { addFile } from'vue-sfc2esm'
49
+
50
+
addFile('HelloWorld.vue', `<template>
51
+
<h1>{{ msg }}</h1>
52
+
</template>
53
+
54
+
<script setup>
55
+
const msg = 'Hello World!'
56
+
</script>
57
+
`)
58
+
```
59
+
60
+
### changeFile
61
+
62
+
> Change the file code, It will trigger `compileFile` action.
63
+
64
+
```js
65
+
import { changeFile } from'vue-sfc2esm'
66
+
67
+
changeFile('HelloWorld.vue', `<template>
68
+
<h1>{{ msg }}</h1>
69
+
</template>
70
+
71
+
<script setup>
72
+
const msg = 'Hello Vue SFC2ESM!'
73
+
</script>
74
+
`)
75
+
```
76
+
77
+
### deleteFile
78
+
79
+
> Delete the file in the store. with or without confirmation.
80
+
81
+
```js
82
+
import { deleteFile } from'vue-sfc2esm'
83
+
84
+
deleteFile('HelloWorld.vue')
85
+
```
86
+
87
+
### CompileModules
88
+
89
+
> Transpiled Vue SFC File to ES modules with `@vue/compiler-sfc`.
90
+
91
+
```js
92
+
import { compileModules } from'vue-sfc2esm'
93
+
94
+
(asyncfunction () {
95
+
// Compile Default App.vue Component Or Files In Store.
96
+
constmodules=awaitcompileModules('App.vue')
97
+
console.log(`Successfully compiled [App.vue] to ES Modules.`)
98
+
console.log(modules)
99
+
})()
100
+
```
101
+
102
+
## Typed
103
+
104
+
```typescript
105
+
/**
106
+
* Transpiled Vue SFC File to ES modules with `@vue/compiler-sfc`.
0 commit comments