Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encountering a spread operator results in fatal error #38

Open
jgravois opened this issue Sep 22, 2021 · 0 comments
Open

encountering a spread operator results in fatal error #38

jgravois opened this issue Sep 22, 2021 · 0 comments

Comments

@jgravois
Copy link

jgravois commented Sep 22, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant