Skip to content

Module migrator can generate @use loops #137

@nex3

Description

@nex3
Contributor

If the entrypoint imports a file that uses variables that were originally defined in the entrypoint, the migrator generates a @use that imports the original file. For example:

// entrypoint.scss
$var: value;

@import "other";
// _other.scss
@debug $var;

is migrated to:

// entrypoint.scss
$var: value;

@use "other";
// _other.scss
@use "entrypoint";
@debug entrypoint.$var;

This is invalid, as it creates a dependency loop. Since it's not totally clear what the user intended, the migrator should probably error out.

Activity

added
bugSomething isn't working
on Feb 4, 2020
changed the title [-]Migrator can generate @use loops[/-] [+]Module migrator can generate @use loops[/+] on Feb 4, 2020
pamelalozano16

pamelalozano16 commented on Dec 7, 2023

@pamelalozano16
Contributor

The given example may be a bit misleading. Here's another example to provide to elaborate further.
Input:

<==> entrypoint.scss
@import "library";
$var: $value;

<==> _library.scss
$value: blue;
a {
  color: $var;
}

Output:

<==> entrypoint.scss
@use "library";
$var: library.$value;

<==> _library.scss
@use "entrypoint";

$value: blue;
a {
  color: entrypoint.$var;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmodule systemPart of the module system migrator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @nex3@pamelalozano16

      Issue actions

        Module migrator can generate @use loops · Issue #137 · sass/migrator