Skip to content

Migrator treats @imports as nested if they are preceded by any rule, regardless of actual nesting #278

Open
@ettmetal

Description

@ettmetal

When using the migrator for modules, if there is any rule in the file preceding an @import directive for a partial which uses sass variables declared in that file, the tool fails. The following error message is produced:

Error: This stylesheet was loaded by a nested import in minimal.sass. The module system only supports loading nested CSS using the load-css() mixin, which doesn't allow access to variables from the outer stylesheet.

The error is not documented, and I couldn't find it anywhere in this repo outside of a test spec which didn't offer much more insight into the cause. In this failure case, it's a little confusing as output, because there are no nested imports.

Expected behaviour: The migrator does not treat non-nested imports as nested.

Minimal reproducable example:

minimal.sass:

$text-color: #fff

body
    background: #000

// Import partials.
@import "minimal/base"

_base.sass:

body
  color: $text-color

command:

$ sass-migrator module -dv ./minimal.sass

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcosmeticDoesn't affect semantics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions