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

JS API - Compilation fails with double-slash comments in the given Sass code #2099

Closed
parasshah195 opened this issue Sep 27, 2023 · 2 comments

Comments

@parasshah195
Copy link

parasshah195 commented Sep 27, 2023

My setup is running Sass JS API from the Sass code fetched from Codemirror editor. The project is bundled using Vite, and I'm using the Svelte framework.

I've cleaned up the line breaks, but on sending Sass code with double-slash comments (//), it throws an error.

Code sass compilation usage:

sass.compileString(sassCode, {
    style: 'compressed',
    quietDeps: true,
    syntax: 'scss',
  });

where sassCode can be a string literal like:

`h1 {
  font-size: 5rem;
  // color: orange;
}`

On running it by passing the string after removing line breaks, this is the error I get:
image

On trying to reproduce on different Typescript setups in online code editors (codesandbox, stackblitz, codepen), all of them just straight up fail with altogether another error Cannot read properties of undefined (reading 'isTTY'), but that's a different topic.

Is this error being caused by something in my setup bundling? Or can somebody else reproduce it at their end and is it a bug in the library code?

@parasshah195
Copy link
Author

Just realized that this error is happening because of removal of line breaks, causing comment to wrap onto the same line and everything else past that being commented (including the closing brace).

In which case, any suggestions/ideas as to how to handle line breaks in Sass string with comments?

@nex3
Copy link
Contributor

nex3 commented Sep 27, 2023

Sass isn't removing the line breaks here, something else is removing them before Sass ever sees the input.

@nex3 nex3 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants