Repository navigation
refactor: replace $features and @ aliases with #features subpath imports - #4191
Merged
Merged
Conversation
SvelteKit 3 deprecates kit.alias. Following #4190 ($lib to #lib), move src/features imports to package.json#imports and drop the alias block from svelte.config.js, so the Kit 3 migration does not need kit.alias. - Add "#features/*": "./src/features/*" to package.json imports - Rewrite 286 specifiers in 144 files ($features 284, @/features 2) with explicit extensions; the rewrite is script-generated and reproducible - Remove the whole alias block from svelte.config.js; leftover $features or @/ imports now fail type checking, while $lib stays blocked by the lint rules from #4190 - Update docs/guides and the tsconfig/svelte.config comments, cover @/ in the documented rg sweep, and point the CodeRabbit DB rule at #lib/server/database.js (missed in #4190) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Review skippedToo many files! This PR contains 150 files, which is 50 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry. ⚙️ Run configuration
📒 Files selected for processing: 150
You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This branch was successfully deployed
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.
SvelteKit 3 deprecates kit.alias. Following #4190 ($lib to #lib), move src/features imports to package.json#imports and drop the alias block from svelte.config.js, so the Kit 3 migration does not need kit.alias.
概要
SvelteKit 3 では
kit.aliasが非推奨になります。#4190($lib→#lib)に続けて、src/featuresへの importもpackage.json#importsの#features/*に置き換え、svelte.config.jsのaliasを丸ごと削除します。これで Kit 3 への移行時にkit.aliasを使わずに済みます。現行の Kit 2.70.3 のまま動作します。変更内容
package.jsonのimportsに"#features/*": "./src/features/*"を追加#features/...に置換($features284箇所、@/features2箇所。下記の codemod で生成).js、コンポーネントは.svelte、runes モジュール(実体が.svelte.ts)は.svelte.jsです。svelte.config.jsのalias(@・$lib・$lib/*・$features・$features/*)を削除$features・@/の import は型チェックで失敗します。$libは Kit 2 が組み込みで解決するため、引き続き refactor: lib subpath imports for kit v3 #4190 の lint 規則で禁止しています。docs/guides(architecture・testing-e2e)と、tsconfig.json・svelte.config.jsのコメントを更新.coderabbit.yamlの DB クライアントの規則を#lib/server/database.jsに修正(refactor: lib subpath imports for kit v3 #4190 での取りこぼし)手で編集したのは
package.json・svelte.config.js・tsconfig.json・.coderabbit.yamlとdocs/guidesの2ファイルです。残りの144ファイルは codemod の出力で、そのうち2ファイル(KanbanTabBar.svelte・workbooks/create/+page.server.ts)だけpnpm formatが行幅で整形しています。レビューの方法
置換部分は、この PR の base(
485ce861)で codemod を再実行すると同じ結果になります。手での確認は、上記の手で編集したファイルに絞れます。確認したこと
pnpm lint、pnpm check(0 errors、警告数は変更前と同じ)、pnpm test:unit(2726件)、pnpm build$featuresを import すると、型チェックでCannot find moduleになること(一時ファイルで確認)rg -n '\$lib|\$features|@/' src e2e prismaが0件。リポジトリ全体でも、残っているのは lint 規則と説明文だけ作業中の branch がある方へ
この PR のマージ後に rebase すると、
$features・@/の import が残っている箇所は型チェックと build で失敗します。rebase 後に codemod を再実行すれば、新しく追加したファイルも含めて置換されます。何度実行しても結果は変わりません。#4190 より前から続いている branch で
$libも残っている場合は、先にlibモードを実行してください(python3 -I codemod_subpath_imports.py . lib)。vi.mockの specifier は型チェックの対象外なので、上のrgで残りを確かめてください。E2E の spec では#featuresを使わず、相対 import のままにしてください。Playwright のランナーは#features/*.jsを.tsの実体に対応付けられないためです。codemod_subpath_imports.py
🤖 Generated with Claude Code