Skip to content

Commit

Permalink
fix: Don't crash when generating types in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 committed Jul 20, 2023
1 parent b625f41 commit d8c1903
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/core/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function buildInternal(

const entrypoints = await findEntrypoints(config);
const groups = groupEntrypoints(entrypoints);
const { output } = await rebuild(config, groups);
const { output } = await rebuild(config, groups, undefined, true);

// Post-build
config.logger.success(
Expand Down Expand Up @@ -70,7 +70,11 @@ export async function rebuild(
): Promise<{ output: BuildOutput; manifest: Manifest.WebExtensionManifest }> {
// Update types directory with new files and types
const allEntrypoints = await findEntrypoints(config);
await generateTypesDir(allEntrypoints, config);
await generateTypesDir(allEntrypoints, config).catch((err) => {
config.logger.warn('Failed to update .wxt directory:', err);
// Throw the error if doing a regular build, don't for dev mode.
if (config.command === 'build') throw err;
});

// Build and merge the outputs
const newOutput = await buildEntrypoints(entrypointGroups, config);
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ export async function createServer(

await fileChangedMutex.runExclusive(async () => {
const fileChanges = changeQueue.splice(0, changeQueue.length);
const changes = detectDevChanges(fileChanges, server.currentOutput);
if (fileChanges.length === 0) return;

const changes = detectDevChanges(fileChanges, server.currentOutput);
if (changes.type === 'no-change') return;

// Log the entrypoints that were effected
Expand Down

0 comments on commit d8c1903

Please sign in to comment.