diff --git a/CHANGELOG.md b/CHANGELOG.md index 8052f0f4b..581fc7b0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ * Fix a bug preventing built-in modules from being loaded within a configured module. +* Fix a bug preventing an unconfigured module from being loaded from within two + different configured modules. + * Fix a bug when `meta.load-css()` was used to load some files that included media queries. diff --git a/lib/src/visitor/async_evaluate.dart b/lib/src/visitor/async_evaluate.dart index aa7156e1c..dd21009b8 100644 --- a/lib/src/visitor/async_evaluate.dart +++ b/lib/src/visitor/async_evaluate.dart @@ -413,9 +413,9 @@ class _EvaluateVisitor var url = Uri.parse(arguments[0].assertString("module").text); var withMap = arguments[1].realNull?.assertMap("with")?.contents; - Map configuration; + var configuration = const {}; if (withMap != null) { - configuration = {}; + configuration = {}; var span = _callableNode.span; withMap.forEach((variable, value) { var name = @@ -525,11 +525,9 @@ class _EvaluateVisitor {Uri baseUrl, Map configuration, bool namesInErrors = false}) async { - configuration ??= const {}; - var builtInModule = _builtInModules[url]; if (builtInModule != null) { - if (configuration.isNotEmpty) { + if (configuration != null && configuration.isNotEmpty) { throw _exception( namesInErrors ? "Built-in module $url can't be configured." @@ -589,12 +587,11 @@ class _EvaluateVisitor Future _execute(AsyncImporter importer, Stylesheet stylesheet, {Map configuration, bool namesInErrors = false}) async { - configuration ??= const {}; var url = stylesheet.span.sourceUrl; var alreadyLoaded = _modules[url]; if (alreadyLoaded != null) { - if (configuration.isNotEmpty || _configuration.isNotEmpty) { + if ((configuration ?? _configuration).isNotEmpty) { throw _exception(namesInErrors ? "${p.prettyUri(url)} was already loaded, so it can't be " "configured using \"with\"." @@ -637,7 +634,10 @@ class _EvaluateVisitor _atRootExcludingStyleRule = false; _inKeyframes = false; - if (configuration.isNotEmpty) _configuration = Map.of(configuration); + if (configuration != null) { + _configuration = + configuration.isEmpty ? const {} : Map.of(configuration); + } await visitStylesheet(stylesheet); css = _outOfOrderImports == null @@ -658,7 +658,7 @@ class _EvaluateVisitor _atRootExcludingStyleRule = oldAtRootExcludingStyleRule; _inKeyframes = oldInKeyframes; - if (configuration.isNotEmpty && _configuration.isNotEmpty) { + if (configuration != null && _configuration.isNotEmpty) { throw _exception( namesInErrors ? "\$${_configuration.keys.first} was not declared with " @@ -1780,7 +1780,7 @@ class _EvaluateVisitor _environment.addModule(module, namespace: node.namespace); }, configuration: node.configuration.isEmpty - ? null + ? const {} : { for (var entry in node.configuration.entries) entry.key: _ConfiguredValue( diff --git a/lib/src/visitor/evaluate.dart b/lib/src/visitor/evaluate.dart index a9f077104..0ae5ccb0d 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/grind/synchronize.dart for details. // -// Checksum: 9083313a65eb24875e7292b859202fd574daf46b +// Checksum: 8abca72a6d671844aa9eb075aef56f58fd71ddf7 // // ignore_for_file: unused_import @@ -419,9 +419,9 @@ class _EvaluateVisitor var url = Uri.parse(arguments[0].assertString("module").text); var withMap = arguments[1].realNull?.assertMap("with")?.contents; - Map configuration; + var configuration = const {}; if (withMap != null) { - configuration = {}; + configuration = {}; var span = _callableNode.span; withMap.forEach((variable, value) { var name = @@ -531,11 +531,9 @@ class _EvaluateVisitor {Uri baseUrl, Map configuration, bool namesInErrors = false}) { - configuration ??= const {}; - var builtInModule = _builtInModules[url]; if (builtInModule != null) { - if (configuration.isNotEmpty) { + if (configuration != null && configuration.isNotEmpty) { throw _exception( namesInErrors ? "Built-in module $url can't be configured." @@ -595,12 +593,11 @@ class _EvaluateVisitor Module _execute(Importer importer, Stylesheet stylesheet, {Map configuration, bool namesInErrors = false}) { - configuration ??= const {}; var url = stylesheet.span.sourceUrl; var alreadyLoaded = _modules[url]; if (alreadyLoaded != null) { - if (configuration.isNotEmpty || _configuration.isNotEmpty) { + if ((configuration ?? _configuration).isNotEmpty) { throw _exception(namesInErrors ? "${p.prettyUri(url)} was already loaded, so it can't be " "configured using \"with\"." @@ -643,7 +640,10 @@ class _EvaluateVisitor _atRootExcludingStyleRule = false; _inKeyframes = false; - if (configuration.isNotEmpty) _configuration = Map.of(configuration); + if (configuration != null) { + _configuration = + configuration.isEmpty ? const {} : Map.of(configuration); + } visitStylesheet(stylesheet); css = _outOfOrderImports == null @@ -664,7 +664,7 @@ class _EvaluateVisitor _atRootExcludingStyleRule = oldAtRootExcludingStyleRule; _inKeyframes = oldInKeyframes; - if (configuration.isNotEmpty && _configuration.isNotEmpty) { + if (configuration != null && _configuration.isNotEmpty) { throw _exception( namesInErrors ? "\$${_configuration.keys.first} was not declared with " @@ -1774,7 +1774,7 @@ class _EvaluateVisitor _environment.addModule(module, namespace: node.namespace); }, configuration: node.configuration.isEmpty - ? null + ? const {} : { for (var entry in node.configuration.entries) entry.key: _ConfiguredValue(