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

Emit deprecation warnings for the legacy JS API #2343

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@

### JS API

* While the legacy API has been deprecated since we released the modern API, we
now emit warnings when the legacy API is used to make sure users are aware
that it will be removed in Dart Sass 2.0.0. In the meantime, you can silence
these warnings by passing `legacy-js-api` in `silenceDeprecations` when using
the legacy API.

* Modify `SassColor` to accept a new `space` option, with support for all the
new color spaces defined in Color Level 4.

Expand Down
6 changes: 6 additions & 0 deletions lib/src/async_compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ Future<CompileResult> _compileStylesheet(
bool quietDeps,
bool sourceMap,
bool charset) async {
if (nodeImporter != null) {
logger?.warnForDeprecation(
Deprecation.legacyJsApi,
'The legacy JS API is deprecated and will be removed in '
'Dart Sass 2.0.0.');
}
var evaluateResult = await evaluateAsync(stylesheet,
importCache: importCache,
nodeImporter: nodeImporter,
Expand Down
8 changes: 7 additions & 1 deletion lib/src/compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_compile.dart.
// See tool/grind/synchronize.dart for details.
//
// Checksum: 4d72aeb3c39a2e607d1889755e07b7e489eddfa6
// Checksum: 4141eec2214ef480b6fdf07e5090202cdea3eb89
//
// ignore_for_file: unused_import

Expand Down Expand Up @@ -168,6 +168,12 @@ CompileResult _compileStylesheet(
bool quietDeps,
bool sourceMap,
bool charset) {
if (nodeImporter != null) {
logger?.warnForDeprecation(
Deprecation.legacyJsApi,
'The legacy JS API is deprecated and will be removed in '
'Dart Sass 2.0.0.');
}
var evaluateResult = evaluate(stylesheet,
importCache: importCache,
nodeImporter: nodeImporter,
Expand Down
6 changes: 5 additions & 1 deletion lib/src/deprecation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum Deprecation {
// DO NOT EDIT. This section was generated from the language repo.
// See tool/grind/generate_deprecations.dart for details.
//
// Checksum: 5470e7252641d3eaa7093b072b52e423c3b77375
// Checksum: 0243e0f7ee85127d6e1bda5c08e363509959e758

/// Deprecation for passing a string directly to meta.call().
callString('call-string',
Expand Down Expand Up @@ -109,6 +109,10 @@ enum Deprecation {
deprecatedIn: '1.79.0',
description: 'Using global color functions instead of sass:color.'),

/// Deprecation for legacy JS API.
legacyJsApi('legacy-js-api',
deprecatedIn: '1.79.0', description: 'Legacy JS API.'),

/// Deprecation for @import rules.
import.future('import', description: '@import rules.'),

Expand Down