Skip to content

Issue with transform-runtime and defualt export using computed property names #7114

@sqal

Description

@sqal

Choose one: is this a bug report or feature request?

Input Code

// actions.js
const types = {
  FOO: 'FOO',
  BAR: 'BAR',
}

export default {
  [types.FOO]() {},
  [types.BAR]() {},
}

// index.js
import actions from './actions'

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

// package.json
"devDependencies": {
  "@babel/core": "^7.0.0-beta.36",
  "@babel/plugin-transform-runtime": "^7.0.0-beta.36",
  "@babel/preset-env": "^7.0.0-beta.36",
  "@babel/runtime": "^7.0.0-beta.36",
  "babel-loader": "^8.0.0-beta.0",
  "webpack": "^3.10.0"
}

// .babelrc
{
  "presets": [
    ["@babel/env", {
      "modules": false,
      "useBuiltIns": "usage"
    }]
  ],
  "plugins": [
    "@babel/transform-runtime"
  ]
}

You can clone the repo with reproduction: https://github.com/sqal/babel-7.0.0-beta.36-bug

Expected Behavior

I expect default import in index.js (actions) to be present

Current Behavior

Default import in index.js is not present. I am getting an error instead:

"export 'default' (imported as 'actions') was not found in './actions'

This is somehow related to transform-runtime plugin along with using computed property names in default export. When I disable transform-runtime, everything works properly. My current workaround for this:

const actions = { ... }

export default actions;

Your Environment

software version(s)
Babel 7.0.0-beta.36
node 8.5.0
npm 5.5.1
Operating System Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions