developit / microbundle

📦 Zero-configuration bundler for tiny modules.
https://npm.im/microbundle
MIT License
8.07k stars 363 forks source link

[Bug] build failed on destructing rest parameters #1039

Open zhanghaobin opened 1 year ago

zhanghaobin commented 1 year ago

Description

Build failed when destructing rest parameters

Version

microbundle@^0.15.1

Reproduce steps

  1. input file
    
    // test.ts

export function A(...[a, b]: any[]) {}


2. build
`microbundle -i test.ts -o test.js`

3. build failed

(babel plugin) TypeError: ~/node-demo/test.ts: Cannot read properties of undefined (reading 'referencePaths') TypeError: ~/node-demo/test.ts: Cannot read properties of undefined (reading 'referencePaths') at Map.RestElement (~/node-demo/node_modules/microbundle/dist/cli.js:134:19) at NodePath._call (~/node-demo/node_modules/@babel/traverse/lib/path/context.js:45:20) at NodePath.call (~/node-demo/node_modules/@babel/traverse/lib/path/context.js:35:17) at NodePath.visit (~/node-demo/node_modules/@babel/traverse/lib/path/context.js:80:31) at TraversalContext.visitQueue (~/node-demo/node_modules/@babel/traverse/lib/context.js:86:16) at TraversalContext.visitMultiple (~/node-demo/node_modules/@babel/traverse/lib/context.js:61:17) at TraversalContext.visit (~/node-demo/node_modules/@babel/traverse/lib/context.js:107:19) at traverseNode (~/node-demo/node_modules/@babel/traverse/lib/traverse-node.js:18:17) at NodePath.visit (~/node-demo/node_modules/@babel/traverse/lib/path/context.js:86:52) at TraversalContext.visitQueue (~/node-demo/node_modules/@babel/traverse/lib/context.js:86:16) at TraversalContext.visitSingle (~/node-demo/node_modules/@babel/traverse/lib/context.js:65:19) at TraversalContext.visit (~/node-demo/node_modules/@babel/traverse/lib/context.js:109:19) at traverseNode (~/node-demo/node_modules/@babel/traverse/lib/traverse-node.js:18:17) at NodePath.visit (~/node-demo/node_modules/@babel/traverse/lib/path/context.js:86:52) at TraversalContext.visitQueue (~/node-demo/node_modules/@babel/traverse/lib/context.js:86:16) at TraversalContext.visitMultiple (~/node-demo/node_modules/@babel/traverse/lib/context.js:61:17) at TraversalContext.visit (~/node-demo/node_modules/@babel/traverse/lib/context.js:107:19) at traverseNode (~/node-demo/node_modules/@babel/traverse/lib/traverse-node.js:18:17) at traverse (~/node-demo/node_modules/@babel/traverse/lib/index.js:49:34) at NodePath.traverse (~/node-demo/node_modules/@babel/traverse/lib/path/index.js:108:24) at PluginPass.Program (~/node-demo/node_modules/microbundle/dist/cli.js:175:14) at newFn (~/node-demo/node_modules/@babel/traverse/lib/visitors.js:149:21) at NodePath._call (~/node-demo/node_modules/@babel/traverse/lib/path/context.js:45:20) at NodePath.call (~/node-demo/node_modules/@babel/traverse/lib/path/context.js:35:17) at NodePath.visit (~/node-demo/node_modules/@babel/traverse/lib/path/context.js:80:31) at TraversalContext.visitQueue (~/node-demo/node_modules/@babel/traverse/lib/context.js:86:16) at TraversalContext.visitSingle (~/node-demo/node_modules/@babel/traverse/lib/context.js:65:19) at TraversalContext.visit (~/node-demo/node_modules/@babel/traverse/lib/context.js:109:19) at traverseNode (~/node-demo/node_modules/@babel/traverse/lib/traverse-node.js:18:17) at traverse (~/node-demo/node_modules/@babel/traverse/lib/index.js:49:34) at transformFile (~/node-demo/node_modules/@babel/core/lib/transformation/index.js:81:29) at transformFile.next () at run (~/node-demo/node_modules/@babel/core/lib/transformation/index.js:24:12) at run.next () at transform (~/node-demo/node_modules/@babel/core/lib/transform.js:22:41) at transform.next () at step (~/node-demo/node_modules/gensync/index.js:261:32) at ~/node-demo/node_modules/gensync/index.js:273:13 at async.call.result.err.err (~/node-demo/node_modules/gensync/index.js:223:11)

cemrehancavdar commented 1 year ago

I had exact error, and saw this. Thanks to point it