diff --git a/importmap.js b/importmap.js index 76609da..af9b64d 100644 --- a/importmap.js +++ b/importmap.js @@ -1,6 +1,7 @@ +const importMapJson = './importmap.json'; const getCacheKey = () => { // 基于import map文件的路径,而不是当前模块的URL - const url = new URL('./importmap.json', window.location.href); + const url = new URL(importMapJson, window.location.href); const basePath = url.pathname.replace('/importmap.json', ''); return `importMap_${btoa(basePath).replace(/[+/=]/g, '_')}`; }; @@ -95,7 +96,7 @@ const loadImportMap = async () => { return; } - const response = await fetch('./imports.json'); + const response = await fetch(importMapJson); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } @@ -114,7 +115,7 @@ const loadImportMap = async () => { // 后台更新缓存(可选功能) export const updateCacheInBackground = async () => { try { - const response = await fetch('./imports.json'); + const response = await fetch(importMapJson); if (response.ok) { const data = await response.json(); setCachedImportMap(data);