fix: 모바일 웹 가계부 내역 진입 불가(청크 로드 실패) 해결
CI / build (push) Failing after 12m17s

- @capacitor/camera 정적 import 제거 → 네이티브에서만 동적 import
  (웹은 카메라를 호출하지도 않는데 정적 import가 AccountView 청크 평가를 깨뜨려
   모바일 웹에서 진입 시 청크 로드 실패 → onError 새로고침 → 로그인 루프 발생)
- router.onError 경로별 1회 새로고침으로 제한(무한 루프 방지) + 성공 시 플래그 정리

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ByungCheol
2026-06-03 18:29:00 +09:00
parent f45be09ff1
commit 8f8744ba4b
2 changed files with 19 additions and 11 deletions
+12 -6
View File
@@ -108,15 +108,21 @@ router.beforeEach((to, from) => {
})
// 새 배포로 청크 해시가 바뀐 뒤, 캐시된 옛 index.html 이 삭제된 옛 청크를 부르면
// 동적 import 가 실패한다. 이 경우 목적지로 전체 새로고침해 최신 index.html 을 받게 한다.
let reloadingForChunk = false
// 동적 import 가 실패한다. 이 경우 목적지로 1회 전체 새로고침해 최신 index.html 을 받게 한다.
// (경로별 1회만 — 새로고침 후에도 실패하면 무한 새로고침/로그인 루프를 막기 위해 중단)
router.onError((err, to) => {
const msg = (err && err.message) || ''
const chunkError = /dynamically imported module|Importing a module script failed|Failed to fetch dynamically imported module|ChunkLoadError|error loading dynamically imported module/i.test(msg)
if (chunkError && !reloadingForChunk) {
reloadingForChunk = true
window.location.assign(to?.fullPath || window.location.pathname)
}
if (!chunkError) return
const path = to?.fullPath || window.location.pathname
const key = 'chunk-reload:' + path
if (sessionStorage.getItem(key)) return // 이미 한 번 새로고침했는데 또 실패 → 루프 방지
sessionStorage.setItem(key, '1')
window.location.assign(path)
})
// 정상 진입 시 해당 경로의 새로고침 플래그 정리 (다음 배포 때 다시 동작하도록)
router.afterEach((to) => {
sessionStorage.removeItem('chunk-reload:' + to.fullPath)
})
export default router