Skip to content

Module migrator can generate @use loops #137

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
nex3 opened this issue Feb 4, 2020 · 1 comment · May be fixed by #249
Open

Module migrator can generate @use loops #137

nex3 opened this issue Feb 4, 2020 · 1 comment · May be fixed by #249
Labels
bug Something isn't working module system Part of the module system migrator

Comments

@nex3
Copy link
Contributor

nex3 commented Feb 4, 2020

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.

@nex3 nex3 added the bug Something isn't working label Feb 4, 2020
@nex3 nex3 changed the title Migrator can generate @use loops Module migrator can generate @use loops Feb 4, 2020
@nex3 nex3 added the module system Part of the module system migrator label Feb 4, 2020
@pamelalozano16
Copy link
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;
}

@pamelalozano16 pamelalozano16 linked a pull request Dec 12, 2023 that will close this issue
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working module system Part of the module system migrator
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants