0

I am trying to use Babel 6 to transplie ES2015 javascript files. Two most simple cases, 1 file and files from a directory.

install babel-cli and babel-preset-es2015, create a .babelrc. use command babel app.js --out-file appout.js. complete, no problem.

then I try to transplie two files in a directory, one of them use export feature.

var shout = function(s){
    return s.toUpperCase();
}

export shout;

then when I use cli to tranpile, babel src --out-dir lib it returns with an error,

unexpected token at export shout;
                                                     ^

don't really understand what is wrong here.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Maxi Wu
  • 1,274
  • 3
  • 20
  • 38

1 Answers1

0

Mjh's answer is correct:

Instead of:

export shout;

it should be:

export {shout};

or

export default shout;
Hitmands
  • 13,491
  • 4
  • 34
  • 69
Maxi Wu
  • 1,274
  • 3
  • 20
  • 38