|
/// Returns the URL to use in the source map to refer to [canonicalUrl]. |
|
/// |
|
/// Returns [canonicalUrl] as-is if it hasn't been loaded by this cache. |
|
Uri sourceMapUrl(Uri canonicalUrl) => |
|
_resultsCache[canonicalUrl]?.sourceMapUrl ?? canonicalUrl; |
In ImportCache, the sourceMapUrl always fallback to canonicalUrl for null.
|
/// An absolute, browser-accessible URL indicating the resolved location of |
|
/// the imported stylesheet. |
|
/// |
|
/// This should be a `file:` URL if one is available, but an `http:` URL is |
|
/// acceptable as well. If no URL is supplied, a `data:` URL is generated |
|
/// automatically from [contents]. |
|
Uri get sourceMapUrl => |
|
_sourceMapUrl ?? Uri.dataFromString(contents, encoding: utf8); |
|
final Uri? _sourceMapUrl; |
However, in ImporterResult it already fallbacks to a data url for null, so in the ImportCache it will never actually fallback to the canonicalUrl.
This causes undesired bloats with sourceMapIncludeSources: true, where the source contents are included and the sourceMapUrl are encoded version of the exact same source contents. On the other hand, with sourceMapIncludeSources: false, the source map can still contain the source contents via data uri, despite being explicitly told to not expose contents.
The comments around the original code makes be believe the intention was to provide source map for source map url that's not file: protocol. However, modern browser can handle non-file: url in source map just fine, especially when source contents are present.
dart-sass/lib/src/async_import_cache.dart
Lines 371 to 375 in 62ec662
In
ImportCache, thesourceMapUrlalways fallback tocanonicalUrlfornull.dart-sass/lib/src/importer/result.dart
Lines 20 to 28 in 62ec662
However, in
ImporterResultit already fallbacks to a data url fornull, so in theImportCacheit will never actually fallback to thecanonicalUrl.This causes undesired bloats with
sourceMapIncludeSources: true, where the source contents are included and thesourceMapUrlare encoded version of the exact same source contents. On the other hand, withsourceMapIncludeSources: false, the source map can still contain the source contents via data uri, despite being explicitly told to not expose contents.The comments around the original code makes be believe the intention was to provide source map for source map url that's not
file:protocol. However, modern browser can handle non-file:url in source map just fine, especially when source contents are present.