Skip to content

Commit 300202b

Browse files
committed
Add retry
1 parent ea26e98 commit 300202b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

tsup.base.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,15 @@ const baseConfig: Options & {
114114

115115
// tsup@8.5.0 do not write to output atomically.
116116
// Thus, when building in parallel, some of the files will be emptied.
117-
// We are writing output to /dist.tmp/ and copy everything back to /dist/.
117+
118+
// Writing output to /dist.tmp/ and copy everything back to /dist/ for better atomicity.
119+
118120
// "onSuccess" runs before DTS, we need to wait until *.d.ts are emitted.
119-
onSuccess: `while [ -z "$(find ./dist.tmp -name '*.d.ts' -print -quit)" ]; do sleep 0.2; done; mkdir -p ./dist/ && cp ./dist.tmp/* ./dist/`,
121+
122+
// All instances of tsup will try to copy at the same time and could fail with "cp: cannot create regular file './dist/...': File exists".
123+
// We will retry.
124+
125+
onSuccess: `while [ -z "$(find ./dist.tmp -name '*.d.ts' -print -quit)" ]; do sleep 0.2; done; mkdir -p ./dist/; until cp ./dist.tmp/* ./dist/; do sleep 0.5; done`,
120126
outDir: './dist.tmp/'
121127
};
122128

0 commit comments

Comments
 (0)