webpack-virtual-modules
webpack-virtual-modules copied to clipboard
[Feature] Support removeModule API
- [ ] I'd be willing to implement this feature
Describe the user story
We will remove virtual modules in some cases.
Describe the solution you'd like
In watch mode, we can remove virtual modules to release memory.
Describe the drawbacks of your solution
New API.
Describe alternatives you've considered
Additional context
I find this use case to be interesting.
I'm using webpack-virtual-modules to virtualize some of the modules that are "required" so that they won't break the application. One thing that upsets me is that the virtual modules will always take precedence over the physical files.
What I'd like to have is the flexibility to "unsubscribe" the virtual modules in favor of files that are now present my working directory and I think that the removeModule API would be fundamental for it.
Do you see any objections to this implementation, @larixer?
@rnarcos No objections, I would merge it, if tests will pass and the code quality will be okay-ish
Any way that I can be in closer contact with you (or any other contributor associated to this project) in order to get a clearer vision about environment setup and contribution guide?
@rnarcos As a core team member of Yarn package manager I'm available at a Yarn's discord: https://discord.com/invite/yarnpkg You are welcome to direct message me there.
hey i think i'm trying to do the same thing as you... basically i'm replacing a module dynamically as i rebuild. i can REPLACE the fake contents with new fake contents by calling writeModule again... but i can't go back to the original easily...
~it seems like~
delete compiler.inputFileSystem._virtualFiles[filename];
compiler.inputFileSystem.purge(filename);
~is doing the thing that i want?~
edit: no it's not.... dang. but i would really like this feature...
as a workaround i'm doing writeModule(filename, fs.readFileSync(filename)) if anybody else is stuck