Skip to content

Commit b0e456e

Browse files
committed
Reorder @forward rules in import-only files
Ensures that variables from indirect dependencies are still configurable via `@import`.
1 parent 7b0faa3 commit b0e456e

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

lib/src/migrators/module.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,12 @@ class _ModuleMigrationVisitor extends MigrationVisitor {
296296
_absoluteUrlToDependency(entry.key, relativeTo: importOnlyUrl)
297297
.item1,
298298
entry.value)
299-
]..sort((a, b) => a.item2.compareTo(b.item2));
299+
];//..sort((a, b) => a.item2.compareTo(b.item2));
300300
var forwardLines = [
301-
...entrypointForwards,
302301
for (var tuple in tuples)
303302
..._forwardRulesForShown(tuple.item1, tuple.item2, tuple.item3,
304-
hiddenByUrl[tuple.item1] ?? {})
303+
hiddenByUrl[tuple.item1] ?? {}),
304+
...entrypointForwards
305305
];
306306
var semicolon = entrypoint.path.endsWith('.sass') ? '' : ';';
307307
return forwardLines.join('$semicolon\n') + '$semicolon\n';

test/migrators/module/forward_flag/import_only.hrx

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ a {
1919
}
2020

2121
<==> output/entrypoint.import.scss
22-
@forward "entrypoint";
2322
@forward "library";
23+
@forward "entrypoint";

test/migrators/module/forward_flag/import_only_multiple_entrypoints.hrx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ $lib-variable2: 1;
1515
$variable1: 1 + entrypoint2.$variable2;
1616

1717
<==> output/entrypoint1.import.scss
18-
@forward "entrypoint1" as lib-*;
1918
@forward "entrypoint2" as lib-*;
19+
@forward "entrypoint1" as lib-*;
2020

2121
<==> output/entrypoint2.scss
2222
$variable2: 1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<==> arguments
2+
--migrate-deps --forward=import-only
3+
4+
<==> input/entrypoint.scss
5+
@import "c";
6+
@import "b";
7+
8+
a {
9+
b: $b-variable;
10+
c: $c-variable;
11+
}
12+
13+
<==> input/_b.scss
14+
$variable: blue !default;
15+
16+
<==> input/_b.import.scss
17+
@forward "b" as b-*;
18+
19+
<==> input/_c.scss
20+
$variable: gold !default;
21+
22+
<==> input/_c.import.scss
23+
@forward "c" as c-*;
24+
25+
<==> output/entrypoint.scss
26+
@use "c";
27+
@use "b";
28+
29+
a {
30+
b: b.$variable;
31+
c: c.$variable;
32+
}
33+
34+
<==> output/entrypoint.import.scss
35+
@forward "c" as c-*;
36+
@forward "b" as b-*;
37+
@forward "entrypoint";

test/migrators/module/forward_flag/import_only_prefixed.hrx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ $variable: blue;
1616
$unprefixed: gold;
1717

1818
<==> output/entrypoint.import.scss
19-
@forward "entrypoint" as lib-*;
2019
@forward "library" hide $variable;
20+
@forward "entrypoint" as lib-*;

0 commit comments

Comments
 (0)