Skip to content

Commit d740d02

Browse files
authoredSep 17, 2024··
Emit deprecation warnings for the legacy JS API (#2343)
1 parent a957eea commit d740d02

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed
 

‎CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@
170170

171171
### JS API
172172

173+
* While the legacy API has been deprecated since we released the modern API, we
174+
now emit warnings when the legacy API is used to make sure users are aware
175+
that it will be removed in Dart Sass 2.0.0. In the meantime, you can silence
176+
these warnings by passing `legacy-js-api` in `silenceDeprecations` when using
177+
the legacy API.
178+
173179
* Modify `SassColor` to accept a new `space` option, with support for all the
174180
new color spaces defined in Color Level 4.
175181

‎lib/src/async_compile.dart

+6
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ Future<CompileResult> _compileStylesheet(
159159
bool quietDeps,
160160
bool sourceMap,
161161
bool charset) async {
162+
if (nodeImporter != null) {
163+
logger?.warnForDeprecation(
164+
Deprecation.legacyJsApi,
165+
'The legacy JS API is deprecated and will be removed in '
166+
'Dart Sass 2.0.0.');
167+
}
162168
var evaluateResult = await evaluateAsync(stylesheet,
163169
importCache: importCache,
164170
nodeImporter: nodeImporter,

‎lib/src/compile.dart

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// DO NOT EDIT. This file was generated from async_compile.dart.
66
// See tool/grind/synchronize.dart for details.
77
//
8-
// Checksum: 4d72aeb3c39a2e607d1889755e07b7e489eddfa6
8+
// Checksum: 4141eec2214ef480b6fdf07e5090202cdea3eb89
99
//
1010
// ignore_for_file: unused_import
1111

@@ -168,6 +168,12 @@ CompileResult _compileStylesheet(
168168
bool quietDeps,
169169
bool sourceMap,
170170
bool charset) {
171+
if (nodeImporter != null) {
172+
logger?.warnForDeprecation(
173+
Deprecation.legacyJsApi,
174+
'The legacy JS API is deprecated and will be removed in '
175+
'Dart Sass 2.0.0.');
176+
}
171177
var evaluateResult = evaluate(stylesheet,
172178
importCache: importCache,
173179
nodeImporter: nodeImporter,

‎lib/src/deprecation.dart

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ enum Deprecation {
1515
// DO NOT EDIT. This section was generated from the language repo.
1616
// See tool/grind/generate_deprecations.dart for details.
1717
//
18-
// Checksum: 5470e7252641d3eaa7093b072b52e423c3b77375
18+
// Checksum: 0243e0f7ee85127d6e1bda5c08e363509959e758
1919

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

112+
/// Deprecation for legacy JS API.
113+
legacyJsApi('legacy-js-api',
114+
deprecatedIn: '1.79.0', description: 'Legacy JS API.'),
115+
112116
/// Deprecation for @import rules.
113117
import.future('import', description: '@import rules.'),
114118

0 commit comments

Comments
 (0)
Please sign in to comment.