common-shakeify
common-shakeify copied to clipboard
encountering a spread operator results in fatal error
hello and thank you for all your great open source work! 👋
here's a simplified repro case for an error i'm running into in the wild.
// foo.js
const bar = require('./bar')
console.log(bar)
// bar.js
const baz = require('./baz')
module.exports = { ...baz }
// baz.js
module.exports = { foo: 3 }
# Node 14
% browserify foo.js -p [ common-shakeify -v ] -o bundle.js
/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/lib/shake/analyzer.js:367
(prop.key.type !== 'Literal' && prop.key.type !== 'Identifier')) {
^
TypeError: Cannot read property 'type' of undefined
at Analyzer.siftModuleExports (/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/lib/shake/analyzer.js:367:19)
at Analyzer.siftAssignment (/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/lib/shake/analyzer.js:329:10)
at AssignmentExpression (/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/lib/shake/analyzer.js:256:40)
at c (/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/lib/shake/walk.js:19:16)
at Object.skipThrough (/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/node_modules/acorn-walk/dist/walk.js:186:39)
at c (/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/lib/shake/walk.js:20:15)
at Object.base.ExpressionStatement.base.ParenthesizedExpression (/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/node_modules/acorn-walk/dist/walk.js:204:37)
at c (/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/lib/shake/walk.js:20:15)
at Object.skipThrough (/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/node_modules/acorn-walk/dist/walk.js:186:39)
at c (/Users/john/code/web/node_modules/@goto-bus-stop/common-shake/lib/shake/walk.js:20:15)
right now i'm using babelify and working around this issue by transpiling for browsers that don't support spreading, but that's less than ideal.
i'd log an issue in common-shake, but i'm at a loss for what's going on under the hood.