diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdb81411d..626849f49 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,6 +140,11 @@ jobs: dart_channel: [stable] node_version: [18] include: + # Temporarily adding back Node 12 here until we actually drop support + # in the package.json. + - os: ubuntu-latest + dart_channel: stable + node_version: 12 # Include LTS versions on Ubuntu - os: ubuntu-latest dart_channel: stable @@ -150,7 +155,6 @@ jobs: - os: ubuntu-latest dart_channel: dev node_version: 18 - steps: - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index ebc7ec3f8..4618111fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 1.59.3 + +* Fix a performance regression introduced in 1.59.0. + +* The NPM release of 1.59.0 dropped support for Node 12 without actually + indicating so in its pubspec. This release temporarily adds back support so + that the latest Sass version that declares it supports Node 12 actually does + so. However, Node 12 is now end-of-life, so we will drop support for it + properly in an upcoming release. + ## 1.59.2 * No user-visible changes. diff --git a/lib/src/parse/parser.dart b/lib/src/parse/parser.dart index c2c27f56c..044285331 100644 --- a/lib/src/parse/parser.dart +++ b/lib/src/parse/parser.dart @@ -11,6 +11,7 @@ import '../exception.dart'; import '../interpolation_map.dart'; import '../logger.dart'; import '../util/character.dart'; +import '../util/lazy_file_span.dart'; import '../utils.dart'; /// The abstract base class for all parsers. @@ -675,7 +676,10 @@ class Parser { @protected FileSpan spanFrom(LineScannerState state) { var span = scanner.spanFrom(state); - return _interpolationMap?.mapSpan(span) ?? span; + if (_interpolationMap != null) { + return LazyFileSpan(() => _interpolationMap!.mapSpan(span)); + } + return span; } /// Prints a warning to standard error, associated with [span]. diff --git a/lib/src/util/lazy_file_span.dart b/lib/src/util/lazy_file_span.dart new file mode 100644 index 000000000..628221cfb --- /dev/null +++ b/lib/src/util/lazy_file_span.dart @@ -0,0 +1,58 @@ +// Copyright 2023 Google LLC. 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 'package:source_span/source_span.dart'; + +/// A wrapper for [FileSpan] that allows an expensive creation process to be +/// deferred until the span is actually needed. +class LazyFileSpan implements FileSpan { + /// The function that creates the underlying span. + final FileSpan Function() _builder; + + /// The underlying span this wraps, which is created the first time this + /// getter is referenced. + FileSpan get span => _span ??= _builder(); + FileSpan? _span; + + /// Creates a new [LazyFileSpan] that defers calling [builder] until the + /// underlying span is needed. + LazyFileSpan(FileSpan Function() builder) : _builder = builder; + + @override + int compareTo(SourceSpan other) => span.compareTo(other); + + @override + String get context => span.context; + + @override + FileLocation get end => span.end; + + @override + FileSpan expand(FileSpan other) => span.expand(other); + + @override + SourceFile get file => span.file; + + @override + String highlight({color}) => span.highlight(color: color); + + @override + int get length => span.length; + + @override + String message(String message, {color}) => + span.message(message, color: color); + + @override + Uri? get sourceUrl => span.sourceUrl; + + @override + FileLocation get start => span.start; + + @override + String get text => span.text; + + @override + SourceSpan union(SourceSpan other) => span.union(other); +} diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index d9a0f072a..13b07b4d4 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.0.3 + +* No user-visible changes. + ## 6.0.2 * No user-visible changes. diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index 6800bf69c..9d24dafc6 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ name: sass_api # Note: Every time we add a new Sass AST node, we need to bump the *major* # version because it's a breaking change for anyone who's implementing the # visitor interface(s). -version: 6.0.2 +version: 6.0.3 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: ">=2.17.0 <3.0.0" dependencies: - sass: 1.59.2 + sass: 1.59.3 dev_dependencies: dartdoc: ^5.0.0 diff --git a/pubspec.yaml b/pubspec.yaml index 521a8d84d..dd69c476e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.59.2 +version: 1.59.3 description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass @@ -35,7 +35,7 @@ dependencies: dev_dependencies: analyzer: ^4.7.0 archive: ^3.1.2 - cli_pkg: ^2.1.4 + cli_pkg: ^2.4.2 crypto: ^3.0.0 dart_style: ^2.0.0 dartdoc: ^6.0.0