mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-22 22:02:00 +01:00
Implement the sourceMapIncludeSources JS option (#1583)
This commit is contained in:
parent
e1fcbaaf36
commit
f055db0797
@ -2,6 +2,10 @@
|
||||
|
||||
* Fix a bug in `string.insert` with certain negative indices.
|
||||
|
||||
### JS API
|
||||
|
||||
* Add support for the `sourceMapIncludeSources` option in the new JS API.
|
||||
|
||||
## 1.48.0
|
||||
|
||||
### JS API
|
||||
|
@ -47,7 +47,7 @@ NodeCompileResult compile(String path, [CompileOptions? options]) {
|
||||
ascii: ascii),
|
||||
importers: options?.importers?.map(_parseImporter),
|
||||
functions: _parseFunctions(options?.functions).cast());
|
||||
return _convertResult(result);
|
||||
return _convertResult(result, includeSourceContents: options?.sourceMapIncludeSources ?? false);
|
||||
} on SassException catch (error, stackTrace) {
|
||||
throwNodeException(error, color: color, ascii: ascii, trace: stackTrace);
|
||||
}
|
||||
@ -76,7 +76,7 @@ NodeCompileResult compileString(String text, [CompileStringOptions? options]) {
|
||||
importer: options?.importer.andThen(_parseImporter) ??
|
||||
(options?.url == null ? NoOpImporter() : null),
|
||||
functions: _parseFunctions(options?.functions).cast());
|
||||
return _convertResult(result);
|
||||
return _convertResult(result, includeSourceContents: options?.sourceMapIncludeSources ?? false);
|
||||
} on SassException catch (error, stackTrace) {
|
||||
throwNodeException(error, color: color, ascii: ascii, trace: stackTrace);
|
||||
}
|
||||
@ -102,7 +102,7 @@ Promise compileAsync(String path, [CompileOptions? options]) {
|
||||
importers: options?.importers
|
||||
?.map((importer) => _parseAsyncImporter(importer)),
|
||||
functions: _parseFunctions(options?.functions, asynch: true));
|
||||
return _convertResult(result);
|
||||
return _convertResult(result, includeSourceContents: options?.sourceMapIncludeSources ?? false);
|
||||
}()), color: color, ascii: ascii);
|
||||
}
|
||||
|
||||
@ -131,13 +131,13 @@ Promise compileStringAsync(String text, [CompileStringOptions? options]) {
|
||||
.andThen((importer) => _parseAsyncImporter(importer)) ??
|
||||
(options?.url == null ? NoOpImporter() : null),
|
||||
functions: _parseFunctions(options?.functions, asynch: true));
|
||||
return _convertResult(result);
|
||||
return _convertResult(result, includeSourceContents: options?.sourceMapIncludeSources ?? false);
|
||||
}()), color: color, ascii: ascii);
|
||||
}
|
||||
|
||||
/// Converts a Dart [CompileResult] into a JS API [NodeCompileResult].
|
||||
NodeCompileResult _convertResult(CompileResult result) {
|
||||
var sourceMap = result.sourceMap?.toJson();
|
||||
NodeCompileResult _convertResult(CompileResult result, {required bool includeSourceContents}) {
|
||||
var sourceMap = result.sourceMap?.toJson(includeSourceContents: includeSourceContents);
|
||||
if (sourceMap is Map<String, dynamic> && !sourceMap.containsKey('sources')) {
|
||||
// Dart's source map library can omit the sources key, but JS's type
|
||||
// declaration doesn't allow that.
|
||||
|
@ -18,6 +18,7 @@ class CompileOptions {
|
||||
external String? get style;
|
||||
external bool? get verbose;
|
||||
external bool? get sourceMap;
|
||||
external bool? get sourceMapIncludeSources;
|
||||
external NodeLogger? get logger;
|
||||
external List<Object?>? get importers;
|
||||
external Object? get functions;
|
||||
|
Loading…
x
Reference in New Issue
Block a user