common-shakeify icon indicating copy to clipboard operation
common-shakeify copied to clipboard

shakes out functions that I used

Open Zae opened this issue 6 years ago • 6 comments

I'm not sure if this plugin in production ready yet, but it seems that it removed functions that I'm definitely using.

Using import to get the modules, but running babel as a browserify transform, so that should rewrite everything to require.

seems that most of the incorrectly removed functions are from the crypto-browserify package.

Zae avatar Dec 29 '17 00:12 Zae

Some of Babel's module transform output may be tripping up common-shake. Could you share an example that shows it failing?

goto-bus-stop avatar Jan 11 '18 08:01 goto-bus-stop

Hi - I'm running into this issue too - I threw together a project that reproduces the issue here: https://github.com/retail-robot/common-shakeify-issue-12-repro

You should be able to clone it and just npm install + npm run build

retail-robot avatar Apr 20 '18 17:04 retail-robot

Thanks @retail-robot! this is really hard to make work correctly in all situations, but that particular case should not be too difficult to support.

goto-bus-stop avatar Apr 20 '18 17:04 goto-bus-stop

Hey,

Sorry I wasn't able to provide any code. I'll try to test the fix on my usecase if I can!

Op vr 20 apr. 2018 19:41 schreef Renée Kooi [email protected]:

Thanks @retail-robot https://github.com/retail-robot! this is really hard to make work correctly in all situations, but that particular case should not be too difficult to support.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/browserify/common-shakeify/issues/12#issuecomment-383170318, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF3fs7gYvru8sLvV8rPWp_1vVZLQE2Yks5tqh21gaJpZM4ROwoG .

Zae avatar Apr 20 '18 17:04 Zae

np, @goto-bus-stop - thanks!

retail-robot avatar Apr 20 '18 17:04 retail-robot

hi! we just ran into this too with the sbd library.

it is stripping out /lib/Match.js:isCaptialized, even though that function is called via this within the code.

09:42:00 ~/src/sbd:master
↳ npx browserify -p common-shakeify lib/tokenizer.js > shake.js
09:42:07 ~/src/sbd:master
↳ npx browserify lib/tokenizer.js > no-shake.js
09:45:03 ~/src/sbd:master
↳ grep isCapitalized shake.js
/* common-shake removed: exports.isCapitalized = */ void function(str) {
    return this.isCapitalized(str) || /``|"|'/.test(str.substring(0,2));
    return this.isCapitalized(str);
        if (wordCount < 5 && words[0].length < 6 && this.isCapitalized(words[0])) {

toddself avatar Apr 26 '18 16:04 toddself