Skip to content

Commit d8c1903

Browse files
committed
fix: Don't crash when generating types in dev mode
1 parent b625f41 commit d8c1903

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/core/build.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function buildInternal(
3939

4040
const entrypoints = await findEntrypoints(config);
4141
const groups = groupEntrypoints(entrypoints);
42-
const { output } = await rebuild(config, groups);
42+
const { output } = await rebuild(config, groups, undefined, true);
4343

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

7579
// Build and merge the outputs
7680
const newOutput = await buildEntrypoints(entrypointGroups, config);

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ export async function createServer(
5959

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

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

6667
// Log the entrypoints that were effected

0 commit comments

Comments
 (0)