File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,6 @@ edge-runtime/vendor/
9
9
deno.lock
10
10
tests /fixtures /simple-next-app-dist-dir /cool /output
11
11
.nx
12
- custom-dist-dir
12
+ custom-dist-dir
13
+ # to avoid needing extra permissions to format files
14
+ .github /workflows
Original file line number Diff line number Diff line change
1
+ const { platform } = require ( 'process' )
2
+ const fsPromises = require ( 'fs/promises' )
3
+
4
+ // Next.js uses `fs.promises.copyFile` to copy files from `.next`to the `.next/standalone` directory
5
+ // It tries copying the same file twice in parallel. Unix is fine with that, but Windows fails
6
+ // with "Resource busy or locked", failing the build.
7
+ // We work around this by memoizing the copy operation, so that the second copy is a no-op.
8
+ // Tracked in TODO: report to Next.js folks
9
+ if ( platform === 'win32' ) {
10
+ const copies = new Map ( )
11
+
12
+ const originalCopy = fsPromises . copyFile
13
+ fsPromises . copyFile = ( src , dest , mode ) => {
14
+ const key = `${ dest } :${ src } `
15
+ const existingCopy = copies . get ( key )
16
+ if ( existingCopy ) return existingCopy
17
+
18
+ const copy = originalCopy ( src , dest , mode )
19
+ copies . set ( key , copy )
20
+ return copy
21
+ }
22
+ }
23
+
1
24
module . exports = {
2
25
trailingSlash : true ,
3
26
output : 'standalone' ,
Original file line number Diff line number Diff line change 1
1
const { platform } = require ( 'process' )
2
2
const fsPromises = require ( 'fs/promises' )
3
3
4
- // Next.js uses `fs.promises.copyFile` to copy the `.wasm` file to the `.next` directory
4
+ // Next.js uses `fs.promises.copyFile` to copy files from `.next` to the `.next/standalone ` directory
5
5
// It tries copying the same file twice in parallel. Unix is fine with that, but Windows fails
6
6
// with "Resource busy or locked", failing the build.
7
7
// We work around this by memoizing the copy operation, so that the second copy is a no-op.
You can’t perform that action at this time.
0 commit comments