thepassle / barrel-begone

50 stars 1 forks source link

Use rollup resolution plugin to gather imports #1

Closed kettanaito closed 5 months ago

kettanaito commented 5 months ago

I propose we write a simple Rollup plugin that hooks into a module resolution phase. This will allow us to flush any modules that a given entrypoint imports, relying on Rollup doing the heavy lifting for us.

thepassle commented 5 months ago

I've added a comment in the code for this, but yeah, I agree. I currently implemented this based on some code I already had lying around in a different project, but we should indeed just replace that with Rollup and do the heavy lifting for us.

With that comes some benefits, because we can also analyze modules to see if they're barrel files as well, and because we have rollups module graph information, we can point out which chain of imports is leading to the barrel file, like for example: foo -> bar.js -> baz.js -> barrel-file.js