jamesbirtles / svelte-vscode

Svelte language support for VS Code
https://marketplace.visualstudio.com/items?itemName=JamesBirtles.svelte-vscode
MIT License
209 stars 23 forks source link

<script lang="typescript"> still gives Unexpected token svelte(parse-error) with `svelte-preprocess` #86

Closed swyxio closed 4 years ago

swyxio commented 4 years ago

I know this sounds like a duplicate of https://github.com/UnwrittenFun/svelte-vscode/issues/39 that was closed a while ago, but I've implemented svelte.config.js and I really still do have this issue!

// svelte.config.js
const sveltePreprocess = require('svelte-preprocess');

module.exports = {
  preprocess: preprocess()
}

Here are my versions so we can try to narrow down why i'm facing this:

as of time of writing, these are all latest versions except the operating system

what other info can i offer you to help? or can you point me to some suggestions to investigate why this doesnt work? im happy to spend a bit of time digging into this.

image

kaisermann commented 4 years ago

Hey @sw-yx 👋 A sample project would definitely help to understand the source of the problem 🙏

swyxio commented 4 years ago

hey @kaisermann thanks for taking a look! my sample repo is here: https://github.com/sw-yx/sveltepreprocesstest (this is not the real repo i have problems with, but is a small reproduction to hopefully find the error. it does use your svelte-preprocess.

what is really weird is that when i clone and install https://github.com/tonyrewin/svelte3-ts-boilerplate, which uses https://github.com/pyonr/svelte-ts-preprocess, i can see that typescript is working in there so it really just looks like something is going wrong only when i use svelte-preprocess (which seems to be the more popular one)?

i know this can be confusing to debug, please let me know what else i can do to debug so we can identify the source of the problem. i filed this issue here because i thought it was more likely an issue with svelte-vscode (or at least debuggable in vscode) than with the preprocess library. i wonder what else we can do to increase the visibility into this extension.

kaisermann commented 4 years ago

Thanks for the repo! Could it be related to your svelte.config.js using a undefined preprocess() method instead of sveltePreprocess() as you defined on the require() line? https://github.com/sw-yx/sveltepreprocesstest/blob/master/svelte.config.js#L6

I just cloned your repo, fixed this line and vscode stopped complaining 😁

swyxio commented 4 years ago

ohhh. 🤦‍♂️

erm ok i made a stupid mistake. i wonder if this vscode plugin can surface the obvious syntax error here?

kaisermann commented 4 years ago

Hehe 😆 I think that would be up to a linter or even vscode default js diagnostics 🤔