Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove baseUrl requirement for tsconfig path aliases #12731

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

meyer
Copy link

@meyer meyer commented Dec 13, 2024

As of TypeScript 4.1, baseUrl is not required for tsconfig path aliases to work. baseUrl is required in Astro, however.

The TypeScript docs actively discourage people from setting baseUrl:

baseUrl was designed for use with AMD module loaders. If you aren’t using an AMD module loader, you probably shouldn’t use baseUrl. Since TypeScript 4.1, baseUrl is no longer required to use paths and should not be used just to set the directory paths values are resolved from.

In this PR I’ve removed the explicit baseUrl check and early return. Rather than bailing if baseUrl is not set, Astro now defaults to a baseUrl of '.'. This aligns with TypeScript’s path resolving functionality. You can read more in the TypeScript documentation page about module resolution: https://www.typescriptlang.org/docs/handbook/modules/reference.html#relationship-to-baseurl

Changes

  • baseUrl now defaults to '.' if baseUrl is not set in your tsconfig file

Testing

I copied the alias-tsconfig fixture over to a new fixture, alias-tsconfig-no-baseurl.

Docs

I removed usage of baseUrl from the README for vite-plugin-config-alias.

Copy link

changeset-bot bot commented Dec 13, 2024

🦋 Changeset detected

Latest commit: 18723ab

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Dec 13, 2024
@meyer meyer force-pushed the remove-baseurl-requirement branch from 8e264a7 to 7a198da Compare December 13, 2024 03:08
Copy link

codspeed-hq bot commented Dec 13, 2024

CodSpeed Performance Report

Merging #12731 will not alter performance

Comparing meyer:remove-baseurl-requirement (18723ab) with main (e3bfd93)

Summary

✅ 4 untouched benchmarks

@meyer meyer force-pushed the remove-baseurl-requirement branch from 7a198da to 18723ab Compare December 13, 2024 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant