Vue to script.
Convert .vue
file to .ts|js
file in a treeshakable manner.
npm i -D v2s
npx v2s path/to/file
It will convert x.vue
to x.render.ts|js
, x.script.ts|js
and x.ts|js
corresponding to the lang
attribute.
Refactor .vue
import/export statement in .ts/.js
files. (Only transformed .vue
imports will be refactored.)
Delete .vue
source file.
If you have a vue library and want to build it in a treeshakable manner, you will always want to keep the original file structure.
For example:
- index.ts index.js + index.d.ts
- Button.vue => Button.js + Button.d.ts
- Input.vue Input.js + Input.d.ts
Currently I can think of some ways to do it.
- rollup +
presereModules=true
: not working, due torollup-plugin-vue
, the output is not treeshakable. - tsc: not working, it doesn't work with
.vue
files. - webpack: not working, can not keep the structure.
I want to use tsc
to make build the library. So I need a tool to tranform all .vue
files to .ts
file and modify all the .vue
import, export statements inside the library.