Use `dynamicCompileOptions` instead of `compilerOptions.runes` for `create`

オープン 初心者向け
#1,466 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
nodejs, typescript
領域
cli, tooling

調査の方向性

scaffolder のテンプレートから sveltekit({ compilerOptions: { runes: ... } }) ブロックを検索してください。これは payload が挙げている唯一のコードです。issue にある dynamicCompileOptions の形式に置き換え、任意の node:path から sep への変更も行うべきか確認してください。生成されたプロジェクトがアプリのコードには runes を強制し、node_modules には強制しない状態になれば完了です。プロジェクトを生成して svelte.config.js を確認することで検証できます。

索引モデルが issue の本文から書いたものです。

説明

As I was experimenting with the project scaffolder, I noticed I could steal that compilerOptions.runes trick to make sure runes are enforced in Svelte Changelog.

But while copying it and reading the docs, I noticed they mention Vite users (SvelteKit) should prefer dynamicCompileOptions. dynamicCompileOptions docs also provide an (outdated but) explicit example for that kind of check.

As a result, the template should probably be changed:

			sveltekit({
				// Force runes mode for the project, except for libraries. Can be removed in Svelte 6.
-				compilerOptions: {
-					runes: ({ filename }) =>
-						filename.split(/[/\\]/).includes('node_modules') ? undefined : true
+				dynamicCompileOptions: ({ filename, compileOptions }) => {
+					if (!filename.split(/[/\\]/).includes('node_modules') && !compileOptions.runes) {
+						return { runes: true };
+					}
				},
				adapter: adapter()
			})

Additionally, Node (and Bun) environments can take advantage of "node:path".sep instead of a (non-precompiled) regex, improving performance:

+import { sep } from 'node:path';

...
-					if (!filename.split(/[/\\]/).includes('node_modules') && !compileOptions.runes) {
+					if (!filename.split(sep).includes('node_modules') && !compileOptions.runes) {
...
主要言語
TypeScript
スター
513
フォーク
110
平均マージ
5日 1時間
マージ済み PR(30日)
24

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sveltejs/cli のほかの issue

sveltejs/cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。