mirror of
https://github.com/danog/dart-sass.git
synced 2024-12-02 09:37:49 +01:00
a333059e71
Prior to this, the watcher handled all the logic around recompiling stylesheets if an upstream file was deleted or added in a way that could affect their import resolution. This left a gap where the stylesheet graph wouldn't be aware that a newly-added file had become upstream dependency of an existing downstream file, leading to recompilation failures. This commit fixes that by moving all that logic into the stylesheet graph. The graph now has full and sole responsibility for providing a consistent view of which stylesheets depend on one another even as the shape of the graph changes, and the watcher is just a client of that logic. Closes #550
42 lines
1.4 KiB
Dart
42 lines
1.4 KiB
Dart
// Copyright 2017 Google Inc. Use of this source code is governed by an
|
|
// MIT-style license that can be found in the LICENSE file or at
|
|
// https://opensource.org/licenses/MIT.
|
|
|
|
import 'importer/async.dart';
|
|
import 'importer/no_op.dart';
|
|
import 'importer/result.dart';
|
|
|
|
export 'importer/async.dart';
|
|
export 'importer/filesystem.dart';
|
|
export 'importer/package.dart';
|
|
export 'importer/result.dart';
|
|
|
|
/// An interface for importers that resolves URLs in `@import`s to the contents
|
|
/// of Sass files.
|
|
///
|
|
/// Importers should override [toString] to provide a human-readable description
|
|
/// of the importer. For example, the default filesystem importer returns its
|
|
/// load path.
|
|
///
|
|
/// This extends [AsyncImporter] to guarantee that [canonicalize] and [load] are
|
|
/// synchronous. It's usable with both the synchronous and asynchronous
|
|
/// `compile()` functions, and as such should be extended in preference to
|
|
/// [AsyncImporter] if possible.
|
|
///
|
|
/// Subclasses should extend [Importer], not implement it.
|
|
abstract class Importer extends AsyncImporter {
|
|
/// An importer that never imports any stylesheets.
|
|
///
|
|
/// This is used for stylesheets which don't support relative imports, such as
|
|
/// those created from Dart code with plain strings.
|
|
static final Importer noOp = NoOpImporter();
|
|
|
|
Uri canonicalize(Uri url);
|
|
|
|
ImporterResult load(Uri url);
|
|
|
|
DateTime modificationTime(Uri url) => DateTime.now();
|
|
|
|
bool couldCanonicalize(Uri url, Uri canonicalUrl) => true;
|
|
}
|