question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues while re-exporting

See original GitHub issue

src\index.js renames exports

export * from './data.js';
export * as File from './FileComponent';
export { default as Folder } from './FolderComponent';
export { Drive as default } from './DriveComponent';

.babelrc typical esnext ReactJS setup

{
    "presets": [
        "es2015-loose",
        "stage-0",
        "react"
    ],
    "plugins": [
        ["transform-runtime"],
        ["transform-decorators-legacy"],
        ["transform-export-extensions"]
    ]
}

The error:

ERROR in ./src/index.js
Module parse failed: \node_modules\react-hot-loader\index.js!\node_modules\babel-loader\index.js?{"presets":["es2015-loose","stage-0","react"],"plugins":[["transform-runtime"],["transform-decorators-legacy"],["transform-export-extensions"]],"cacheDirectory":"\\.cache\\babel-loader"}!\src\index.js 'import' and 'export' may only appear at the top level (5:0)
You may need an appropriate loader to handle this file type.
  SyntaxError: 'import' and 'export' may only appear at the top level (5:0)
  • Removing react-hot from loaders list solves the issue but forces refresh which throws away state.
  • Removing transform-runtime also solves the issue, but breaks IE11 due to ES6

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, May 23, 2016

Ah, sorry, RHL 1.x won’t work with Webpack 2 ES modules. Please switch to RHL 3.x beta. https://github.com/gaearon/react-hot-boilerplate/pull/61

0reactions
Silviu-Mariancommented, May 17, 2016

Looks like we get more output with webpack2 and es2015-loose-native-modules.

\index.js 'import' and 'export' may only appear at the top level (3:0)
You may need an appropriate loader to handle this file type.
| /* REACT HOT LOADER */ if (module.hot) { (function () { var ReactHotAPI = require("\\node_modules\\react-hot-api\\modules\\index.js"), RootInstanceProvider = require("\\node_modules\\react-hot-loader\\RootInstanceProvider.js"), ReactMount = require("react/lib/ReactMount"), React = require("react"); module.makeHot = module.hot.data ? module.hot.data.makeHot : ReactHotAPI(function () { return RootInstanceProvider.getRootInstances(ReactMount); }, React); })(); } try { (function () {
|
| import React from 'react';
| import ReactDOM from 'react-dom';
| import { Provider } from 'react-redux';
 @ multi Documentation
Read more comments on GitHub >

github_iconTop Results From Across the Web

3 common risks to guard against when exporting
Buy credit insurance to protect against a range of risks including customer bankruptcy or non-payment, contract cancellation, issues with currency conversion or ...
Read more >
Challenges when Exporting
Required Documents when Exporting: ... Failure to supply export documents in a timely manner results in delayed shipments and storage. The following export ......
Read more >
Top 10 Issues for Small Business Exporters and How to ...
Here 10 issues for small business exporters and links to resources to help overcome them: Is your product export ready?
Read more >
Fix export issues in Premiere Pro
Fix common export issues in 7 simple steps · Try exporting your project to a different file format. · Exporting to H. ·...
Read more >
Challenges of exporting | nibusinessinfo.co.uk
Understanding what export customers want and how the market operates is vital. · You need to cope with extra logistical problems, contractual issues...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found