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

New code at beginning of file should be inserted after BOM #234

Open
lwpinion opened this issue Sep 27, 2022 · 3 comments
Open

New code at beginning of file should be inserted after BOM #234

lwpinion opened this issue Sep 27, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@lwpinion
Copy link

Operating System
Windows 10

Sass Version
1.55.0 (compiled with dart2js 2.18.1)

Migrator Version
1.7.1 (compiled with dart2js 2.18.0)

After using the migrator on a large number of files, I encountered a bug when it came to the styles on my home page. I dug into it and turns out when the migrator tool inserts the use rule it injected some sort of hidden character along with the line break (see screenshot).

sass-hidden-character

I am on Windows, so perhaps this is due to some sort of discrepancy with the line breaks between operating systems? Visual Studio does notify me on each file that the line endings are inconsistent; however, no matter what option I choose I still get this invisible character.

sass-line-endings

Fwiw, there's no urgency to fix this. I just went through all of my files and deleted that character before each rule.

@jathak
Copy link
Member

jathak commented Oct 3, 2022

Can you provide a minimal reproduction with an input file and migrator invocation that causes this error?

Also, is everything entirely running within Windows, or are you using a tool like WSL, or any other intermediate tools that could be messing with the file format?

@jathak jathak added the needs info Awaiting a response with more info from the reporter label Oct 3, 2022
@lwpinion
Copy link
Author

lwpinion commented Oct 3, 2022

Can you provide a minimal reproduction with an input file and migrator invocation that causes this error?

Are you looking for me to provide something you can use to reproduce the issue? I'm sorry, but I don't fully understand what you are needing.

If it's helpful, I ran sass-migrator --migrate-deps module style.scss on a large centralized stylesheet we use to import all of our partials. It's those partial that ended up with the extra character. The code in each of these files was previously flush at the top, but sass-migrator went through and added the @use statements to the top with the extra line breaks (along with this character) as you can see in my earlier post.

As to your second question, I was using bash inside of Cmder (I prefer bash commands over Windows commands), so I thought there could be something there. However, I tried running sass-migrator with Command Prompt and still got the same issue.

I took my existing files and copied them to a temp folder before running it. Other than that, the only tools I used were Command Prompt and then VS Code to look at the files. Below is a screenshot of how VS Code interprets the invisible character.

image

@stof
Copy link

stof commented Sep 14, 2023

This U+FEFF unicode character is the BOM.

I guess the sass-migrator should ensure that if a file starts with a BOM, it inserts the use statement after it rather than before it. The BOM needs to stay the first thing in the file.

@nex3 nex3 added bug Something isn't working and removed needs info Awaiting a response with more info from the reporter labels Sep 15, 2023
@jathak jathak changed the title Hidden no-break space character preventing styles from loading New code at beginning of file should be inserted after BOM Sep 18, 2023
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

No branches or pull requests

4 participants