Open aklinker1 opened 8 months ago
There is a CLI tool for this https://github.com/btd/rollup-plugin-visualizer#cli already. Not sure if i want to support merge as API
Basically merge happen there https://github.com/btd/rollup-plugin-visualizer/blob/master/bin/cli.ts#L70C3-L102C5 I can extract this to the function, if it works for you
I would prefer the entire runForPluginJson
function be exported. Or else please include the call to renderTemplate
, since that's not exported either.
I'm working on a framework for building chrome extensions, WXT, that includes this plugin when running
wxt build --analyze
. Chrome extensions contain multiple bulid steps, so each step outputs a separate stats JSON file, and then therollup-plugin-visualizer
CLI is used to combine them.However, this doesn't work out of the box when using
pnpm
andshamefully-hoist=true
(the default). This is because the binary isn't included innode_modules/.bin
, so it's not in the path. Instead, the binary is stored atnode_modules/wxt/node_modules/.bin/rollup-plugin-visualizer
. There might be a similar problem for yarn PnP, haven't tested it.I could add
node_modules/wxt/node_modules/.bin
to the path while callingspawn("rollup-plugin-visualizer")
(and I likely will do that as a workaround for now), but I'd also like to just call a function instead of spawning a new process, something like this:After looking at the code, I think this is a pretty simple change. Just involves exporting
runForPluginJson
fromplugin/index.ts
, or another entrypoint if that doesn't make sense.https://github.com/btd/rollup-plugin-visualizer/blob/dec839823db43af6b34d54779ed1db0486fe4e1c/bin/cli.ts#L56
If that sounds OK, I'm willing to work on this and open a PR!