Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/compiler/build/watch-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ export const createWatchBuild = async (
);
}

// Make sure all files in the module map are still in the fs
// Otherwise, we can run into build errors because the compiler can think
// there are two component files with the same tag name
Array.from(compilerCtx.moduleMap.keys()).forEach((key) => {
if (filesUpdated.has(key) || filesDeleted.has(key)) {
// Check if the file exists in the fs
const fileExists = compilerCtx.fs.accessSync(key);
if (!fileExists) {
compilerCtx.moduleMap.delete(key);
}
}
});

// Make sure all added/updated files are watched
// We need to check both added/updates since the TS watch program behaves kinda weird
// and doesn't always handle file renames the same way
new Set([...filesUpdated, ...filesAdded]).forEach((filePath) => {
compilerCtx.addWatchFile(filePath);
});

dirsAdded.clear();
dirsDeleted.clear();
filesAdded.clear();
Expand Down