Skip to content

Commit

Permalink
Fix one more orphan import-only bug (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
jathak authored Mar 30, 2021
1 parent 812acd6 commit e47ce5f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.3.7

### Module Migrator

* Fix a crash in a rare edge case involving orphan import-only files and
multiple load paths.

## 1.3.6

### Module Migrator
Expand Down
2 changes: 1 addition & 1 deletion lib/src/migrators/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ class _ModuleMigrationVisitor extends MigrationVisitor {
for (var import in dynamicImports) {
var ruleUrl = import.url;
var tuple = importCache.canonicalize(Uri.parse(ruleUrl),
baseImporter: importer, forImport: true);
baseImporter: importer, baseUrl: currentUrl, forImport: true);
var canonicalImport = tuple?.item2;
if (references.orphanImportOnlyFiles.containsKey(canonicalImport)) {
ruleUrl = null;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass_migrator
version: 1.3.6
version: 1.3.7
description: A tool for running migrations on Sass files
author: Jennifer Thakar <[email protected]>
homepage: https://github.com/sass/migrator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<==> arguments
--migrate-deps --load-path load-path --load-path .

<==> README.md
This test is for a combination of edge cases where an orphan import-only file
available through two load paths, one of which is the directory the migrator
is being run from.

This is a regression test for a bug where References and _ModuleMigrationVisitor
disagreed about which import-only file to use, resulting in a crash.

<==> input/entrypoint/in/a/subdirectory.scss
@import "old";

a {
color: $lib-variable;
}

<==> input/load-path/_old.import.scss
@forward "new" as lib-*;

<==> input/_new.scss
$variable: green;

<==> input/_old.import.scss
@forward "wrong";

<==> input/_wrong.scss
$lib-variable: blue;

<==> output/entrypoint/in/a/subdirectory.scss
@use "new";

a {
color: new.$variable;
}

0 comments on commit e47ce5f

Please sign in to comment.