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

index.js with export default as returns undefined #8987

Open
BorisTB opened this Issue Nov 7, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@BorisTB

BorisTB commented Nov 7, 2018

Bug Report

Current Behavior
File structure:

components
│__ComponentA
|  └ index.js
│__ComponentB
|  └ index.js
│__ComponentC
|  └ index.js
└ index.js

components/index.js

export { default as ComponentA } from './ComponentA'
export { default as ComponentB } from './ComponentB'
export { default as ComponentC } from './ComponentC'

components/ComponentA/index.js
import { ComponentC } from 'Components' // Components is webpack alias to components folder

So the problem is when I import ComponentA in ComponentB with destructuring (import { ComponentA } from 'Components'), it's undefined. Behaviour is similar to circular dependency, but I don't think this should be treated as circular dep. Other imports works great, until I don't import other components in them.

Expected behavior/code
The component should be defined when imported with destructuring

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

{
  "presets": [
    "@babel/preset-env",
    ["react-app", {
      "flow": true,
      "typescript": false
    }]
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-transform-runtime",
    "inline-dotenv",
    "relay"
  ]
}

Environment

  • Babel version(s): 7.1.0
  • Node/npm version: Node v11.1.0 / npm v6.4.1
  • OS: OSX 10.14
  • Monorepo no
  • How you are using Babel: loader
@babel-bot

This comment has been minimized.

Collaborator

babel-bot commented Nov 7, 2018

Hey @BorisTB! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo

This comment has been minimized.

Member

nicolo-ribaudo commented Nov 7, 2018

If you are using babel-loader, Babel isn't traspiling those exports since they are handled by webpack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment