browserify / browserify/common-shakeify

encountering a spread operator results in fatal error

Open
#38 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
103
Forks
8
PR merge metrics
No merged PRs in 30d

Description

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.

```js
// foo.js
const bar = require('./bar')
console.log(bar)

// bar.js
const baz = require('./baz')
module.exports = { ...baz }

// baz.js
module.exports = { foo: 3 }
```

```bash
# 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.