8000
Skip to content

prettyUri generates incorrect relative location of sassStack for sass-embedded #2775

Description

@ntkme

With the following code:

sass.compileString('a {b:}', {url: `file://${process.cwd()}/test.scss`})

sass produces:

sass.Exception [Error]: Expected expression.
  ╷
1 │ a {b:}
  │      ^
  ╵
  test.scss 1:6  root stylesheet

sass-embedded produces:

Exception [Error]: Error: Expected expression.
  ╷
1 │ a {b:}
  │      ^
  ╵
  ../../../../test.scss 1:6  root stylesheet

How does it work internally:

  1. sassStack internally is a Trace object

  2. trace.toString() internal calls path.prettyUri(uri)

  3. path.prettyUri(uri) convert absolute file uri to relative uri, from the current working directory.


Now, here is the problem:

In native dart sass or npm sass package, it's more or less limited by the fact that the context of sassStack is the current working directory of the running dart vm or node vm. However, in npm sass-embedded package, because the working directory of the host and the compiler is different, it produces a ../../../../ prefix on sassStack.

Concurrent implementation of the host allows the host side to concurrently submit different compilation requests in different working directory, and then they can change directory before the compilation is completed. So, the definition of what should be the relative context for sassStack on the host time itself can be ambiguous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0