From af816d094111b22a52c7fb8a1b86e0c905184364 Mon Sep 17 00:00:00 2001 From: Jennifer Thakar Date: Wed, 2 Jun 2021 14:52:17 -0700 Subject: [PATCH] Fix bug in --update with built-in modules (#1338) Fixes #1335. --- CHANGELOG.md | 3 +++ lib/src/visitor/find_dependencies.dart | 9 +++++---- pubspec.yaml | 2 +- test/cli/shared/update.dart | 11 +++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5e169bad..f69bd3ec8 100644 --- a/CHANGELOG.md +++ b/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. diff --git a/lib/src/visitor/find_dependencies.dart b/lib/src/visitor/find_dependencies.dart index 80a876fa5..64bd2095a 100644 --- a/lib/src/visitor/find_dependencies.dart +++ b/lib/src/visitor/find_dependencies.dart @@ -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> 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 = []; final _imports = []; @@ -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) { diff --git a/pubspec.yaml b/pubspec.yaml index 197eddbbb..f27aad41c 100644 --- a/pubspec.yaml +++ b/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 diff --git a/test/cli/shared/update.dart b/test/cli/shared/update.dart index 3453f12ec..fb45398c9 100644 --- a/test/cli/shared/update.dart +++ b/test/cli/shared/update.dart @@ -183,6 +183,17 @@ void sharedTests(Future runSass(Iterable 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", () {