diff --git a/lib/src/executable/watch.dart b/lib/src/executable/watch.dart index e7f051b1..48dd37d7 100644 --- a/lib/src/executable/watch.dart +++ b/lib/src/executable/watch.dart @@ -43,7 +43,8 @@ Future watch(ExecutableOptions options, StylesheetGraph graph) async { for (var source in options.sourcesToDestinations.keys) { var destination = options.sourcesToDestinations[source]; graph.addCanonical(FilesystemImporter('.'), p.toUri(p.canonicalize(source)), - p.toUri(source)); + p.toUri(source), + recanonicalize: false); var success = await watcher.compile(source, destination, ifModified: true); if (!success && options.stopOnError) { dirWatcher.events.listen(null).cancel(); diff --git a/lib/src/stylesheet_graph.dart b/lib/src/stylesheet_graph.dart index 1ce55c65..8e970df5 100644 --- a/lib/src/stylesheet_graph.dart +++ b/lib/src/stylesheet_graph.dart @@ -86,8 +86,14 @@ class StylesheetGraph { /// Returns the set of nodes that need to be recompiled because their imports /// changed as a result of this stylesheet being added. This does not include /// the new stylesheet, which can be accessed via `nodes[canonicalUrl]`. + /// + /// If [recanonicalize] is `false`, this instead avoids checking downstream + /// nodes' imports and always returns an empty set. It should only be set to + /// `false` when initially adding stylesheets, not when handling future + /// updates. Set addCanonical( - Importer importer, Uri canonicalUrl, Uri originalUrl) { + Importer importer, Uri canonicalUrl, Uri originalUrl, + {bool recanonicalize = true}) { var node = _nodes[canonicalUrl]; if (node != null) return const {}; @@ -99,7 +105,9 @@ class StylesheetGraph { _upstreamNodes(stylesheet, importer, canonicalUrl)); _nodes[canonicalUrl] = node; - return _recanonicalizeImports(importer, canonicalUrl); + return recanonicalize + ? _recanonicalizeImports(importer, canonicalUrl) + : const {}; } /// Returns two maps from non-canonicalized imported URLs in [stylesheet] to