Removed ~/assets alias and baseUrl from tsconfig presets. #7940
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.
Changes
Removed ~/assets alias and baseUrl from tsconfig presets.
Instead of predefining ~/assets and baseUrl in our tsconfig presets user should now define them in their own in their tsconfig.json, as predefined aliases were too opinionated and didn't work without modifying tsconfig anyways.
By opinionated i mean that it not only forces a specific location, but also a specific prefix, some users would want to use assets like
@assets/blah.png
, it just doesn't make much sense to define this in the preset.Original justification for defining src/assets as a stable directory was in withastro/roadmap#468 (reply in thread)
Justification for defining ~/assets as an alias was in withastro/roadmap#468 (reply in thread)
User has to add baseUrl into their tsconfig for this to work anyway, and this only adds alias for ~/assets and not ~/content or whatever, it just doesn't make much sense, src/assets isn't really any more special than src/content.
Fixes #7470 (you should also read discussion there)
Testing
No tests were added.
tsconfig.json was added at the base dir of all tests that use ~/assets alias, they weren't removed as it may be useful to test if aliases regular work there.
Do you think tests (relevant parts) should be removed instead?
Tested with
pnpm --filter astro run test
Docs
Builtin ~/assets alias in the astro assets example should be removed or modified in the docs.
In theory this change can affect users that don't use astro:assets, only if they had
baseUrl
set in their tsconfig, i doubt it matters./cc @withastro/maintainers-docs for feedback!