Git Product home page Git Product logo

Comments (18)

failwyn avatar failwyn commented on July 17, 2024 1

I have a few other issues to look at, but I will try my best to get a new release out by Monday.

from webcompiler.

failwyn avatar failwyn commented on July 17, 2024 1

I just pushed the version with this fix, please let me know if it resolved the issue.

from webcompiler.

dgoldm avatar dgoldm commented on July 17, 2024 1

I tested it in the scenario where I was having problems - works ok.

+1 for not wanting to modify too much code.
My approach in rewriting the module was to take into account Sass's coming deprecation of @import rules, but your approach of not wanting to rock the boat too hard makes sense too.

from webcompiler.

failwyn avatar failwyn commented on July 17, 2024 1

1.14.5 is now available and should address this issue

from webcompiler.

dgoldm avatar dgoldm commented on July 17, 2024

The fix works fine for basic @use rules, such as @use 'file1';
But not for those that use the full syntax, e.g.
@use 'file1' as *;
or
@use 'file1' with ($var1: 0);

from webcompiler.

failwyn avatar failwyn commented on July 17, 2024

@dgoldm Is there an exception or error shown?

from webcompiler.

dgoldm avatar dgoldm commented on July 17, 2024

No error shown.
Although apparently it's clear why it's not working, the match returned by the regex at line 53 of src/WebCompiler/Dependencies/SassDependencyResolver.cs includes all the characters up to the semicolon.

BTW, while investigating the issue I came across another problem with the above regex - if the @use or @import rule is commented out, it still matches, and the file is processed even though it shouldn't be.

from webcompiler.

failwyn avatar failwyn commented on July 17, 2024

@dgoldm That Regex is only responsible for identifying which files will trigger compilation on save, it has nothing to do with the actual compilation; the Sass CLI is used to compile the files; so, that regex doesn't need to be perfect.

from webcompiler.

dgoldm avatar dgoldm commented on July 17, 2024

Isn't that is precisely the issue? Currently when a @used file (which has an "as" or "with" clause in the line referencing it) is saved, the compiler isn't triggered.
(I noticed that line because it's the one that you changed in the commit that fixes the OP)

from webcompiler.

dgoldm avatar dgoldm commented on July 17, 2024

BTW, for now I found a simple workaround, taking advantage of the 2nd problem I described. My code looks like this:

main.scss:

@use "lib" as *;
//@use "lib"

Now, when I save lib.scss, the comment triggers the compilation of main.scss

from webcompiler.

failwyn avatar failwyn commented on July 17, 2024

Sorry, I think I misread your comment, I read it as the compilation wasn’t working correctly when using the other variations of @use; I’ll look i to why it’s not correctly parsing the file url out of the complex matches. Thanks for the clarification!

from webcompiler.

failwyn avatar failwyn commented on July 17, 2024

I’m not good enough with Regex to make the pattern match better, but I could split the string on “as” and “with” in the GetFileInfos function to get it working.

from webcompiler.

dgoldm avatar dgoldm commented on July 17, 2024

I'm no expert either, but may I offer a suggestion:
According to the docs, the syntax of @use & @forward is simpler than @import, specifically in that it only allows one file per rule.
Maybe you could process them separately?

This regex should work (capture what's in between the quotes following the at-rule):
(?<=^@use|^@forward)\s+(["'])(?<url>.+?[^\\])\1

This would allow restoring the original version of line 53 to process the @import rules.

from webcompiler.

dgoldm avatar dgoldm commented on July 17, 2024

@failwyn I modified the code and managed to create a working version (tested in VS 2022).
It looks like I'm missing some dependencies and tools on my machine to actually build the vsix, so I can't test the compiled extension itself.
Should I create a pull request?

from webcompiler.

failwyn avatar failwyn commented on July 17, 2024

If you want to check it in, I’ll take a look at it; I got it working with the string split, but if your fix is better, I’d be happy to implement it.

from webcompiler.

dgoldm avatar dgoldm commented on July 17, 2024

Done.
Note that also the original processing of @import rules wasn't complete - it also didn't cover cases where the rule contained optional clauses that are part of the syntax.
But since nobody has complained until today, and Sass is now deprecating @import, there's probably no point in fixing it.

from webcompiler.

failwyn avatar failwyn commented on July 17, 2024

I'm testing a fix for this that makes fewer changes and appears to work in all scenarios that I could think of without modifying too much code. I committed the change in a branch if anyone wants to review it before I merge it to release a new version.

from webcompiler.

failwyn avatar failwyn commented on July 17, 2024

Thank you for taking the time to rewrite the code and create the Pull Request, I really appreciate the help and input even if we didn’t use it this time. If I had the time to test it thoroughly I would have merged it. Thanks for validating this fix as well!

from webcompiler.

Related Issues (20)

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.