Skip to content

Commit

Permalink
fix: avoid including vue in import map if using default URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 6, 2023
1 parent c27ea52 commit 37ce32b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,23 @@ export class ReplStore implements Store {
}

serialize() {
return '#' + utoa(JSON.stringify(this.getFiles()))
const files = this.getFiles()
const importMap = files['import-map.json']
if (importMap) {
const { imports } = JSON.parse(importMap)
if (imports['vue'] === this.defaultVueRuntimeURL) {
delete imports['vue']
}
if (imports['vue/server-renderer'] === this.defaultVueServerRendererURL) {
delete imports['vue/server-renderer']
}
if (!Object.keys(imports).length) {
delete files['import-map.json']
} else {
files['import-map.json'] = JSON.stringify({ imports }, null, 2)
}
}
return '#' + utoa(JSON.stringify(files))
}

getFiles() {
Expand Down Expand Up @@ -209,7 +225,8 @@ export class ReplStore implements Store {
JSON.stringify(
{
imports: {
vue: this.defaultVueRuntimeURL
vue: this.defaultVueRuntimeURL,
'vue/server-renderer': this.defaultVueServerRendererURL
}
},
null,
Expand Down

0 comments on commit 37ce32b

Please sign in to comment.