Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue #290

Open
lastmjs opened this issue Jan 18, 2020 · 4 comments
Open

Vue #290

lastmjs opened this issue Jan 18, 2020 · 4 comments

Comments

@lastmjs
Copy link
Owner

lastmjs commented Jan 18, 2020

Should we include support for .vue files in Zwitterion core, or should it be a third-party plugin?

@koresar
Copy link

koresar commented Jan 19, 2020

Hi mate.
Thanks for the tool!

Questions.
What are the technical difficulties of adding .vue if any?
Are there much differences between JSX and VUE files?
Anything else stopping from adding VUE files support?

@lastmjs
Copy link
Owner Author

lastmjs commented Jan 20, 2020

Hey, you're welcome. To add .Vue files to Zwitterion core, we just need to create a new internal plugin and implement all of the fields and functions. Each language supported so far is implemented as an internal plugin here: https://github.com/lastmjs/zwitterion/tree/master/src/languages

The hardest thing for .vue will be implementing the transformer, which is the function that takes the source file contents and returns the modified contents to the browser. I'm not yet familiar with exactly how Vue single file components work, but I believe we can use this tool or one similar to do the transformation: https://www.npmjs.com/package/vue-template-compiler

As I dig into Vue, I'm afraid I'll start finding out technical complications in this process. It could be pretty simply to get basic support though.

In what ways are JSX and Vue similar? Do you mean the actual languages or the Zwitterion implementation? JSX and TSX are very simple, as they use the TypeScript compiler with just one extra flag and are easily compiled to JavaScript, everything being self-contained in one file. Vue might be more complex, as there is the style, template, script, imports and exports to deal with (though the script, imports, and exports might work without much complication).

The biggest question I have is whether Vue should be supported natively by Zwitterion, or if Vue support should be put into a separate plugin that is installed separately. I want to come up with criteria for what should and should not be included in Zwitterion. If we don't have good guidelines, Zwitterion could get bloated to install and maintain. Right now I'm thinking languages that have a very high demand and chance of existing in high demand for the next few years should be supported.

@koresar
Copy link

koresar commented Jan 20, 2020

Answering the questions.

JSX is like Vue template+style combined.
Vue <template> is fully HTML compatible. In fact, it is the HTML. So, technically, it is even simpler than JSX because .vue files are actually .html-compatible files. But, for JS-bundling, it is compiled to the same as React h() nested functions call tree by the vue-template-compiler.

However, what can get things complicated is the <template lang="pug"> and <script lang="ts"> and <style lang="stylus"> language compilations (which make the .vue files not .html-compatible). But these are quite rare, so okay to be not supported.

Separate note about <style>.
There are two: <style scoped> (default and widely recommended) and <style> (adds to styles).
I have no idea how they work internally though.

My recommendation is to look at this chart and decide:
image

@lastmjs
Copy link
Owner Author

lastmjs commented Jan 21, 2020

Good recommendation. I think I will add Vue support to Zwitterion core. If we're supporting React, we might as well support Vue. The popularity of Vue would probably help Zwitterion gain notoriety. Even if adding an extension does end up bloating core, I think it would be relatively simple to split out plugins into third-party packages later on, might as well make it as convenient as possible for a lot of people. Svelte will probably be next after Vue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants