Skip to content

Commit 4405957

Browse files
authored
Watch files through @forward rules (#871)
Closes #870
1 parent 071c529 commit 4405957

File tree

4 files changed

+69
-16
lines changed

4 files changed

+69
-16
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.23.4
2+
3+
### Command-Line Interface
4+
5+
* Fix a bug where `--watch` wouldn't watch files referred to by `@forward`
6+
rules.
7+
18
## 1.23.3
29

310
* Fix a bug where selectors were being trimmed over-eagerly when `@extend`

lib/src/visitor/find_imports.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class _FindImportsVisitor extends RecursiveStatementVisitor<void> {
3232
_imports.add(DynamicImport(node.url.toString(), node.span));
3333
}
3434

35+
void visitForwardRule(ForwardRule node) {
36+
_imports.add(DynamicImport(node.url.toString(), node.span));
37+
}
38+
3539
void visitImportRule(ImportRule node) {
3640
for (var import in node.imports) {
3741
if (import is DynamicImport) _imports.add(import);

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.23.3
2+
version: 1.23.4
33
description: A Sass implementation in Dart.
44
author: Sass Team
55
homepage: https://github.com/sass/dart-sass

test/cli/shared/watch.dart

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,66 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
173173
]).validate();
174174
});
175175

176-
test("when its dependency is modified", () async {
177-
await d.file("_other.scss", "a {b: c}").create();
178-
await d.file("test.scss", "@import 'other'").create();
176+
group("when its dependency is modified", () {
177+
test("through @import", () async {
178+
await d.file("_other.scss", "a {b: c}").create();
179+
await d.file("test.scss", "@import 'other'").create();
179180

180-
var sass = await watch(["test.scss:out.css"]);
181-
await expectLater(
182-
sass.stdout, emits('Compiled test.scss to out.css.'));
183-
await expectLater(sass.stdout, _watchingForChanges);
184-
await tickIfPoll();
181+
var sass = await watch(["test.scss:out.css"]);
182+
await expectLater(
183+
sass.stdout, emits('Compiled test.scss to out.css.'));
184+
await expectLater(sass.stdout, _watchingForChanges);
185+
await tickIfPoll();
185186

186-
await d.file("_other.scss", "x {y: z}").create();
187-
await expectLater(
188-
sass.stdout, emits('Compiled test.scss to out.css.'));
189-
await sass.kill();
187+
await d.file("_other.scss", "x {y: z}").create();
188+
await expectLater(
189+
sass.stdout, emits('Compiled test.scss to out.css.'));
190+
await sass.kill();
190191

191-
await d
192-
.file("out.css", equalsIgnoringWhitespace("x { y: z; }"))
193-
.validate();
192+
await d
193+
.file("out.css", equalsIgnoringWhitespace("x { y: z; }"))
194+
.validate();
195+
});
196+
197+
test("through @use", () async {
198+
await d.file("_other.scss", "a {b: c}").create();
199+
await d.file("test.scss", "@use 'other'").create();
200+
201+
var sass = await watch(["test.scss:out.css"]);
202+
await expectLater(
203+
sass.stdout, emits('Compiled test.scss to out.css.'));
204+
await expectLater(sass.stdout, _watchingForChanges);
205+
await tickIfPoll();
206+
207+
await d.file("_other.scss", "x {y: z}").create();
208+
await expectLater(
209+
sass.stdout, emits('Compiled test.scss to out.css.'));
210+
await sass.kill();
211+
212+
await d
213+
.file("out.css", equalsIgnoringWhitespace("x { y: z; }"))
214+
.validate();
215+
});
216+
217+
test("through @forward", () async {
218+
await d.file("_other.scss", "a {b: c}").create();
219+
await d.file("test.scss", "@forward 'other'").create();
220+
221+
var sass = await watch(["test.scss:out.css"]);
222+
await expectLater(
223+
sass.stdout, emits('Compiled test.scss to out.css.'));
224+
await expectLater(sass.stdout, _watchingForChanges);
225+
await tickIfPoll();
226+
227+
await d.file("_other.scss", "x {y: z}").create();
228+
await expectLater(
229+
sass.stdout, emits('Compiled test.scss to out.css.'));
230+
await sass.kill();
231+
232+
await d
233+
.file("out.css", equalsIgnoringWhitespace("x { y: z; }"))
234+
.validate();
235+
});
194236
});
195237

196238
test("when it's deleted and re-added", () async {

0 commit comments

Comments
 (0)