vite-plugin-inspect
vite-plugin-inspect copied to clipboard
fix: remove unnecessary `load` hook
Description
IMHO, the load
hook of the plugin is not necessary at all.
Let's take a glance at the logic of hijackHood(plugin, 'load')
.
- first we execute hooks to get the result
- check whether it's valid
- if it's valid, then put in into the map, which refers
transformMap
ortransformMapSSR
.
So we add the correct result into the map in step 3. However, the load
hook of vite-plugin-inspect
is executed first in step 1, and there is no corresponding result in the map at this time, because the correct result is obtained by calling the load hooks of other plugins.
I added some console.logs to the hook and tested it in /playground, the result could prove too.
load: {
order: 'pre',
handler(id, { ssr } = {}) {
const map = ssr ? transformMapSSR : transformMap
console.log(id in map)
delete map[id]
return null
},
},
Linked Issues
None
Additional context
None