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 1 commit
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
9 changes: 6 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 { fs: memfs } = require('memfs');
// borrow join and normalize from memory-fs
memfs.join = require('memory-fs/lib/join');
memfs.normalize = require('memory-fs/lib/normalize');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not good solution, we don't need two memory-fs package

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those functions appear to be unrelated to the file system itself and could live somewhere else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but it is bad have two memory fs package, we should move these function to separate repo or move to memfs

const { colors } = require('webpack-log');
const NodeOutputFileSystem = require('webpack/lib/node/NodeOutputFileSystem');
const DevMiddlewareError = require('./DevMiddlewareError');
Expand Down Expand Up @@ -60,12 +63,12 @@ module.exports = {

let fileSystem;
// store our files in memory
const isMemoryFs = !compiler.compilers && compiler.outputFileSystem instanceof MemoryFileSystem;
const isMemoryFs = !compiler.compilers && compiler.outputFileSystem === memfs;

if (isMemoryFs) {
fileSystem = compiler.outputFileSystem;
} else {
fileSystem = new MemoryFileSystem();
fileSystem = memfs;
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
2 changes: 1 addition & 1 deletion test/tests/server.js
Expand Up @@ -390,7 +390,7 @@ describe('Server', () => {
});

it('request to non-public path', (done) => {
request(app).get('/').expect(404, done);
request(app).get('/nonpublic/').expect(404, done);
});
});

Expand Down