Fix CSS import bug (#1633)

This commit is contained in:
Jennifer Thakar 2022-02-17 13:25:21 -08:00 committed by GitHub
parent 4181d0d4bf
commit c66ea3f9a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 20 deletions

View File

@ -1,5 +1,7 @@
## 1.49.8 ## 1.49.8
* Fixed a bug where some plain CSS imports would not be emitted.
### JS API ### JS API
* Fix a bug where inspecting the Sass module in the Node.js console crashed on * Fix a bug where inspecting the Sass module in the Node.js console crashed on

View File

@ -47,7 +47,8 @@ NodeCompileResult compile(String path, [CompileOptions? options]) {
ascii: ascii), ascii: ascii),
importers: options?.importers?.map(_parseImporter), importers: options?.importers?.map(_parseImporter),
functions: _parseFunctions(options?.functions).cast()); functions: _parseFunctions(options?.functions).cast());
return _convertResult(result, includeSourceContents: options?.sourceMapIncludeSources ?? false); return _convertResult(result,
includeSourceContents: options?.sourceMapIncludeSources ?? false);
} on SassException catch (error, stackTrace) { } on SassException catch (error, stackTrace) {
throwNodeException(error, color: color, ascii: ascii, trace: stackTrace); throwNodeException(error, color: color, ascii: ascii, trace: stackTrace);
} }
@ -76,7 +77,8 @@ NodeCompileResult compileString(String text, [CompileStringOptions? options]) {
importer: options?.importer.andThen(_parseImporter) ?? importer: options?.importer.andThen(_parseImporter) ??
(options?.url == null ? NoOpImporter() : null), (options?.url == null ? NoOpImporter() : null),
functions: _parseFunctions(options?.functions).cast()); functions: _parseFunctions(options?.functions).cast());
return _convertResult(result, includeSourceContents: options?.sourceMapIncludeSources ?? false); return _convertResult(result,
includeSourceContents: options?.sourceMapIncludeSources ?? false);
} on SassException catch (error, stackTrace) { } on SassException catch (error, stackTrace) {
throwNodeException(error, color: color, ascii: ascii, trace: stackTrace); throwNodeException(error, color: color, ascii: ascii, trace: stackTrace);
} }
@ -102,7 +104,8 @@ Promise compileAsync(String path, [CompileOptions? options]) {
importers: options?.importers importers: options?.importers
?.map((importer) => _parseAsyncImporter(importer)), ?.map((importer) => _parseAsyncImporter(importer)),
functions: _parseFunctions(options?.functions, asynch: true)); functions: _parseFunctions(options?.functions, asynch: true));
return _convertResult(result, includeSourceContents: options?.sourceMapIncludeSources ?? false); return _convertResult(result,
includeSourceContents: options?.sourceMapIncludeSources ?? false);
}()), color: color, ascii: ascii); }()), color: color, ascii: ascii);
} }
@ -131,13 +134,16 @@ Promise compileStringAsync(String text, [CompileStringOptions? options]) {
.andThen((importer) => _parseAsyncImporter(importer)) ?? .andThen((importer) => _parseAsyncImporter(importer)) ??
(options?.url == null ? NoOpImporter() : null), (options?.url == null ? NoOpImporter() : null),
functions: _parseFunctions(options?.functions, asynch: true)); functions: _parseFunctions(options?.functions, asynch: true));
return _convertResult(result, includeSourceContents: options?.sourceMapIncludeSources ?? false); return _convertResult(result,
includeSourceContents: options?.sourceMapIncludeSources ?? false);
}()), color: color, ascii: ascii); }()), color: color, ascii: ascii);
} }
/// Converts a Dart [CompileResult] into a JS API [NodeCompileResult]. /// Converts a Dart [CompileResult] into a JS API [NodeCompileResult].
NodeCompileResult _convertResult(CompileResult result, {required bool includeSourceContents}) { NodeCompileResult _convertResult(CompileResult result,
var sourceMap = result.sourceMap?.toJson(includeSourceContents: includeSourceContents); {required bool includeSourceContents}) {
var sourceMap =
result.sourceMap?.toJson(includeSourceContents: includeSourceContents);
if (sourceMap is Map<String, dynamic> && !sourceMap.containsKey('sources')) { if (sourceMap is Map<String, dynamic> && !sourceMap.containsKey('sources')) {
// Dart's source map library can omit the sources key, but JS's type // Dart's source map library can omit the sources key, but JS's type
// declaration doesn't allow that. // declaration doesn't allow that.

View File

@ -1526,10 +1526,12 @@ class _EvaluateVisitor
_importer = oldImporter; _importer = oldImporter;
_stylesheet = oldStylesheet; _stylesheet = oldStylesheet;
_root = oldRoot; if (loadsUserDefinedModules) {
_parent = oldParent; _root = oldRoot;
_endOfImports = oldEndOfImports; _parent = oldParent;
_outOfOrderImports = oldOutOfOrderImports; _endOfImports = oldEndOfImports;
_outOfOrderImports = oldOutOfOrderImports;
}
_configuration = oldConfiguration; _configuration = oldConfiguration;
_inDependency = oldInDependency; _inDependency = oldInDependency;
}); });
@ -1539,7 +1541,6 @@ class _EvaluateVisitor
// CSS from modules used by [stylesheet]. // CSS from modules used by [stylesheet].
var module = environment.toDummyModule(); var module = environment.toDummyModule();
_environment.importForwards(module); _environment.importForwards(module);
if (loadsUserDefinedModules) { if (loadsUserDefinedModules) {
if (module.transitivelyContainsCss) { if (module.transitivelyContainsCss) {
// If any transitively used module contains extensions, we need to // If any transitively used module contains extensions, we need to

View File

@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_evaluate.dart. // DO NOT EDIT. This file was generated from async_evaluate.dart.
// See tool/grind/synchronize.dart for details. // See tool/grind/synchronize.dart for details.
// //
// Checksum: c1d303225e5cac5e32dd32a4eed30a71a35b390c // Checksum: d0af88db460da6528bdfeef34eb85baac00f9435
// //
// ignore_for_file: unused_import // ignore_for_file: unused_import
@ -1526,10 +1526,12 @@ class _EvaluateVisitor
_importer = oldImporter; _importer = oldImporter;
_stylesheet = oldStylesheet; _stylesheet = oldStylesheet;
_root = oldRoot; if (loadsUserDefinedModules) {
_parent = oldParent; _root = oldRoot;
_endOfImports = oldEndOfImports; _parent = oldParent;
_outOfOrderImports = oldOutOfOrderImports; _endOfImports = oldEndOfImports;
_outOfOrderImports = oldOutOfOrderImports;
}
_configuration = oldConfiguration; _configuration = oldConfiguration;
_inDependency = oldInDependency; _inDependency = oldInDependency;
}); });
@ -1539,7 +1541,6 @@ class _EvaluateVisitor
// CSS from modules used by [stylesheet]. // CSS from modules used by [stylesheet].
var module = environment.toDummyModule(); var module = environment.toDummyModule();
_environment.importForwards(module); _environment.importForwards(module);
if (loadsUserDefinedModules) { if (loadsUserDefinedModules) {
if (module.transitivelyContainsCss) { if (module.transitivelyContainsCss) {
// If any transitively used module contains extensions, we need to // If any transitively used module contains extensions, we need to

View File

@ -1,3 +1,7 @@
## 1.0.0-beta.37
* No user-visible changes.
## 1.0.0-beta.36 ## 1.0.0-beta.36
* No user-visible changes. * No user-visible changes.

View File

@ -2,7 +2,7 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major* # Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the # version because it's a breaking change for anyone who's implementing the
# visitor interface(s). # visitor interface(s).
version: 1.0.0-beta.36 version: 1.0.0-beta.37
description: Additional APIs for Dart Sass. description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass homepage: https://github.com/sass/dart-sass
@ -10,7 +10,7 @@ environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'
dependencies: dependencies:
sass: 1.49.7 sass: 1.49.8
dependency_overrides: dependency_overrides:
sass: {path: ../..} sass: {path: ../..}

View File

@ -1,5 +1,5 @@
name: sass name: sass
version: 1.49.8-dev version: 1.49.8
description: A Sass implementation in Dart. description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass homepage: https://github.com/sass/dart-sass