Skip to content

Commit aaa39df

Browse files
committed
Emit deprecation
1 parent 12da411 commit aaa39df

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

lib/src/compile.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,24 @@
55
import {initAsyncCompiler} from './compiler/async';
66
import {OptionsWithLegacy, StringOptionsWithLegacy} from './compiler/utils';
77
import {initCompiler} from './compiler/sync';
8-
import {CompileResult} from './vendor/sass';
8+
import {CompileResult, SourceMapIncludeSources} from './vendor/sass';
9+
import {
10+
DeprecationOptions,
11+
deprecations,
12+
warnForHostSideDeprecation,
13+
} from './deprecations';
914

1015
export {NodePackageImporter} from './importer-registry';
1116

1217
export function compile(
1318
path: string,
1419
options?: OptionsWithLegacy<'sync'>,
1520
): CompileResult {
21+
_warnForSourceMapIncludeSourcesBoolean(
22+
options?.sourceMapIncludeSources,
23+
options?.legacy,
24+
options,
25+
);
1626
const compiler = initCompiler();
1727
try {
1828
return compiler.compile(path, options);
@@ -25,6 +35,11 @@ export function compileString(
2535
source: string,
2636
options?: StringOptionsWithLegacy<'sync'>,
2737
): CompileResult {
38+
_warnForSourceMapIncludeSourcesBoolean(
39+
options?.sourceMapIncludeSources,
40+
options?.legacy,
41+
options,
42+
);
2843
const compiler = initCompiler();
2944
try {
3045
return compiler.compileString(source, options);
@@ -37,6 +52,11 @@ export async function compileAsync(
3752
path: string,
3853
options?: OptionsWithLegacy<'async'>,
3954
): Promise<CompileResult> {
55+
_warnForSourceMapIncludeSourcesBoolean(
56+
options?.sourceMapIncludeSources,
57+
options?.legacy,
58+
options,
59+
);
4060
const compiler = await initAsyncCompiler();
4161
try {
4262
return await compiler.compileAsync(path, options);
@@ -49,10 +69,36 @@ export async function compileStringAsync(
4969
source: string,
5070
options?: StringOptionsWithLegacy<'async'>,
5171
): Promise<CompileResult> {
72+
_warnForSourceMapIncludeSourcesBoolean(
73+
options?.sourceMapIncludeSources,
74+
options?.legacy,
75+
options,
76+
);
5277
const compiler = await initAsyncCompiler();
5378
try {
5479
return await compiler.compileStringAsync(source, options);
5580
} finally {
5681
await compiler.dispose();
5782
}
5883
}
84+
85+
function _warnForSourceMapIncludeSourcesBoolean(
86+
sourceMapIncludeSources?: SourceMapIncludeSources | boolean,
87+
legacy?: boolean,
88+
options?: DeprecationOptions,
89+
): void {
90+
if (
91+
legacy !== true &&
92+
(sourceMapIncludeSources === true || sourceMapIncludeSources === false)
93+
) {
94+
const suggestion = sourceMapIncludeSources ? 'always' : 'never';
95+
warnForHostSideDeprecation(
96+
'Passing a boolean value for Options.sourceMapIncludeSources is' +
97+
'deprecated and will be removed in Dart Sass 2.0.0.\n' +
98+
`Please use '${suggestion}' instead of ${sourceMapIncludeSources}.\n\n` +
99+
'More info: https://sass-lang.com/d/source-map-include-sources-boolean',
100+
deprecations['source-map-include-sources-boolean'],
101+
options,
102+
);
103+
}
104+
}

0 commit comments

Comments
 (0)