Skip to content

Commit

Permalink
fix(web): suppress error in loading built-in plugin (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
keiya01 authored Aug 23, 2023
1 parent 42ad685 commit ae83bc0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions web/src/services/config/unsafeBuiltinPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type UnsafeBuiltinWidgets<T = unknown> = Record<string, T>;

export const loadUnsafeBuiltinPlugins = async (urls: string[]) => {
return (
await Promise.all(
await Promise.allSettled(
urls.map(async url => {
try {
const plugin: UnsafeBuiltinPlugin = (await import(/* @vite-ignore */ url)).default;
Expand All @@ -32,5 +32,15 @@ export const loadUnsafeBuiltinPlugins = async (urls: string[]) => {
}
}),
)
).filter(Boolean);
)
.map(val => {
switch (val.status) {
case "fulfilled":
return val.value;
case "rejected":
console.warn(val.reason);
return;
}
})
.filter((v): v is UnsafeBuiltinPlugin => !!v);
};

0 comments on commit ae83bc0

Please sign in to comment.