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

Handle case where a stylesheet is configuring an indirect dependency #28

Open
jathak opened this Issue Apr 10, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@jathak
Copy link
Member

commented Apr 10, 2019

Something like this

// entrypoint.scss
$config: red;
@import "direct";

// _direct.scss
@import "indirect";

// _indirect.scss
$config: green !default;

is currently migrated to

// entrypoint.scss
$config: red;
@use "direct";

// _direct.scss
@use "entrypoint";
@use  "indirect";

// _indirect.scss
$config: green !default;

which is definitely wrong, but I'm also not sure what the best way to actually do it would be.

@nex3

This comment has been minimized.

Copy link
Contributor

commented Apr 10, 2019

I guess something like this:

// entrypoint.scss
@use "direct" with ($config: red);

// _direct.scss
@forward "indirect";

// _indirect.scss
$config: green !default;
@jathak

This comment has been minimized.

Copy link
Member Author

commented Apr 12, 2019

What about cases like this, where the intermediate dependency also uses the variable that's being configured?

// entrypoint.scss
$config: red;
@import "direct";

// _direct.scss
@import "indirect";
a {
  b: $config;
}

// _indirect.scss
$config: green !default;

This is my best guess, but I'm not sure whether $indirect.config would be red or green in this case.

// entrypoint.scss
@use "direct" with ($config: red);

// _direct.scss
@forward "indirect";
@use  "indirect";
a {
  b: $indirect.config;
}

// _indirect.scss
$config: green !default;
@nex3

This comment has been minimized.

Copy link
Contributor

commented Apr 15, 2019

I think your translation is correct, except that the first file should be @use "direct" with ($config: red) (which I think is what you meant). In that case, $indirect.config will be green (every variable has only one value at a time, no matter how it's accessed, and configuration happens when evaluating the @forward rule).

@jathak

This comment has been minimized.

Copy link
Member Author

commented Apr 15, 2019

Whoops, forgot to add the clause. Edited for clarity.

Is there a way to match the original behavior where the output would be a { b: red } in the module system?

@nex3

This comment has been minimized.

Copy link
Contributor

commented Apr 15, 2019

Sorry, I'm kind of out of it... I meant to say that the $indirect.config will be red.

@jathak jathak referenced a pull request that will close this issue Apr 23, 2019

Open

Properly support configurable variables #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.