diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2025-03-12 14:37:57 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-12 14:37:57 +0900 |
| commit | e594fb0037f440f589c36c01e0108f011545a681 (patch) | |
| tree | 2afd5944284b0f0f3682b19c20b7d6800ef75117 /packages/frontend/lib | |
| parent | remove todo (diff) | |
| download | misskey-e594fb0037f440f589c36c01e0108f011545a681.tar.gz misskey-e594fb0037f440f589c36c01e0108f011545a681.tar.bz2 misskey-e594fb0037f440f589c36c01e0108f011545a681.zip | |
enhance(dev): frontendの検索インデックス作成を単独のコマンドで行えるように (#15653)
Diffstat (limited to 'packages/frontend/lib')
| -rw-r--r-- | packages/frontend/lib/vite-plugin-create-search-index.ts | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/packages/frontend/lib/vite-plugin-create-search-index.ts b/packages/frontend/lib/vite-plugin-create-search-index.ts index e194872640..d506e84bb6 100644 --- a/packages/frontend/lib/vite-plugin-create-search-index.ts +++ b/packages/frontend/lib/vite-plugin-create-search-index.ts @@ -1428,6 +1428,23 @@ async function processVueFile( }; } +export async function generateSearchIndex(options: Options, transformedCodeCache: Record<string, string> = {}) { + const filePaths = options.targetFilePaths.reduce<string[]>((acc, filePathPattern) => { + const matchedFiles = glob.sync(filePathPattern); + return [...acc, ...matchedFiles]; + }, []); + + for (const filePath of filePaths) { + const id = path.resolve(filePath); // 絶対パスに変換 + const code = fs.readFileSync(filePath, 'utf-8'); // ファイル内容を読み込む + const { transformedCodeCache: newCache } = await processVueFile(code, id, options, transformedCodeCache); // processVueFile 関数を呼び出す + transformedCodeCache = newCache; // キャッシュを更新 + } + + await analyzeVueProps({ ...options, transformedCodeCache }); // 開発サーバー起動時にも analyzeVueProps を実行 + + return transformedCodeCache; // キャッシュを返す +} // Rollup プラグインとして export export default function pluginCreateSearchIndex(options: Options): Plugin { @@ -1445,19 +1462,7 @@ export default function pluginCreateSearchIndex(options: Options): Plugin { return; } - const filePaths = options.targetFilePaths.reduce<string[]>((acc, filePathPattern) => { - const matchedFiles = glob.sync(filePathPattern); - return [...acc, ...matchedFiles]; - }, []); - - for (const filePath of filePaths) { - const id = path.resolve(filePath); // 絶対パスに変換 - const code = fs.readFileSync(filePath, 'utf-8'); // ファイル内容を読み込む - const { transformedCodeCache: newCache } = await processVueFile(code, id, options, transformedCodeCache); // processVueFile 関数を呼び出す - transformedCodeCache = newCache; // キャッシュを更新 - } - - await analyzeVueProps({ ...options, transformedCodeCache }); // 開発サーバー起動時にも analyzeVueProps を実行 + transformedCodeCache = await generateSearchIndex(options, transformedCodeCache); }, async transform(code, id) { |