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

Markup incorrectly parsed after <style global> SCSS flag #136

Closed
Egnus opened this issue May 29, 2020 · 12 comments · Fixed by #152
Closed

Markup incorrectly parsed after <style global> SCSS flag #136

Egnus opened this issue May 29, 2020 · 12 comments · Fixed by #152
Labels
bug Something isn't working

Comments

@Egnus
Copy link

Egnus commented May 29, 2020

Describe the bug
HTML Svelte interpolated code with comparisons {condition === 2} starts to make the rest of the file to be wrongly parsed after <style> tag if 'global' flag is provided at the end of the style tag for SCSS preprocessors.
This does not affect builds and the same svelte.config is both used for rollup and for vscode with the preprocessor.
To Reproduce

  1. The order of the Svelte file has to be script - style - markup.
  2. Style has to use global preprocessor flag attribute after any other attrib like <style src="./path.scss" global>
  3. In the markup, inside interpolated Svelte code ({expressions}) there should be a boolean comparison (this is the only case I found but there might be more) like {x === 2}.

Minimal reproducible example:

<script>let whatever = 1; /* it does not matter */</script>
<style src="./aFile.scss" global> // <-- 'global' has to be last
{whatever === 1} // <-- last '}' will give you error, then almost any other not native html code

Expected behavior
Nothing should be prompted unless it is a real error.

Screenshots
Screenshot 2020-05-29 at 13 37 47

System (please complete the following information):

  • OS: Mojave. Mac
  • IDE: VSCode
  • Plugin/Package: only "Svelte Beta" (No "Svelte" or "Svelte Type Check" or similar)

WORKAROUND
I found out that if global is set just before the src="" attribute, the compiler will work.
This clarifies that this issue is, in fact, from the language-tool, perhaps as a conflict with other built-in plugins from VSCode

<script>let whatever = 1; /* it does not matter */</script>
<style global src="./aFile.scss">
{whatever === 1} // This works
@Egnus Egnus added the bug Something isn't working label May 29, 2020
@jasonlyu123
Copy link
Member

This is because the transformation behind the scenes mistakenly takes the === as the end of the global attribute. Thank you for the report.

@dummdidumm
Copy link
Member

So this is another case where our regex-parser fails? Maybe we could refactor it as proposed here and then fix both these issues at once.

@jasonlyu123
Copy link
Member

This one is in svelte2tsx, this line:

@Egnus
Copy link
Author

Egnus commented Jun 1, 2020

yeah, it seems that htmlxparser.ts code doesn't take into consideration true implicit attributes.

@Egnus
Copy link
Author

Egnus commented Jun 2, 2020

how can i see is this is added in the current version? is it auto-deployed when merged? At this moment it still shows the error

@dummdidumm
Copy link
Member

It is autodeployed nightly, in about 8 hours.

@Egnus
Copy link
Author

Egnus commented Jun 3, 2020

I am afraid it still does not work. Updated & restarted all before testing, nothing relevant in the Output -> Svelte either
Screenshot 2020-06-03 at 11 27 51

@jasonlyu123
Copy link
Member

language-server and svelte-vscode seem to be released with the version of svelte2tsx released a day ago. So the fix hasn't been released yet.

@dummdidumm
Copy link
Member

Oh, we definetely should somehow order the releases during the deploy then. @orta can we somehow change this so that it's "deploy svelte2tsx to npm first, then svelte-language-server, then svelte-check, then deploy svelte-vscode to marketplace", so that the yarn install that is done in svelte-vscode before publishing already gets the latest version?

@Egnus
Copy link
Author

Egnus commented Jun 7, 2020

I have tried to push some changes as a PR but it seems that the project is locked and I does not admit branches and PRs.

I just did 2 changes to reorder the build in any case. Still today the vscode extension fails on this and I can see it seems that is failing the deployments for the last 3 or 4 days.

@dummdidumm
Copy link
Member

Deployment: orta will look into it, he has made an issue to track it.
PRs: you should definitely be able to do PRs. You need to fork the repo for that.

@Egnus
Copy link
Author

Egnus commented Jun 11, 2020

Fixed in the last deployed version 🙇 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants