browserify / common-shakeify

browserify tree shaking plugin using `common-shake`
https://www.npmjs.com/package/common-shakeify
MIT License
105 stars 18 forks source link

Fix sequential expressions #43

Closed tornqvist closed 2 years ago

tornqvist commented 2 years ago

Handle sequential expressions with values other than functions and class expressions.

Input

exports.a={},exports.b='hello'

Output

// Before
/* common-shake removed: exports.a = */ {},/* common-shake removed: exports.b = */ 'hello'

// After
/* common-shake removed: exports.a = */ void {},/* common-shake removed: exports.b = */ void 'hello'
goto-bus-stop commented 2 years ago

📦 1.1.2 thanks 😊

tornqvist commented 2 years ago

I just noticed that this change completely breaks split-require. Only module.exports = whatever work but all named exports are dropped. I'm currently trying to create a test case to recreate it but am struggling as the test/comment/app.js does just the thing that is now broken, only that it's using require and not split-require.

I'm not fully familiar with the inner workings of split-require and even less so in combination with common-shakeify, @goto-bus-stop, can you see why this change would break split-require?