Skip to content

Commit

Permalink
Fix bug in --update with built-in modules (#1338)
Browse files Browse the repository at this point in the history
Fixes #1335.
  • Loading branch information
jathak committed Jun 2, 2021
1 parent 0db3415 commit af816d0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
## 1.34.1

* Fix a bug where `--update` would always compile any file that depends on a
built-in module.

* Fix the URL for the `@-moz-document` deprecation message.

* Fix a bug with `@for` loops nested inside property declarations.
Expand Down
9 changes: 5 additions & 4 deletions lib/src/visitor/find_dependencies.dart
Expand Up @@ -10,12 +10,13 @@ import 'recursive_statement.dart';
/// Returns two lists of dependencies for [stylesheet].
///
/// The first is a list of URLs from all `@use` and `@forward` rules in
/// [stylesheet]. The second is a list of all imports in [stylesheet].
/// [stylesheet] (excluding built-in modules). The second is a list of all
/// imports in [stylesheet].
Tuple2<List<Uri>, List<Uri>> findDependencies(Stylesheet stylesheet) =>
_FindDependenciesVisitor().run(stylesheet);

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

void visitUseRule(UseRule node) {
_usesAndForwards.add(node.url);
if (node.url.scheme != 'sass') _usesAndForwards.add(node.url);
}

void visitForwardRule(ForwardRule node) {
_usesAndForwards.add(node.url);
if (node.url.scheme != 'sass') _usesAndForwards.add(node.url);
}

void visitImportRule(ImportRule node) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,5 +1,5 @@
name: sass
version: 1.34.1-dev
version: 1.34.1
description: A Sass implementation in Dart.
author: Sass Team
homepage: https://github.com/sass/dart-sass
Expand Down
11 changes: 11 additions & 0 deletions test/cli/shared/update.dart
Expand Up @@ -183,6 +183,17 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {

await d.file("dir/test.css", "a {b: c}").validate();
});

test("that uses a built-in module", () async {
await d.file("test.scss", "@use 'sass:math'; a {b: c}").create();
await d.file("out.css", "x {y: z}").create();

var sass = await update(["test.scss:out.css"]);
expect(sass.stdout, emitsDone);
await sass.shouldExit(0);

await d.file("out.css", "x {y: z}").validate();
});
});

group("updates a CSS file", () {
Expand Down

0 comments on commit af816d0

Please sign in to comment.