Skip to content

Commit

Permalink
fix: serialize import maps
Browse files Browse the repository at this point in the history
closes vuejs#204
  • Loading branch information
sxzz committed Jan 7, 2024
1 parent 8038b49 commit e085e30
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export class ReplStore implements Store {
const files = this.getFiles()
const importMap = files[importMapFile]
if (importMap) {
const { imports } = JSON.parse(importMap)
const { imports, ...restImportMap } = JSON.parse(importMap)
if (imports['vue'] === this.defaultVueRuntimeURL) {
delete imports['vue']
}
Expand All @@ -328,7 +328,11 @@ export class ReplStore implements Store {
if (!Object.keys(imports).length) {
delete files[importMapFile]
} else {
files[importMapFile] = JSON.stringify({ imports }, null, 2)
files[importMapFile] = JSON.stringify(
{ imports, ...restImportMap },
null,
2
)
}
}
return '#' + utoa(JSON.stringify(files))
Expand Down Expand Up @@ -400,7 +404,7 @@ export class ReplStore implements Store {
)
}
map.code = JSON.stringify(json, null, 2)
} catch (e) {}
} catch {}
}
}

Expand Down

0 comments on commit e085e30

Please sign in to comment.