Replies: 2 comments 1 reply
-
defaultValue of |
Beta Was this translation helpful? Give feedback.
-
In Webpack, plugin can get the module instance directly through compilation.hooks.runtimeModule.tap('xxx', (module, chunk) => {
if (chunk.name === 'xxx' && (module.name === 'xxx' || module.constructor.name === 'xxx')) {
const originSource = module.getGeneratedCode();
const appendSource = "/* new source */";
module.getGeneratedCode = () => `${originSource}\n${appendSource}`;
}
}); But in Rspack, since the injection of the runtime module is on the Rust side, and it is very hard to port the entire runtime module + runtime requirements to the JavaScript side. compilation.hooks.runtimeModule.tap("TestFakePlugin", (module, chunk) => {
if (chunk.name === 'xxx' && (module.name === 'xxx' || module.constructorName === 'xxx')) {
const originSource = module.source.source.toString('utf-8');
const appendSource = "blabla";
module.source.source = Buffer.from(
`${originSource}\n${appendSource}`,
"utf-8"
);
}
}); |
Beta Was this translation helpful? Give feedback.
-
This discussion channel is used to track the design(not implmentation) misalignments between Rspack and webpack, we need to align with webpack unless we have strong solid reason to diff with webpack.
Beta Was this translation helpful? Give feedback.
All reactions