webpack-virtual-modules icon indicating copy to clipboard operation
webpack-virtual-modules copied to clipboard

[Feature] Support removeModule API

Open dolymood opened this issue 4 years ago • 6 comments

  • [ ] 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

dolymood avatar Aug 06 '21 10:08 dolymood

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 avatar Apr 11 '23 16:04 rnarcos

@rnarcos No objections, I would merge it, if tests will pass and the code quality will be okay-ish

larixer avatar Apr 11 '23 16:04 larixer

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 avatar Apr 11 '23 17:04 rnarcos

@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.

larixer avatar Apr 11 '23 20:04 larixer

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...

fringd avatar Aug 28 '23 23:08 fringd

as a workaround i'm doing writeModule(filename, fs.readFileSync(filename)) if anybody else is stuck

fringd avatar Aug 29 '23 00:08 fringd