I'm writing a webpack Plugin and Loader and I'd like to create a "dynamic" module that's generated through my Plugin.
Basically, I want my loader emit an import to the dynamic module, like this:
module.exports = function (content) {
return `
const dynamicModule = require('./the-dynamic-module')
// module.exports = ...
`;
}
The Plugin should generate "./the-dynamic-module"
, and ideally, the loader should be re-built every time the dynamic module changes.
Is there a way to achieve this?
There's a Plugin that generates virtual modules, but they're static. I'd like to generate a dynamic one, during compilation time.
Any help is appreciated! Cheers.