The rspack.experiments.VirtualModulesPlugin
is a Rust port of the webpack-virtual-modules
plugin. It's deeply integrated with Rspack to deliver the same functionality with enhanced performance.
You can pass virtual modules to the constructor when creating a new VirtualModulesPlugin instance:
Parameters:
modules
(optional): An object where keys are file paths and values are file contents.You can dynamically create or modify virtual modules using the writeModule
method:
Parameters:
filePath
: The virtual file path relative to compiler.context
contents
: The content of the virtual file