Skip to content

Duplicate declaration error with Babel 7, React preset and regenerator transform plugin. #8525

@sfarthin

Description

@sfarthin

Bug Report

Current Behavior

$ babel ./test.js --no-babelrc --presets=module:@babel/preset-react --plugins=module:@babel/plugin-transform-regenerator
TypeError: /Users/stevefar/sc/labeltron/test.js: Duplicate declaration "newSessionId" (This is an error on an internal node. Probably an internal error.)
    at File.buildCodeFrameError (/Users/stevefar/sc/labeltron/node_modules/@babel/core/lib/transformation/file/file.js:259:12)
    at Scope.checkBlockScopedCollisions (/Users/stevefar/sc/labeltron/node_modules/@babel/traverse/lib/scope/index.js:347:22)
    at Scope.registerBinding (/Users/stevefar/sc/labeltron/node_modules/@babel/traverse/lib/scope/index.js:504:16)
    at Scope.registerDeclaration (/Users/stevefar/sc/labeltron/node_modules/@babel/traverse/lib/scope/index.js:444:14)
    at Object.Declaration (/Users/stevefar/sc/labeltron/node_modules/@babel/traverse/lib/scope/index.js:125:12)
    at NodePath._call (/Users/stevefar/sc/labeltron/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/Users/stevefar/sc/labeltron/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/stevefar/sc/labeltron/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (/Users/stevefar/sc/labeltron/node_modules/@babel/traverse/lib/context.js:118:16)
    at TraversalContext.visitMultiple (/Users/stevefar/sc/labeltron/node_modules/@babel/traverse/lib/context.js:85:17)

Input Code
The is the contents of test.js

<Component>
  {() => {
    const saveSession = async () => {
      const newSessionId = await someAsyncFunc();
    };
  }}
</Component>;

Expected behavior/code
I get a runtime error running babel, I expected it to create the transpiled code.

Babel Configuration (.babelrc, package.json, cli command)

babel ./test.js --no-babelrc --presets=module:@babel/preset-react --plugins=module:@babel/plugin-transform-regenerator

Environment

  • Babel version(s): 7.0.0-rc.2 (@babel/core 7.0.0-rc.2)
  • Node/npm version: Node 8/npm 5
  • OS: OSX 10.13.6
  • Monorepo no
  • How you are using Babel: cli

Additional context/Screenshots
If I do each transform as a individual step it works:

$ cat ./test.js | babel --no-babelrc --presets=module:@babel/preset-react | babel --no-babelrc --plugins=module:@babel/plugin-transform-regenerator

Its not clear why this would work, but including both the preset and plugin would not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions