luwes / rollup-plugin-size

🍣 Track compressed Rollup asset sizes over time.
65 stars 4 forks source link

Share core functionality with size-plugin? #1

Closed developit closed 5 years ago

developit commented 5 years ago

Hi @luwes!

I'm wondering if we should figure out a way to share the core size calculation and display logic between the two plugins so they can receive the same updates (in particular, GoogleChromeLabs/size-plugin#15). Thoughts?

luwes commented 5 years ago

That would be super neat! I'm all for that.

I mostly used the outputSizes and getSizes functions, removed reverseTemplate I thought this was specific to Webpack, though the hash logic might have to be put back. I didn't try this yet with code splitting only with multiple bundles builds.

For this the default columnWidth was added because multiple bundles wouldn't know about each other beforehand I think.

One bit in outputSizes changed from assets[name].source() to assets[name].code.

Let me know if I can be of help for the core functionality. Would they be exposed from size-plugin or another isolated pkg?

luwes commented 5 years ago

Would love that history functionality 😃 We actually NEED that at work, take my size graph to meetings haha

developit commented 5 years ago

Just an update from me, I still want this but haven't had time to hack on anything.

kuldeepkeshwar commented 5 years ago

@developit @luwes I gave it a try size-plugin-core, please review

PRs

developit commented 5 years ago

Might be nice to expose a method that lets folks populate sizesBefore before calling outputSizes. Also maybe make it a class?

kuldeepkeshwar commented 5 years ago

@developit / @luwes I have updated the code. Added option to override any step performed by size-plugin-core.

e.g

const sizesBefore = await getPreviousSizes(outputPath) ;
const sizes = await getSizes(assets); 
const files = await getDiff(sizesBefore,sizes); // calculate the diff
const output = await printSizes(files); // template output message
await uploadSizes(files); // upload stats
return output;