diff --git a/src/core/utils/building/build-entrypoints.ts b/src/core/utils/building/build-entrypoints.ts index b5f9d85e..dbd4def4 100644 --- a/src/core/utils/building/build-entrypoints.ts +++ b/src/core/utils/building/build-entrypoints.ts @@ -18,12 +18,15 @@ export async function buildEntrypoints( const steps: BuildStepOutput[] = []; for (let i = 0; i < groups.length; i++) { const group = groups[i]; - const groupNames = [group] - .flat() - .map((e) => e.name) - .join(pc.dim(', ')); - spinner.text = pc.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNames}`; - steps.push(await config.builder.build(group)); + const groupNames = [group].flat().map((e) => e.name); + const groupNameColored = groupNames.join(pc.dim(', ')); + spinner.text = + pc.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNameColored}`; + try { + steps.push(await config.builder.build(group)); + } catch (err) { + throw Error(`Failed to build ${groupNames.join(', ')}`, { cause: err }); + } } const publicAssets = await copyPublicDirectory(config); diff --git a/src/core/utils/building/import-entrypoint.ts b/src/core/utils/building/import-entrypoint.ts index b368a250..b1dc090b 100644 --- a/src/core/utils/building/import-entrypoint.ts +++ b/src/core/utils/building/import-entrypoint.ts @@ -89,16 +89,16 @@ export async function importEntrypointFile( const res = await jiti(path); return res.default; } catch (err) { + const filePath = relative(config.root, path); if (err instanceof ReferenceError) { // "XXX is not defined" - usually due to WXT removing imports const variableName = err.message.replace(' is not defined', ''); - const filePath = relative(config.root, path); throw Error( `${filePath}: Cannot use imported variable "${variableName}" outside the main function. See https://wxt.dev/guide/entrypoints.html#side-effects`, { cause: err }, ); } else { - throw err; + throw Error(`Failed to load entrypoint: ${filePath}`, { cause: err }); } } }