diff --git a/CHANGELOG.md b/CHANGELOG.md index 460c76d80..0401866f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ * Fix importing files relative to `package:`-imported files. +* Don't claim that "package:" URLs aren't supported when they actually are. + ### Dart API * Explicitly require that importers' `canonicalize()` methods be able to take diff --git a/lib/src/visitor/async_evaluate.dart b/lib/src/visitor/async_evaluate.dart index cebb42db8..74f0839d4 100644 --- a/lib/src/visitor/async_evaluate.dart +++ b/lib/src/visitor/async_evaluate.dart @@ -27,6 +27,7 @@ import '../extend/extender.dart'; import '../importer.dart'; import '../importer/node.dart'; import '../importer/utils.dart'; +import '../io.dart'; import '../logger.dart'; import '../parse/keyframe_selector.dart'; import '../syntax.dart'; @@ -851,7 +852,7 @@ class _EvaluateVisitor if (tuple != null) return tuple; } - if (url.startsWith('package:')) { + if (url.startsWith('package:') && isNode) { // Special-case this error message, since it's tripped people up in the // past. throw "\"package:\" URLs aren't supported on this platform."; diff --git a/lib/src/visitor/evaluate.dart b/lib/src/visitor/evaluate.dart index 5c327cb2d..5ca9b4a98 100644 --- a/lib/src/visitor/evaluate.dart +++ b/lib/src/visitor/evaluate.dart @@ -5,7 +5,7 @@ // DO NOT EDIT. This file was generated from async_evaluate.dart. // See tool/synchronize.dart for details. // -// Checksum: be2d44a3dc50defd98446d806b4c21bfe54a4ba9 +// Checksum: e7642c8d4c838f0afe94b882794e81b0937ba1a1 // // ignore_for_file: unused_import @@ -36,6 +36,7 @@ import '../extend/extender.dart'; import '../importer.dart'; import '../importer/node.dart'; import '../importer/utils.dart'; +import '../io.dart'; import '../logger.dart'; import '../parse/keyframe_selector.dart'; import '../syntax.dart'; @@ -851,7 +852,7 @@ class _EvaluateVisitor if (tuple != null) return tuple; } - if (url.startsWith('package:')) { + if (url.startsWith('package:') && isNode) { // Special-case this error message, since it's tripped people up in the // past. throw "\"package:\" URLs aren't supported on this platform."; diff --git a/test/cli/dart/errors_test.dart b/test/cli/dart/errors_test.dart index db672602e..478d2129f 100644 --- a/test/cli/dart/errors_test.dart +++ b/test/cli/dart/errors_test.dart @@ -5,6 +5,7 @@ @TestOn('vm') import 'package:test/test.dart'; +import 'package:test_descriptor/test_descriptor.dart' as d; import '../dart_test.dart'; import '../shared/errors.dart'; @@ -12,4 +13,21 @@ import '../shared/errors.dart'; void main() { setUpAll(ensureSnapshotUpToDate); sharedTests(runSass); + + test("for package urls", () async { + await d.file("test.scss", "@import 'package:nope/test';").create(); + + var sass = await runSass(["--no-unicode", "test.scss"]); + expect( + sass.stderr, + emitsInOrder([ + "Error: Can't find stylesheet to import.", + " ,", + "1 | @import 'package:nope/test';", + " | ^^^^^^^^^^^^^^^^^^^", + " '", + " test.scss 1:9 root stylesheet" + ])); + await sass.shouldExit(65); + }); } diff --git a/test/cli/node/errors_test.dart b/test/cli/node/errors_test.dart index fda63b705..87220b350 100644 --- a/test/cli/node/errors_test.dart +++ b/test/cli/node/errors_test.dart @@ -6,6 +6,7 @@ @Tags(['node']) import 'package:test/test.dart'; +import 'package:test_descriptor/test_descriptor.dart' as d; import '../../ensure_npm_package.dart'; import '../node_test.dart'; @@ -14,4 +15,21 @@ import '../shared/errors.dart'; void main() { setUpAll(ensureNpmPackage); sharedTests(runSass); + + test("for package urls", () async { + await d.file("test.scss", "@import 'package:nope/test';").create(); + + var sass = await runSass(["--no-unicode", "test.scss"]); + expect( + sass.stderr, + emitsInOrder([ + "Error: \"package:\" URLs aren't supported on this platform.", + " ,", + "1 | @import 'package:nope/test';", + " | ^^^^^^^^^^^^^^^^^^^", + " '", + " test.scss 1:9 root stylesheet" + ])); + await sass.shouldExit(65); + }); } diff --git a/test/cli/shared/errors.dart b/test/cli/shared/errors.dart index 051bb6701..2d75e9ec8 100644 --- a/test/cli/shared/errors.dart +++ b/test/cli/shared/errors.dart @@ -113,21 +113,4 @@ void sharedTests(Future runSass(Iterable arguments)) { expect(sass.stderr, emitsThrough(contains("\.dart"))); await sass.shouldExit(65); }); - - test("for package urls", () async { - await d.file("test.scss", "@import 'package:nope/test';").create(); - - var sass = await runSass(["--no-unicode", "test.scss"]); - expect( - sass.stderr, - emitsInOrder([ - "Error: \"package:\" URLs aren't supported on this platform.", - " ,", - "1 | @import 'package:nope/test';", - " | ^^^^^^^^^^^^^^^^^^^", - " '", - " test.scss 1:9 root stylesheet" - ])); - await sass.shouldExit(65); - }); }