Giter VIP home page Giter VIP logo

v2s's Introduction

v2s

Vue to script.

Convert .vue file to .ts|js file in a treeshakable manner.

Installation

npm i -D v2s

Usage

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.

Option

-r, --refactor

Refactor .vue import/export statement in .ts/.js files. (Only transformed .vue imports will be refactored.)

-d, --delete-source

Delete .vue source file.

Why it exists

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.

  1. rollup + presereModules=true: not working, due to rollup-plugin-vue, the output is not treeshakable.
  2. tsc: not working, it doesn't work with .vue files.
  3. 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.

v2s's People

Contributors

07akioni avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.