Vite: Avoid reading node_modules after building
Related https://github.com/vitejs/devtools/pull/151#pullrequestreview-3615746309
Since it is an after-build analyze devtools, I think it is also important to make display effect to be the same after building no matter what actions you have done except editing the files in .rolldown dir, there are two ways to implement:
- Since we only require the package name and its version, I think we can do something at rolldown side to save the metadata in the logs, and read the metadata rather than
node_modules. It is an easy but a little breaking way since the data struct is changed - Another workaround is try to get the the information required from the file URL, it is a little bit hacky and different package manager can have different path format for parsing.
The current solution is temporary, I will communicate with the rolldown side to see if it is possible to provide the packages info. I think this would be a better solution.
Okay, and I think it is not very difficult, I will also try to take part in implementing it. Thanks!
Note after viewing the code logic: the current logic uses chunks from ChunkGraph and cut the path to get the package path, we can just add the similar logic and package.json file reads there. and I think we should add packages object in ChunkGraphReady hook (like { action: "ChunkGraphReady", chunks: chunk_infos, packages: package_infos }) or others.
https://github.com/rolldown/rolldown/blob/b381fe6ab9931bde102ef2282617233824bceb1c/crates/rolldown/src/stages/generate_stage/mod.rs#L609-611
I have communicated and confirmed that rolldown will take over support for this.
Okay, thanks!