Skip to content

Commit

Permalink
Fix dest already exists build errors (remix-run#9901)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish authored Aug 22, 2024
1 parent 6f23bc9 commit c5292ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-crabs-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

Fix `dest already exists` build errors by only moving SSR assets to the client build directory when they're not already present on disk
13 changes: 3 additions & 10 deletions packages/remix-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,6 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
return JSON.parse(manifestContents) as Vite.Manifest;
};

let getViteManifestFilePaths = (viteManifest: Vite.Manifest): Set<string> => {
let filePaths = Object.values(viteManifest).map((chunk) => chunk.file);
return new Set(filePaths);
};

let getViteManifestAssetPaths = (
viteManifest: Vite.Manifest
): Set<string> => {
Expand Down Expand Up @@ -1405,9 +1400,6 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
let serverBuildDirectory = getServerBuildDirectory(ctx);

let ssrViteManifest = await loadViteManifest(serverBuildDirectory);
let clientViteManifest = await loadViteManifest(clientBuildDirectory);

let clientFilePaths = getViteManifestFilePaths(clientViteManifest);
let ssrAssetPaths = getViteManifestAssetPaths(ssrViteManifest);

// We only move assets that aren't in the client build, otherwise we
Expand All @@ -1419,8 +1411,9 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
let movedAssetPaths: string[] = [];
for (let ssrAssetPath of ssrAssetPaths) {
let src = path.join(serverBuildDirectory, ssrAssetPath);
if (!clientFilePaths.has(ssrAssetPath)) {
let dest = path.join(clientBuildDirectory, ssrAssetPath);
let dest = path.join(clientBuildDirectory, ssrAssetPath);

if (!fse.existsSync(dest)) {
await fse.move(src, dest);
movedAssetPaths.push(dest);
} else {
Expand Down

0 comments on commit c5292ed

Please sign in to comment.