Skip to content

Commit

Permalink
Fix deprecation ID displays in JS mode (#2483)
Browse files Browse the repository at this point in the history
In the pure JS release, these weren't working because the Dart-to-JS
logger didn't know to pass along the deprecation metadata when falling
back to the wrapped StderrLogger. In the embedded release, these
weren't working because we didn't give it an update to match the
stderr logger.
  • Loading branch information
nex3 authored Jan 14, 2025
1 parent b12b508 commit ddb14b2
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.83.2

* Properly display deprecation IDs for the JS Sass API.

* Don't display deprecation IDs for user-defined deprecations.

## 1.83.1

* Fix a bug where `--quiet-deps` would get deactivated for `@content` blocks,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/embedded/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ final class EmbeddedLogger extends LoggerWithDeprecationType {
{FileSpan? span, Trace? trace, Deprecation? deprecation}) {
var formatted = withGlyphs(() {
var buffer = StringBuffer();
var showDeprecation =
deprecation != null && deprecation != Deprecation.userAuthored;
if (_color) {
buffer.write('\u001b[33m\u001b[1m');
if (deprecation != null) buffer.write('Deprecation ');
buffer.write('Warning\u001b[0m');
if (showDeprecation) buffer.write(' [\u001b[34m$deprecation\u001b[0m]');
} else {
if (deprecation != null) buffer.write('DEPRECATION ');
buffer.write('WARNING');
if (showDeprecation) buffer.write(' [$deprecation]');
}
if (span == null) {
buffer.writeln(': $message');
Expand Down
10 changes: 8 additions & 2 deletions lib/src/logger/js_to_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ final class JSToDartLogger extends LoggerWithDeprecationType {
deprecationType: deprecations[deprecation?.id]));
} else {
_withAscii(() {
_fallback.warn(message,
span: span, trace: trace, deprecation: deprecation != null);
switch (_fallback) {
case LoggerWithDeprecationType():
_fallback.internalWarn(message,
span: span, trace: trace, deprecation: deprecation);
case _:
_fallback.warn(message,
span: span, trace: trace, deprecation: deprecation != null);
}
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/logger/stderr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ final class StderrLogger extends LoggerWithDeprecationType {
void internalWarn(String message,
{FileSpan? span, Trace? trace, Deprecation? deprecation}) {
var result = StringBuffer();
var showDeprecation =
deprecation != null && deprecation != Deprecation.userAuthored;
if (color) {
// Bold yellow.
result.write('\u001b[33m\u001b[1m');
if (deprecation != null) result.write('Deprecation ');
result.write('Warning\u001b[0m');
if (deprecation != null) {
result.write(' [\u001b[34m$deprecation\u001b[0m]');
}
if (showDeprecation) result.write(' [\u001b[34m$deprecation\u001b[0m]');
} else {
if (deprecation != null) result.write('DEPRECATION ');
result.write('WARNING');
if (deprecation != null) result.write(' [$deprecation]');
if (showDeprecation) result.write(' [$deprecation]');
}

if (span == null) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.10

* No user-visible changes.

## 0.4.9

* Add support for parsing the `@include` rule.
Expand Down
2 changes: 1 addition & 1 deletion pkg/sass-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sass-parser",
"version": "0.4.9",
"version": "0.4.10",
"description": "A PostCSS-compatible wrapper of the official Sass parser",
"repository": "sass/sass",
"author": "Google Inc.",
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 15.0.2

* No user-visible changes.

## 15.0.1

* No user-visible changes.
Expand Down
4 changes: 2 additions & 2 deletions pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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: 15.0.1
version: 15.0.2
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: ">=3.3.0 <4.0.0"

dependencies:
sass: 1.83.1
sass: 1.83.2

dev_dependencies:
dartdoc: ^8.0.14
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.83.1
version: 1.83.2
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit ddb14b2

Please sign in to comment.