Nested maps from imports #86
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since the parser does not have options for the included paths (paths to imported files), the imported variables are not compiled when
converter.getStructured()invokesparser.parseStructured().This is not an issue for imports that are top level variables. This is because the variable will be computed when invoking
converter.renderPropertyValue()later on in theconverter.compileStructure()method. However, an issue occurs for nested variables that are referenced from an external file. This is because the nested variable inside the map will not have knowledge about the contents of the imported map since the Parser does not have knowledge of theincludedPaths.Steps to reproduce:
_test-map.scsswith the following contentstest-import.scsswith the following contentstest-import.scssfile and see that it fails to parse the imported map variablecompiledValue, it does not flesh out themapValueof the full nested mapThis solves the issue by parsing the compiled value of a map property before evaluating if it is a nested map and then evaluating the contents of the nested map.
One downside to this method is that there are some methods in the Parser that had to be made public. And it would potentially be more efficient to handle the import logic within the parser and correctly parse the full path all in one shot. But that would require more restructuring and require passing in the
includedPathsto the Parser.There are also some other bugs with parsing/compiling maps that are not handled by this PR. Such as copying a map directly to another variable.