Skip to content

Commit 9f53bd1

Browse files
committed
feat(store): return setImportMap and add merge parameter
1 parent 180dcef commit 9f53bd1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: src/store.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ export function useStore(
142142
}
143143
}
144144

145-
function setImportMap(map: ImportMap) {
145+
function setImportMap(map: ImportMap, merge = false) {
146+
if (merge) {
147+
map = mergeImportMap(getImportMap(), map)
148+
}
149+
146150
if (map.imports)
147151
for (const [key, value] of Object.entries(map.imports)) {
148152
if (value) {
@@ -368,6 +372,7 @@ export function useStore(
368372
deleteFile,
369373
renameFile,
370374
getImportMap,
375+
setImportMap,
371376
getTsConfig,
372377
serialize,
373378
deserialize,
@@ -436,6 +441,7 @@ export interface ReplStore extends UnwrapRef<StoreState> {
436441
deleteFile(filename: string): void
437442
renameFile(oldFilename: string, newFilename: string): void
438443
getImportMap(): ImportMap
444+
setImportMap(map: ImportMap, merge?: boolean): void
439445
getTsConfig(): Record<string, any>
440446
serialize(): string
441447
deserialize(serializedState: string): void

0 commit comments

Comments
 (0)