D
D
Dmitry Belyaev2019-03-15 20:25:13
webpack
Dmitry Belyaev, 2019-03-15 20:25:13

How to slip a virtual (generated) module into webpack?

I needed a module in the project, which I simply generate from the AST tree based on the data collected by the loader from some modules
. At the moment, everything works through a rather crutch (in my opinion) method, namely:
1. there is an empty blank file on the disk
2. a loader is set on the file, which cuts down the cache for the module and builds its code
3. in the afterResolve hook of normalModuleFactory, this module is asynchronously blocked until all the data is collected.
What I would like to receive:
1. get rid of the unnecessary file on the disk
2. get rid of the loader , and generate the module code directly from the plugin
3. invalidate the module, when the data is updated,
I understand that I need to dig in theory or in the direction of normalModuleFactoryor in the direction of contextModuleFactory
but since there is no documentation for either of the words at all ... I have already killed 2 nights by connecting to the node with a debugger from chrome, and breaking webpack ... but I have not achieved anything ...
I will even grateful for links to at least some kind of documentation (maybe I don’t know how to google?) on writing plugins for webpack (with a detailed description of all hooks)...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question