diff --git a/lib/src/async_environment.dart b/lib/src/async_environment.dart index 7bc7e824..c7e48939 100644 --- a/lib/src/async_environment.dart +++ b/lib/src/async_environment.dart @@ -632,6 +632,7 @@ class _EnvironmentModule implements AsyncModule { final Extender extender; final CssStylesheet css; final bool transitivelyContainsCss; + final bool transitivelyContainsExtensions; /// The environment that defines this module's members. final AsyncEnvironment _environment; @@ -648,7 +649,10 @@ class _EnvironmentModule implements AsyncModule { mixins = PublicMemberMap(_environment._mixins.first), transitivelyContainsCss = css.children.isNotEmpty || _environment._allModules - .any((module) => module.transitivelyContainsCss); + .any((module) => module.transitivelyContainsCss), + transitivelyContainsExtensions = !extender.isEmpty || + _environment._allModules + .any((module) => module.transitivelyContainsExtensions); void setVariable(String name, Value value, AstNode nodeWithSpan) { if (!_environment._variables.first.containsKey(name)) { diff --git a/lib/src/async_module.dart b/lib/src/async_module.dart index 70b9a26e..7e0b4f70 100644 --- a/lib/src/async_module.dart +++ b/lib/src/async_module.dart @@ -58,6 +58,10 @@ abstract class AsyncModule { /// Whether this module *or* any modules in [upstream] contain any CSS. bool get transitivelyContainsCss; + /// Whether this module *or* any modules in [upstream] contain `@extend` + /// rules.. + bool get transitivelyContainsExtensions; + /// Sets the variable named [name] to [value], associated with /// [nodeWithSpan]'s source span. /// diff --git a/lib/src/environment.dart b/lib/src/environment.dart index 7d4eb35d..a57dee88 100644 --- a/lib/src/environment.dart +++ b/lib/src/environment.dart @@ -5,7 +5,7 @@ // DO NOT EDIT. This file was generated from async_environment.dart. // See tool/synchronize.dart for details. // -// Checksum: 097eb94cd15103bf4bef739a61e61414db4b55b1 +// Checksum: 3210a5c0528eac456ae8ca7827b65f3976f6b29d // // ignore_for_file: unused_import @@ -634,6 +634,7 @@ class _EnvironmentModule implements Module { final Extender extender; final CssStylesheet css; final bool transitivelyContainsCss; + final bool transitivelyContainsExtensions; /// The environment that defines this module's members. final Environment _environment; @@ -650,7 +651,10 @@ class _EnvironmentModule implements Module { mixins = PublicMemberMap(_environment._mixins.first), transitivelyContainsCss = css.children.isNotEmpty || _environment._allModules - .any((module) => module.transitivelyContainsCss); + .any((module) => module.transitivelyContainsCss), + transitivelyContainsExtensions = !extender.isEmpty || + _environment._allModules + .any((module) => module.transitivelyContainsExtensions); void setVariable(String name, Value value, AstNode nodeWithSpan) { if (!_environment._variables.first.containsKey(name)) { diff --git a/lib/src/module.dart b/lib/src/module.dart index 5fb0fc53..67167596 100644 --- a/lib/src/module.dart +++ b/lib/src/module.dart @@ -5,7 +5,7 @@ // DO NOT EDIT. This file was generated from async_module.dart. // See tool/synchronize.dart for details. // -// Checksum: 895440529b78f1ef2830cf105af00dba0755e947 +// Checksum: d996840504b080c2c4e6b34136562b8152bb2e97 // // ignore_for_file: unused_import @@ -65,6 +65,10 @@ abstract class Module { /// Whether this module *or* any modules in [upstream] contain any CSS. bool get transitivelyContainsCss; + /// Whether this module *or* any modules in [upstream] contain `@extend` + /// rules.. + bool get transitivelyContainsExtensions; + /// Sets the variable named [name] to [value], associated with /// [nodeWithSpan]'s source span. /// diff --git a/lib/src/visitor/async_evaluate.dart b/lib/src/visitor/async_evaluate.dart index 0e9179c3..8fbc8f1f 100644 --- a/lib/src/visitor/async_evaluate.dart +++ b/lib/src/visitor/async_evaluate.dart @@ -1033,7 +1033,12 @@ class _EvaluateVisitor var module = environment.toModule( CssStylesheet(const [], stylesheet.span), Extender.empty); if (module.transitivelyContainsCss) { - await _combineCss(module, clone: true).accept(this); + // If any transitively used module contains extensions, we need to clone + // all modules' CSS. Otherwise, it's possible that they'll be used or + // imported from another location that shouldn't have the same extensions + // applied. + await _combineCss(module, clone: module.transitivelyContainsExtensions) + .accept(this); } var visitor = _ImportedCssVisitor(this); diff --git a/lib/src/visitor/evaluate.dart b/lib/src/visitor/evaluate.dart index 92a0e919..44153ce9 100644 --- a/lib/src/visitor/evaluate.dart +++ b/lib/src/visitor/evaluate.dart @@ -5,7 +5,7 @@ // DO NOT EDIT. This file was generated from async_evaluate.dart. // See tool/synchronize.dart for details. // -// Checksum: 0f4f00db38a7f2a60771d3d50652cbfdeb322e52 +// Checksum: 4de442e73c75611a675e2fd0d8962219f1ceffd7 // // ignore_for_file: unused_import @@ -1036,7 +1036,12 @@ class _EvaluateVisitor var module = environment.toModule( CssStylesheet(const [], stylesheet.span), Extender.empty); if (module.transitivelyContainsCss) { - _combineCss(module, clone: true).accept(this); + // If any transitively used module contains extensions, we need to clone + // all modules' CSS. Otherwise, it's possible that they'll be used or + // imported from another location that shouldn't have the same extensions + // applied. + _combineCss(module, clone: module.transitivelyContainsExtensions) + .accept(this); } var visitor = _ImportedCssVisitor(this);