fix(webpack): explicitly pass outputFileSystem to webpackDevMiddleware #7613
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Types of changes
Description
I got hit by nuxt/typescript#145 a couple of days ago, and together with @crutch12 we were able to determine the reason.
It is not triggered in particular by
lerna
,@nuxt/typescript
, and can also be reproduced with yarn.The culprit happens to be in the interaction between
@nuxt/webpack
,webpack-dev-middleware
andmemory-fs
, and how the package manager (e.g. npm or yarn) decides to dedupe them on disk.In particular,
webpack-dev-middleware@3.7.2
performs a checkcompiler.outputFileSystem instanceof MemoryFileSystem
: https://github.com/webpack/webpack-dev-middleware/blob/v3.7.2/lib/fs.js#L112@nuxt/webpack
andwebpack-dev-middleware
happen to "share" the dedupedmemory-fs
(i.e. it is hoisted to a top of node_modules), then the check passes, and everything is snazzy.memory-fs
happens to be "inlined" (i.e. another version ofmemory-fs
is hoisted to the top of node_modules), then the check fails, andwebpack-dev-middleware
creates it's own instance of MemoryFileSystem to write to, and the original AsyncMFS created by@nuxt/webpack
never gets populated with compiled files.Reproduction is quite easy, you just have to have top level
memory-fs
dependency of a different version than the one used by@nuxt/webpack
andwebpack-dev-middleware
:A solution we were able to find is to explicitly pass file system instance through
webpack-dev-middleware
options instead of relying on it to extract the file system instance from the compiler instance.Checklist: