Add support for absolute path to babel plugin #229
Merged
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.
When using Snowpack with a custom output directory like:
snowpack --dest public/web_modules
, the babel plugin can't use a path that looks likepublic/web_modules/import-map.json
(like in this example) because you end up with./web_modules/public/web_modules/import-map.json
.This is because
dir
is automatically added to the path to require the import map in the plugin, even though the path to the import map isn't related to the web server web_modules path location at all (as far as I can tell).This PR adds a backwards-compatible solution that lets people use an absolute path instead of a relative path. I think the better solution is to not use
dir
at all to construct the import path, but to remove that would be a breaking change so I opted for this solution, which is enough for my needs.If this is useful and a good approach for y'all I can add test fixtures to the PR as well.