Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use memfs instead of memory-fs #366

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/fs.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
}

Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -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",
Expand Down