Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport deprecation API to legacy JS API #2293

Merged
merged 8 commits into from
Sep 3, 2024
Merged

Conversation

jathak
Copy link
Member

@jathak jathak commented Jul 29, 2024

See sass/sass#3907.
See sass/sass-spec#2006.

This also fixes a bug where the deprecation flags would not always be respected when using embedded Sass, as ImportCaches could be created with an unwrapped logger, meaning any parse-time deprecation warnings (e.g. @import) couldn't be controlled. ImportCache now wraps the logger it gets in a DeprecationProcessingLogger to fix this.

[skip sass-embedded]

bin/sass.dart Outdated
logger: options.logger,
silenceDeprecations: options.silenceDeprecations,
fatalDeprecations: options.fatalDeprecations,
futureDeprecations: options.futureDeprecations,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: no trailing comma

@@ -6,6 +6,7 @@ import 'package:cli_pkg/js.dart';
import 'package:collection/collection.dart';
import 'package:pub_semver/pub_semver.dart';

import 'logger.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Comment on lines 99 to 102
Logger? logger,
Set<Deprecation>? fatalDeprecations,
Set<Deprecation>? futureDeprecations,
Set<Deprecation>? silenceDeprecations})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like this change. It's not actually providing any better guarantees—the caller still has to remember to explicitly handle the deprecation options for a new ImportCache—and it's reducing the separation of concerns between the way a Logger is configured and the way an ImportCache is configured. I'd rather just wrap the logger explicitly in the places it needs to be wrapped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the wrapping for import cache into a static method so that it's now always wrapped explicitly, but we don't have to repeat the boilerplate (including the comment about not limiting repetition) in each place we wrap a logger this way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these constructor parameters be removed, then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, whoops. I think I accidentally removed them from ImportCache instead of AsyncImportCache and then that got undone by synchronizing.

this.limitRepetition = true});

/// Warns if any of the deprecations options are incompatible or unnecessary.
void validate() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why split this out into a separate method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only want to emit warnings for invalid/unnecessary deprecation flags once and we're now wrapping loggers more than once in many cases, so the warning part is separated out from the constructor and only called on the main wrapped logger.

@jathak jathak requested a review from nex3 August 22, 2024 20:52
@jathak jathak merged commit b1d5f98 into main Sep 3, 2024
29 checks passed
@jathak jathak deleted the deprecation-backport branch September 3, 2024 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants