diff --git a/src/core/create-server.ts b/src/core/create-server.ts index 29dcfd5f..973a6122 100644 --- a/src/core/create-server.ts +++ b/src/core/create-server.ts @@ -189,34 +189,38 @@ function createFileReloader(server: WxtDevServer) { // Rebuild entrypoints on change const allEntrypoints = await findEntrypoints(); - const { output: newOutput } = await rebuild( - allEntrypoints, - // TODO: this excludes new entrypoints, so they're not built until the dev command is restarted - changes.rebuildGroups, - changes.cachedOutput, - ); - server.currentOutput = newOutput; + try { + const { output: newOutput } = await rebuild( + allEntrypoints, + // TODO: this excludes new entrypoints, so they're not built until the dev command is restarted + changes.rebuildGroups, + changes.cachedOutput, + ); + server.currentOutput = newOutput; - // Perform reloads - switch (changes.type) { - case 'extension-reload': - server.reloadExtension(); - consola.success(`Reloaded extension`); - break; - case 'html-reload': - const { reloadedNames } = reloadHtmlPages( - changes.rebuildGroups, - server, - ); - consola.success(`Reloaded: ${getFilenameList(reloadedNames)}`); - break; - case 'content-script-reload': - reloadContentScripts(changes.changedSteps, server); - const rebuiltNames = changes.rebuildGroups - .flat() - .map((entry) => entry.name); - consola.success(`Reloaded: ${getFilenameList(rebuiltNames)}`); - break; + // Perform reloads + switch (changes.type) { + case 'extension-reload': + server.reloadExtension(); + consola.success(`Reloaded extension`); + break; + case 'html-reload': + const { reloadedNames } = reloadHtmlPages( + changes.rebuildGroups, + server, + ); + consola.success(`Reloaded: ${getFilenameList(reloadedNames)}`); + break; + case 'content-script-reload': + reloadContentScripts(changes.changedSteps, server); + const rebuiltNames = changes.rebuildGroups + .flat() + .map((entry) => entry.name); + consola.success(`Reloaded: ${getFilenameList(rebuiltNames)}`); + break; + } + } catch (err) { + // Catch build errors instead of crashing. Don't log error either, builder should have already logged it } }); }; diff --git a/src/core/utils/building/build-entrypoints.ts b/src/core/utils/building/build-entrypoints.ts index a360c1fb..9104caf6 100644 --- a/src/core/utils/building/build-entrypoints.ts +++ b/src/core/utils/building/build-entrypoints.ts @@ -20,6 +20,7 @@ export async function buildEntrypoints( try { steps.push(await wxt.config.builder.build(group)); } catch (err) { + spinner.stop().clear(); wxt.logger.error(err); throw Error(`Failed to build ${groupNames.join(', ')}`, { cause: err }); }