web-infra-dev / rspack

The fast Rust-based web bundler with webpack-compatible API 🦀️
https://rspack.dev
MIT License
9.85k stars 569 forks source link

Does rspack `normalModuleLoader` plan to align `beforeLoaders` and other hooks with webpack 5? #8055

Open gaoachao opened 1 month ago

gaoachao commented 1 month ago

Current

webpack NormalModuleCompilationHooks:

Image

rspack js side NormalModuleHooks:

Image

My Confusion

In addition, I found some code about before_loaders on the rust side, but the definition here is a litter different from webpack. Does it only need to be exported on the js side before it can be used? Please forgive me if my understanding is wrong. Image

Background

My webpack project use this hooks to add some custom loader context.

compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
    NormalModule.getCompilationHooks(compilation).beforeLoaders.tap(PLUGIN_NAME, (loaders, mod) => {
OskarLebuda commented 1 week ago

Is there any possibilities to expose beforeLoader? This is part of https://github.com/Trinovantes/vue-ssr-assets-plugin that I would like to move into Rspack. Without that this cannot be done.