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

template for Vue + Typescript #690

Closed
axetroy opened this issue Jul 31, 2020 · 12 comments
Closed

template for Vue + Typescript #690

axetroy opened this issue Jul 31, 2020 · 12 comments
Labels
contributors welcome! contributors welcome!

Comments

@axetroy
Copy link

axetroy commented Jul 31, 2020

Hi!

Before this, I already had an existing project (generated by Vue CLI)

Now I want to migrate to snowpack, but unfortunately, I did not find a template for typescript + vue, and migration documentation.

When I try to migrate, it gives me an HTTP error 500

And there is no error message, I don’t know what to do.

any helps are welcome. Thx.

@drwpow drwpow added the contributors welcome! contributors welcome! label Jul 31, 2020
@drwpow
Copy link
Collaborator

drwpow commented Jul 31, 2020

Yes! Agree we should have a Vue + TypeScript template, especially one that works out-of-the-box migrating from Vue CLI, if possible.

We’d love a PR if anyone is able to tackle this.

@spikyjt
Copy link

spikyjt commented Aug 5, 2020

I'm currently setting this up for a new project (Vue 3), so will report back with how I get on and plan to create a template once it is stable.

If successful, I may try porting a previous Vue 2 project to snowpack, although I'm not certain that is possible. Would be worth the OP stating which version of Vue they are on.

@FredKSchott
Copy link
Owner

@spikyjt that sounds great! any luck??

@spikyjt
Copy link

spikyjt commented Aug 24, 2020

@FredKSchott I've been distracted with other things, but so far ended up with WSOD using the sample app used in the Vue CLI generator!

@spikyjt
Copy link

spikyjt commented Aug 24, 2020

@FredKSchott I've had another look, but gone down a black hole with Single-File Components. Is there a loader for Typescript in <script> tags in SFCs? Plain JS works fine, so something is extracting the scripts. Anything that we can plug in for this? It's a non-starter without it.

@FredKSchott
Copy link
Owner

FredKSchott commented Aug 25, 2020

I don't know the answer, unfortunately. Svelte has https://www.npmjs.com/package/svelte-check, I wonder if Vue has something similar. Maybe Vue doesn't fully support TS? Curious if anyone knows how this might work!

@spikyjt
Copy link

spikyjt commented Aug 25, 2020

@FredKSchott Vue 3 is written in TS and Vue has always supported TS fully. The script part of the SFC needs lang="ts" and that's it. In its standard Webpack build, vue-loader builds the TS scripts as required. @vue/compiler-sfc (used by vue-loader and @snowpack/plugin-vue uses babel-parser to build the TS. I can see the code in that which should handle it.

I suspect the problem is with @snowpack/plugin-vue. Looking at its code, it blithely assumes everything in a script block is plain JS. It also assumes all style blocks are plain CSS. Again with these, you should be able to use lang="scss" etc.

I'm willing to contribute, let's continue this discussion on Discord.

@Akimyou
Copy link
Contributor

Akimyou commented Sep 10, 2020

#984 , Will support Vue + Typescript in this merged PR.
Please try on master now.

@axetroy
Copy link
Author

axetroy commented Sep 10, 2020

@Akimyou Thanks for your great job!:+ could you add an example for this?

@Akimyou
Copy link
Contributor

Akimyou commented Sep 10, 2020

Example:
https://github.com/Akimyou/snowpack/tree/feature/plugin-vue-enhance-demo/create-snowpack-app/app-template-vue-typescript

official template will be add after next release.

@Akimyou
Copy link
Contributor

Akimyou commented Sep 22, 2020

PR here: #1088

@FredKSchott
Copy link
Owner

Completed in #1088. Thanks @Akimyou !

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

No branches or pull requests

5 participants