diff --git a/lib/fs.js b/lib/fs.js index 6bd5e9baa..e5df1e7d3 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -2,7 +2,10 @@ const fs = require('fs'); const path = require('path'); -const MemoryFileSystem = require('memory-fs'); +const { Volume } = require('memfs'); +// TODO: move these two functions to a better place +const memoryFsJoin = require('memory-fs/lib/join'); +const memoryFsNormalize = require('memory-fs/lib/normalize'); const { colors } = require('webpack-log'); const NodeOutputFileSystem = require('webpack/lib/node/NodeOutputFileSystem'); const DevMiddlewareError = require('./DevMiddlewareError'); @@ -60,12 +63,14 @@ module.exports = { let fileSystem; // store our files in memory - const isMemoryFs = !compiler.compilers && compiler.outputFileSystem instanceof MemoryFileSystem; + const isMemoryFs = !compiler.compilers && compiler.outputFileSystem instanceof Volume; if (isMemoryFs) { fileSystem = compiler.outputFileSystem; } else { - fileSystem = new MemoryFileSystem(); + fileSystem = new Volume(); + fileSystem.join = memoryFsJoin; + fileSystem.normalize = memoryFsNormalize; compiler.outputFileSystem = fileSystem; } diff --git a/package-lock.json b/package-lock.json index c3d95e8af..bd7f9efd3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2543,6 +2543,11 @@ "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", "dev": true }, + "fast-extend": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/fast-extend/-/fast-extend-0.0.2.tgz", + "integrity": "sha1-9exCz0C5Rg9SGmOH37Ut7u1nHb0=" + }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", @@ -2821,6 +2826,11 @@ "minipass": "^2.2.1" } }, + "fs-monkey": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-0.3.3.tgz", + "integrity": "sha512-FNUvuTAJ3CqCQb5ELn+qCbGR/Zllhf2HtwsdAtBi59s1WeCjKMT81fHcSu7dwIskqGVK+MmOrb7VOBlq3/SItw==" + }, "fs-write-stream-atomic": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", @@ -3997,6 +4007,15 @@ "mimic-fn": "^1.0.0" } }, + "memfs": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/memfs/-/memfs-2.15.0.tgz", + "integrity": "sha512-vktLqfHB1K4I9oiWlG4VjbztEreU5LqgnTnlVimr4bKNhJwjTmKg5+eYIimmNiKVUolTUrWSy2k/KEyqqLqZrQ==", + "requires": { + "fast-extend": "0.0.2", + "fs-monkey": "^0.3.3" + } + }, "memory-fs": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", diff --git a/package.json b/package.json index b45de43f4..1a93a5b3d 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "release": "standard-version" }, "dependencies": { + "memfs": "^2.15.0", "memory-fs": "~0.4.1", "mime": "^2.3.1", "range-parser": "^1.0.3",