Use Vite tsconfig path resolution by default#17202
Merged
Merged
Conversation
Fixes: #17163 Related: 3cf76c0, 4766f37 Goal: restore Astro 6-style tsconfig alias handling for CSS references that are written inside .astro <style> blocks and therefore go through Astro's direct preprocessCSS() path instead of Vite's normal transform pipeline. Issue #17163 reported that the earlier CSS alias repair still missed @import url("@/...") and Tailwind-style @reference declarations in component styles. The issue discussion later added @config. Testing resolve.tsconfigPaths showed it is not a replacement here: with Vite 8.1.0/Rolldown 1.1.2 it fails existing Astro alias tests on its own, and even when combined with Astro's custom alias plugin it does not fix the <style> preprocessCSS() path. Decision: keep Astro's existing config alias plugin, extract its CSS alias rewriting into resolveCssAliases(), and call that same helper from createStylePreprocessor before preprocessCSS(). This preserves the standalone .css transform behavior while covering the compiler preprocessing path that previously bypassed the transform hook. The helper now matches @import, @reference, and @config path-bearing at-rules, plus the existing quoted url() handling. It resolves only aliases that map to existing files, matching the previous best-effort behavior. Testing: added an alias-path-alias-style fixture page with @import url('@/styles/base.css'), @reference '@/styles/reference.css', and @config '@/tailwind.config.ts' inside a component <style>. The test asserts the imported CSS is bundled and no @/ alias remains in output CSS. Verification run: - pnpm -C packages/astro run build:ci - pnpm -C packages/astro exec tsc -b - pnpm -C packages/astro exec astro-scripts test "test/{alias-tsconfig,alias-tsconfig-no-baseurl,alias-path-alias-style,alias-css-url}.test.ts" - pnpm format
🦋 Changeset detectedLatest commit: e9f9343 The changes in this PR will be included in the next version bump. This PR includes changesets to release 393 packages
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 |
Related: bdeee80 Enable Vite's resolve.tsconfigPaths by default so Astro uses the native resolver where it works. Keep the existing custom config alias plugin as a deprecated fallback because testing showed resolve.tsconfigPaths alone does not pass Astro's existing alias suite with the current Vite/Rolldown stack. The fallback comments now explicitly document supported cases: - standalone CSS: @import, @reference, @config, and quoted url() references - Astro <style> preprocessing: the same supported CSS references before preprocessCSS() - module imports: JS/TS/Astro specifiers via resolveId The comments also state the fallback is deprecated and should be removed in a future Astro version once Vite covers these paths. Verification run: - pnpm format - pnpm -C packages/astro run build:ci - pnpm -C packages/astro exec tsc -b - pnpm -C packages/astro exec astro-scripts test "test/{alias-tsconfig,alias-tsconfig-no-baseurl,alias-path-alias-style,alias-css-url}.test.ts"
Remove the new #17163 regression fixture and the style-preprocessor alias rewrite. The PR is intentionally minimal now: enable Vite's resolve.tsconfigPaths and keep Astro's existing custom alias plugin only as a deprecated fallback for the cases it already supports. The fallback comments now document the supported CSS cases explicitly without claiming broader @reference/@config support. Verification run: - pnpm format - pnpm -C packages/astro run build:ci - pnpm -C packages/astro exec tsc -b - pnpm -C packages/astro exec astro-scripts test "test/{alias-tsconfig,alias-tsconfig-no-baseurl,alias-path-alias-style,alias-css-url}.test.ts"
Use an @deprecated JSDoc tag on the custom tsconfig alias fallback and make the supported syntax explicit. The comments now state that the fallback only covers the already-supported CSS syntax (@import string, @import url(), and quoted url()) plus JS/TS/Astro module specifiers. They also explicitly tell future maintainers and agents not to expand this plugin for @use, @forward, @reference, @config, unquoted url(), or other file-reference syntax. Verification run: - pnpm format - pnpm -C packages/astro run build:ci - pnpm -C packages/astro exec tsc -b - pnpm -C packages/astro exec astro-scripts test "test/{alias-tsconfig,alias-tsconfig-no-baseurl,alias-path-alias-style,alias-css-url}.test.ts"
matthewp
marked this pull request as ready for review
June 26, 2026 14:26
ematipico
approved these changes
Jun 29, 2026
| 'astro': patch | ||
| --- | ||
|
|
||
| Uses Vite's native tsconfig path resolution by default, with Astro's existing alias support kept as a fallback for CSS references that Vite does not yet resolve |
Member
There was a problem hiding this comment.
It's not clear what we're fixing.
Comment on lines
+253
to
+256
| // Use Vite's native tsconfig path resolution first. Astro's custom | ||
| // configAliasVitePlugin above is a deprecated fallback for cases Vite does | ||
| // not currently support in Astro's pipeline, and will be removed in a | ||
| // future Astro version. |
Contributor
Author
There was a problem hiding this comment.
to explain why we are enabling the option for future readers. I'm simplifying the comment so it's a one-liner.
|
|
||
| /** | ||
| * Regex matching CSS @import statements with the specifier in capture group 1. | ||
| * https://regex101.com/?regex=%40import%5Cs%2B%28%3F%3Aurl%5C%28%5Cs*%29%3F%5B%27%22%5D%28%5B%5E%27%22%5D%2B%29%5B%27%22%5D%5Cs*%5C%29%3F&testString=&flags=g&flavor=pcre2&delimiter=%2F |
Merged
dadezzz
pushed a commit
to dadezzz/university_notes
that referenced
this pull request
Jul 7, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [@astrojs/markdown-remark](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/markdown/remark)) | [`7.2.0` → `7.2.1`](https://renovatebot.com/diffs/npm/@astrojs%2fmarkdown-remark/7.2.0/7.2.1) |  |  | | [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.0.4` → `7.0.6`](https://renovatebot.com/diffs/npm/astro/7.0.4/7.0.6) |  |  | --- ### Release Notes <details> <summary>withastro/astro (@​astrojs/markdown-remark)</summary> ### [`v7.2.1`](https://github.com/withastro/astro/blob/HEAD/packages/markdown/remark/CHANGELOG.md#721) [Compare Source](https://github.com/withastro/astro/compare/@astrojs/[email protected]...@astrojs/[email protected]) ##### Patch Changes - Updated dependencies \[[`eb6f97e`](withastro/astro@eb6f97e)]: - [@​astrojs/internal-helpers](https://github.com/astrojs/internal-helpers)@​0.10.1 </details> <details> <summary>withastro/astro (astro)</summary> ### [`v7.0.6`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#706) [Compare Source](https://github.com/withastro/astro/compare/[email protected]@7.0.6) ##### Patch Changes - [#​17261](withastro/astro#17261) [`79aa99c`](withastro/astro@79aa99c) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes a false deprecation warning for `markdown.gfm` and `markdown.smartypants` when using the Container API - [#​17247](withastro/astro#17247) [`f94280d`](withastro/astro@f94280d) Thanks [@​chatman-media](https://github.com/chatman-media)! - Fixes route generation throwing "Missing parameter" (or silently dropping the segment) when a dynamic param's value is `0`. The generator used truthy checks instead of checking for `undefined`, so `paginate(posts, { params: { categoryId: 0 } })` would crash even though `0` is a perfectly valid param value. - [#​17278](withastro/astro#17278) [`6f11739`](withastro/astro@6f11739) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes missing CSS for virtual style modules (e.g., responsive image layout styles) in dev mode when JavaScript is disabled - [#​17250](withastro/astro#17250) [`0b30b35`](withastro/astro@0b30b35) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes the `security.checkOrigin` check so it is applied consistently to Astro Actions and on-demand endpoints, regardless of how the request pipeline is composed. Previously, the origin check could be skipped in the composable `astro/hono` pipeline depending on the order of the `middleware()` primitive (or when it was omitted). - [#​17274](withastro/astro#17274) [`8c3579b`](withastro/astro@8c3579b) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes missing `render()` type overload for live collection entries. Previously, calling `render()` on a `LiveDataEntry` produced a TypeScript error when using only `live.config.ts` without a `content.config.ts`. - [#​17257](withastro/astro#17257) [`4208297`](withastro/astro@4208297) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes `astro check` failing to find `@astrojs/check` and `typescript` when astro is installed in a directory outside the project tree (e.g. pnpm virtual store) - [#​17272](withastro/astro#17272) [`b428648`](withastro/astro@b428648) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes island component paths so that extensionless imports (e.g. `import { Counter } from '../components/Counter'`) resolve to the real file on disk, matching Vite's extension order and directory `index` resolution. This makes the `include`/`exclude` options of JSX renderer integrations (React, Preact, Solid) match components imported without a file extension, and removes the spurious React 19 "Invalid hook call" warning logged on every request in dev when `include` was set alongside another JSX renderer - [#​17279](withastro/astro#17279) [`2aeaa44`](withastro/astro@2aeaa44) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes a bug where `<Picture inferSize>` with a remote image could fail with `FailedToFetchRemoteImageDimensions` when the image server rate-limits requests (e.g. HTTP 429). Remote dimensions are now resolved once per render instead of once per output format. - [#​17251](withastro/astro#17251) [`5240e26`](withastro/astro@5240e26) Thanks [@​matthewp](https://github.com/matthewp)! - Hardens the handling of attribute rendering when using with custom elements. - [#​17248](withastro/astro#17248) [`429bd62`](withastro/astro@429bd62) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes a crash when using Astro's `getViteConfig` with Vitest browser mode (e.g., Storybook vitest runner). Astro now skips dev server setup inside Vitest, preventing errors. - [#​17260](withastro/astro#17260) [`14524c0`](withastro/astro@14524c0) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes a regression where a `<script>` inside a component rendered through `Astro.slots.render()` was hoisted out of its original position instead of staying next to its component content - Updated dependencies \[[`eb6f97e`](withastro/astro@eb6f97e)]: - [@​astrojs/internal-helpers](https://github.com/astrojs/internal-helpers)@​0.10.1 - [@​astrojs/markdown-remark](https://github.com/astrojs/markdown-remark)@​7.2.1 - [@​astrojs/markdown-satteri](https://github.com/astrojs/markdown-satteri)@​0.3.3 ### [`v7.0.5`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#705) [Compare Source](https://github.com/withastro/astro/compare/[email protected]@7.0.5) ##### Patch Changes - [#​17242](withastro/astro#17242) [`9c05ba4`](withastro/astro@9c05ba4) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes an error that could occur after the dev server restarts when using an adapter such as `@astrojs/cloudflare`, where a request would fail with a `500` referencing a missing pre-bundled dependency: ``` The file does not exist at "node_modules/.vite/deps_ssr/astro_compiler-runtime.js?v=6419660d" which is in the optimize deps directory. The dependency might be incompatible with the dep optimizer. Try adding it to `optimizeDeps.exclude`. ``` - [#​17202](withastro/astro#17202) [`c6d254d`](withastro/astro@c6d254d) Thanks [@​matthewp](https://github.com/matthewp)! - Refactors path alias resolution to use Vite's native `tsconfigPaths` option This is an internal change with no expected impact on user projects. Astro now defers tsconfig and jsconfig `paths` alias resolution to Vite, keeping a small fallback for a few CSS cases Vite does not yet handle. - [#​17123](withastro/astro#17123) [`72e29bd`](withastro/astro@72e29bd) Thanks [@​martrapp](https://github.com/martrapp)! - Fixes an issue where the ClientRouter wipes head elements after page transitions if the `<head>` contains a `server:defer` component. - [#​17232](withastro/astro#17232) [`257505e`](withastro/astro@257505e) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes a bug where `<style>` tags from components such as a content collection's `Content` could be silently dropped from the output when an `await` appeared before the component in an `.astro` file's markup. - [#​17193](withastro/astro#17193) [`a7352fd`](withastro/astro@a7352fd) Thanks [@​jan-kubica](https://github.com/jan-kubica)! - Fixes the background dev server failing to start when `astro` is hoisted outside the project's `node_modules` (for example bun workspaces). The background process is now spawned from Astro's own resolved location instead of a path assumed under the project root. - [#​17255](withastro/astro#17255) [`581d171`](withastro/astro@581d171) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes prefetch not working for links inside `server:defer` components </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDYuMSIsInVwZGF0ZWRJblZlciI6IjQzLjI0Ni4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
resolve.tsconfigPathsby default.Testing
Docs
Related #17163