Issue 1:
I have encountered something that's very likely a bug.

In the same module, the transpiled code for export ... from ... appears before the transpiled code for import ... in the output.

This scenario has already been asked here - unfortunately without an answer.

I think this is a bug because the 2 following snippets should be equivalent:

import foo from 'foo';
export { default as bar } from 'bar';

import foo from 'foo';
import bar from 'bar';
export { bar }

Input Code

import foo from 'foo';
export { default as bar } from 'bar';

see the REPL

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

Part of my package.json:

{
"devDependencies": {
"babel-eslint": "^7.2.3",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-react-native": "^4.0.0",
"eslint": "^4.6.1",
"eslint-plugin-react": "^7.3.0",
"react-test-renderer": "16.0.0-alpha.12"
},
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
},
"dependencies": {
"immutable": "^3.8.1",
"prop-types": "^15.5.10",
"react": "16.0.0-alpha.12",
"react-native": "0.47",
"react-navigation": "^1.0.0-beta.11",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-promise": "^0.5.3",
"redux-thunk": "^2.2.0"
}
}

Expected Behavior

The behavior should be equivalent to

import foo from 'foo';
import bar from 'bar';
export { bar }

Current Behavior

Currently the code gets executed as if it was written like this:

export { default as bar } from 'bar';
import foo from 'foo';

'bar' is required before 'foo' no matter what exactly is put between export and from (e.g. the problem also occurs for export * from ...).

Context

I am exporting multiple moddules from an index.js file.

All exports depend on some code that must have been run.

import "./this_code_must_be_run_before_the_exports"
export * from "./first"
export * from "./second"

Your Environment

I am using babel with React Native.

software
version(s)

Babel
latest (https://babeljs.io/repl/)

node
8.7.0

npm
5.4.2

Operating System
macOS 10.12.6

Issue 2:
Input Code

import "babel-polyfill";

export {default as foo} from "./foo"; //Foo depends on the babel-polyfill

Example in REPL

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

{
"presets": ["es-2015"]
}

Expected Behavior

The contents of the foo module should be exported on as foo on the current module

Current Behavior

Fails with ReferenceError: regeneratorRuntime is not defined

The following code is generated by babel:

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.foo = undefined;

var _foo = require("./foo");

Object.defineProperty(exports, "foo", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_foo).default;
}
});

require("babel-polyfill");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

The require("./foo") call gets hoisted above the require("babel-polyfill") call, and so regeneratorRuntime is not defined when the contents of the foo module runs. I found this issue with babel-polyfill specifically, but it could manifest with any import that performs a side-effect, followed by an export ... from with a module that relies on that side-effect.

Possible Solution

It seems like the the export ... from should cause the module to be imported in the same order that it would be imported if the export statement were replaced with an import statement.

Your Environment

software
version

Babel
6.4.14

node
4.4.4

npm
3.9.0