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.
Background
When migrating a v1 addon to v2, whether absolute or relative paths are used doesn't affect the build and is a question of code style.
In addition to preserving the end-developer's code better, removing
useRelativePaths
has another benefit. The current implementation, which relies on a regular expression, is hard to maintain and can result in false positives (a bug). These problems were observed in:Bug report from
ember-container-query
Bug fix for
useRelativePaths
Feedback from @phndiaye
While replacing old imports (with the package’s name as root) with relative imports, the codemod accidentally replaced dynamically built asset paths in some components with relative imports, breaking some images paths. A quick double check might be needed here
For the translations, although there is a default directory, it can be configured to have a custom directory so it would be some extra work for the codemod to read the ember-intl configuration and match it.
For the false positive in the relative paths, I got something like this in component:
which was then used in the template like
<img src={{asset-map this.illustration}} />
. [T]he @upfluence/hyperstream in the basePath was rewritten to../../../assets/images
.Feedback from @josephdsumner
I think I would echo the feedback that came up in the blog post / thread in community chat -- the relative paths being perhaps optional, how things like
less
/postcss
might get updated.The underlying issue is, a regular expression doesn't understand files to be able to distinguish false positives from true ones. A more powerful library would be needed to parse CSS / JS / TS / ... files, but bringing in such a library won't provide much value (again, when we consider relative paths as a stylistic choice).
What changed?
For simplicity, I removed the
useRelativePaths
step and the associated test files. The removal has a few benefits: