Comments (4)
It is an old issue, but I just wanted to share our experience with memory-fs. Probably it is true that memory limitation isn't so important. However in non-trivial apps with multiple entry points, using require.context
and having a lot of various images it does become a very important aspect, and suddenly a webpack dev server process starts spanning gigabytes of RAM. This is without mentioning the plugins!
In our setup, webpack dev server process takes 2GB of RAM. After we configure a more aggressive policy for CommonsChunkPlugin, the RAM consumption goes down to 1.2GB, which is still insane. Removing typescript loader reduces it to 1GB.
May be we can apply some more optimization and reduce it even further. But it does not makes much sense to me. In our case the ideal solution for us would be to switch to a regular FS. This will solve the memory consumption problem and also reduce the time needed to start webpack dev server. By the way as webpack's user base keeps growing a lot of other folks are reporting same problems: webpack/webpack#2157 and webpack/webpack#1914.
Webpack is a great tool and has a huge potential. But it is wrong to make assumption on user's dev environment and to limit webpack's applications. I think any controversial decisions, such as using memory-fs, should be at least debatable and there is should be a possibility to opt it out. Is it possible to make memory-fs optional and to have a flag to disable its usage?
from webpack-dev-middleware.
I had no part in this decision, but I agree with it, so here's my position. For me, this is the kind of thing that varies on use case. On one hand, using memory storage limits you a tad since you probably want to be able to fit the output into memory. On the other hand:
- The memory limitation isn't so important because e.g. a 100 MiB Webpack app probably wouldn't be very nice to use anyways.
- Using memory means that the storage is fully ephemeral, such that there's no clean-up needed, and no possibility of accidentally reusing stale files from a previous run.
- Memory is obviously faster to write to/serve from than disk, though the difference here is probably very minuscule. May help much more if you use a remote filesystem.
- Nothing to add to
.gitignore
or similar, since there's no disk output. Nothing to clear from the home folder if it crashes.
The fact that it doesn't write to a build folder by default is nice. I don't accidentally want a version of the app with hot reload enabled to get deployed. (I have other safe-guards around bad deploys like that, of course, but nonetheless.)
You may find that in your case it hardly helps and perhaps it even hurts you. I think it'd be reasonable to have an option to not use an in-memory filesystem and instead use your build folder; but it does introduce a couple of filesystem related complications that in-memory work skips.
from webpack-dev-middleware.
It would be nice to have both. It is super nice to have hot module reloading, but if I reload at all, I have to re-run webpack since to get going again and that is a little frustrating.
from webpack-dev-middleware.
Yeah I agree with you that compiling to memory is a fine solution. But since you usually want to compile to disk anyway (for production environments or for doing other things with the compiled bundle), it feels as the plainer, more straight-forward solution to just compile to disk in this scenario as well. (It saves a code path.)
Now, having clarified the point I was trying to make in my opening post, the nine days that have passed in the meantime have provided me with a relevant new insight: due to hot-reload script files (with their unique names) the build target directory turns into a big mess very quickly if you don't proactively clean-up (or never write to disk at all).
So yeah, I would conclude that this is the reason why compiling to memory is worth it. It's by far the most elegant solution for preventing chaos in your build target folder.
from webpack-dev-middleware.
Related Issues (20)
- webpack-dev-middleware/types/index.d.ts requires @types/node@16 when Node.js 12 is still LTS HOT 1
- Problem with filesystem import
- Problem with file system import HOT 1
- Support for multipart range requests HOT 2
- Configurable logging HOT 1
- Bump memfs to 3.4.2 HOT 3
- [5.3.2] .d.ts references dom Request/Response HOT 5
- How to reference in-memory bundle from webpack-dev-middleware ? HOT 2
- Error: EPIPE: broken pipe, write causing livereload to break on Windows HOT 2
- Shared content base for multiple compiler instances HOT 6
- Propuesta
- Nueva propuesta
- Adding Hapi To The Other Servers Section Of README HOT 3
- Incorrect stats position field in res object HOT 10
- Incorrect content type when using typescript worker in dev server HOT 4
- middleware blocks on requests to non-webpack assets HOT 14
- Upgrade memfs HOT 1
- Bump json-joy dependency to new version due to bug fix with reserved windows file names HOT 2
- Address the vulnerability HOT 10
- memorize util printed out CACHE key HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpack-dev-middleware.