diff --git a/CHANGELOG.md b/CHANGELOG.md index 238ae93..4af7566 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/src/migrators/module.dart b/lib/src/migrators/module.dart index 8fa9c74..b038a02 100644 --- a/lib/src/migrators/module.dart +++ b/lib/src/migrators/module.dart @@ -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; diff --git a/pubspec.yaml b/pubspec.yaml index 5a633ef..1332c2c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 homepage: https://github.com/sass/migrator diff --git a/test/migrators/module/partial_migration/changed_path/load_paths.hrx b/test/migrators/module/partial_migration/changed_path/load_paths.hrx new file mode 100644 index 0000000..d2259b0 --- /dev/null +++ b/test/migrators/module/partial_migration/changed_path/load_paths.hrx @@ -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; +}