Skip to content

Commit

Permalink
fix: handle error at load for apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Jan 15, 2024
1 parent c7dbb9d commit df9e98a
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ export default function astroDevToolbar({ settings }: AstroPluginOptions): vite.
return `
export const loadDevToolbarApps = async () => {
return [${settings.devToolbarApps
.map((plugin) => `(await import(${JSON.stringify(plugin)})).default`)
.join(',')}];
.map((plugin) => `await safeLoadPlugin(${JSON.stringify(plugin)})`)
.join(',')}].filter(app => app !== undefined));
};
async function safeLoadPlugin(entrypoint) {
try {
return (await import(entrypoint)).default;
} catch (err) {
console.error("Failed to load dev toolbar app from", entrypoint, err);
return undefined;
}
}
`;
}
},
Expand Down

0 comments on commit df9e98a

Please sign in to comment.