Skip to content

Commit af816d0

Browse files
authored
Fix bug in --update with built-in modules (#1338)
Fixes #1335.
1 parent 0db3415 commit af816d0

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## 1.34.1
22

3+
* Fix a bug where `--update` would always compile any file that depends on a
4+
built-in module.
5+
36
* Fix the URL for the `@-moz-document` deprecation message.
47

58
* Fix a bug with `@for` loops nested inside property declarations.

lib/src/visitor/find_dependencies.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import 'recursive_statement.dart';
1010
/// Returns two lists of dependencies for [stylesheet].
1111
///
1212
/// The first is a list of URLs from all `@use` and `@forward` rules in
13-
/// [stylesheet]. The second is a list of all imports in [stylesheet].
13+
/// [stylesheet] (excluding built-in modules). The second is a list of all
14+
/// imports in [stylesheet].
1415
Tuple2<List<Uri>, List<Uri>> findDependencies(Stylesheet stylesheet) =>
1516
_FindDependenciesVisitor().run(stylesheet);
1617

1718
/// A visitor that traverses a stylesheet and records, all `@import`, `@use`,
18-
/// and `@forward` rules it contains.
19+
/// and `@forward` rules (excluding built-in modules) it contains.
1920
class _FindDependenciesVisitor extends RecursiveStatementVisitor {
2021
final _usesAndForwards = <Uri>[];
2122
final _imports = <Uri>[];
@@ -35,11 +36,11 @@ class _FindDependenciesVisitor extends RecursiveStatementVisitor {
3536
void visitSupportsCondition(SupportsCondition condition) {}
3637

3738
void visitUseRule(UseRule node) {
38-
_usesAndForwards.add(node.url);
39+
if (node.url.scheme != 'sass') _usesAndForwards.add(node.url);
3940
}
4041

4142
void visitForwardRule(ForwardRule node) {
42-
_usesAndForwards.add(node.url);
43+
if (node.url.scheme != 'sass') _usesAndForwards.add(node.url);
4344
}
4445

4546
void visitImportRule(ImportRule node) {

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.34.1-dev
2+
version: 1.34.1
33
description: A Sass implementation in Dart.
44
author: Sass Team
55
homepage: https://github.com/sass/dart-sass

test/cli/shared/update.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
183183

184184
await d.file("dir/test.css", "a {b: c}").validate();
185185
});
186+
187+
test("that uses a built-in module", () async {
188+
await d.file("test.scss", "@use 'sass:math'; a {b: c}").create();
189+
await d.file("out.css", "x {y: z}").create();
190+
191+
var sass = await update(["test.scss:out.css"]);
192+
expect(sass.stdout, emitsDone);
193+
await sass.shouldExit(0);
194+
195+
await d.file("out.css", "x {y: z}").validate();
196+
});
186197
});
187198

188199
group("updates a CSS file", () {

0 commit comments

Comments
 (0)