3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import * as fs from 'fs' ;
7
6
import { Barrier , retry } from 'vs/base/common/async' ;
8
7
import { ResourceMap } from 'vs/base/common/map' ;
9
8
import { VSBuffer } from 'vs/base/common/buffer' ;
@@ -27,26 +26,41 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
27
26
import { UniversalWatcherClient } from 'vs/platform/files/node/watcher/watcherClient' ;
28
27
import { NodeJSWatcherClient } from 'vs/platform/files/node/watcher/nodejs/nodejsClient' ;
29
28
30
- // ESM-comment-begin
31
- import { gracefulify } from 'graceful-fs' ;
32
- // ESM-comment-end
33
- // ESM-uncomment-begin
34
- // import pkg from 'graceful-fs';
35
- // const { gracefulify } = pkg;
36
- // ESM-uncomment-end
37
-
38
29
/**
39
30
* Enable graceful-fs very early from here to have it enabled
40
31
* in all contexts that leverage the disk file system provider.
41
32
*/
33
+
34
+ // ESM-comment-begin
35
+ import * as fs from 'fs' ;
36
+ import { gracefulify } from 'graceful-fs' ;
42
37
( ( ) => {
43
38
try {
44
39
gracefulify ( fs ) ;
45
40
} catch ( error ) {
46
41
console . error ( `Error enabling graceful-fs: ${ toErrorMessage ( error ) } ` ) ;
47
- console . error ( error ) ;
48
42
}
49
43
} ) ( ) ;
44
+ // ESM-comment-end
45
+
46
+ // ESM-uncomment-begin
47
+ //// HACK: when importing 'fs' it comes out as non-configurable and
48
+ //// HACK: therefore we cannot patch it with graceful-fs. As a workaround
49
+ //// HACK: we use the CJS module (fingers crossed that this works)
50
+ // import pkg from 'graceful-fs';
51
+ // const { gracefulify } = pkg;
52
+ // import type * as fs from 'fs';
53
+ // const _fs = globalThis._VSCODE_NODE_MODULES.fs;
54
+ // (() => {
55
+ // try {
56
+ // gracefulify(_fs);
57
+ // } catch (error) {
58
+ // console.error(`Error enabling graceful-fs: ${toErrorMessage(error)}`);
59
+ // }
60
+ // })();
61
+ // ESM-uncomment-end
62
+
63
+
50
64
51
65
export class DiskFileSystemProvider extends AbstractDiskFileSystemProvider implements
52
66
IFileSystemProviderWithFileReadWriteCapability ,
0 commit comments