perf: 게임 화면을 경로별로 지연 로드

모든 게임 화면을 진입 번들에 포함하던 정적 import를 Vue Router 동적 import로 바꿉니다. 초기 프로필 진입에서 현재 경로에 필요한 화면만 내려받고, 회귀 방지 테스트를 추가합니다.
This commit is contained in:
2026-08-18 06:39:40 +00:00
parent e1c4336253
commit ada8edc72e
2 changed files with 60 additions and 38 deletions
@@ -0,0 +1,21 @@
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import path from 'node:path';
import { describe, it } from 'node:test';
const routerSourcePath = path.resolve(import.meta.dirname, '../src/router/index.ts');
void describe('game route loading contract', () => {
void it('loads view components through route-level dynamic imports', async () => {
const source = await readFile(routerSourcePath, 'utf8');
const staticViewImports = [...source.matchAll(/^import\s+.+\s+from\s+['"]\.\.\/views\//gm)];
const lazyViewImports = [...source.matchAll(/=\s*\(\)\s*=>\s*import\(['"]\.\.\/views\//g)];
const routedViewComponents = new Set(
[...source.matchAll(/^\s*component:\s*([A-Z][A-Za-z0-9]+View),?$/gm)].map((match) => match[1])
);
assert.deepEqual(staticViewImports, []);
assert.equal(lazyViewImports.length, routedViewComponents.size);
assert.ok(lazyViewImports.length >= 35);
});
});