feat(dart/transform): Do not re-process generated files
In the `DeferredRewriter` phase, do not process files which were generated by the transformer, since these will never need to be rewritten.
This commit is contained in:
parent
3f4628c0b0
commit
8f91ff84c7
|
@ -30,6 +30,20 @@ const ALL_EXTENSIONS = const [
|
|||
'.dart'
|
||||
];
|
||||
|
||||
/// Whether `uri` was created by a transform phase.
|
||||
///
|
||||
/// This may return false positives for problematic inputs.
|
||||
/// This just tests file extensions known to be created by the transformer, so
|
||||
/// any files named like transformer outputs will be reported as generated.
|
||||
bool isGenerated(String uri) {
|
||||
return const [
|
||||
DEPS_EXTENSION,
|
||||
NON_SHIMMED_STYLESHEET_EXTENSION,
|
||||
SHIMMED_STYLESHEET_EXTENSION,
|
||||
TEMPLATE_EXTENSION,
|
||||
].any((ext) => uri.endsWith(ext));
|
||||
}
|
||||
|
||||
/// Returns `uri` with its extension updated to [META_EXTENSION].
|
||||
String toMetaExtension(String uri) =>
|
||||
_toExtension(uri, ALL_EXTENSIONS, META_EXTENSION);
|
||||
|
|
|
@ -21,7 +21,7 @@ class DeferredRewriter extends Transformer {
|
|||
|
||||
@override
|
||||
bool isPrimary(AssetId id) =>
|
||||
id.extension.endsWith('dart') && !id.path.endsWith(DEPS_EXTENSION);
|
||||
id.extension.endsWith('dart') && _isNotGenerated(id);
|
||||
|
||||
@override
|
||||
Future apply(Transform transform) async {
|
||||
|
@ -36,6 +36,8 @@ class DeferredRewriter extends Transformer {
|
|||
}
|
||||
}
|
||||
|
||||
bool _isNotGenerated(AssetId id) => !isGenerated(id.path);
|
||||
|
||||
// Visible for testing
|
||||
Future<String> rewriteDeferredLibraries(AssetReader reader, AssetId id) async {
|
||||
var rewriter = new Rewriter(id, reader);
|
||||
|
|
Loading…
Reference in New Issue