title: Trying to use import/export in ES6 (with babel compile)
body: <p>Here are the files for my app which uses babel to compile the ES6 in <code>main.js</code> to ES5 in <code>main.bundle.js</code> </p>
  
  <p><a href="https://i.stack.imgur.com/A4mhJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/A4mhJ.png" alt="enter image description here"></a></p>
  
  <p>Here is my <code>babel.rc</code> file (hidden):</p>
  
  <pre><code>{
      "presets": ["@babel/preset-env"]
  }
  </code></pre>
  
  <p>Here is my <code>package.json</code> file with all my node modules (devDependencies):</p>
  
  <pre><code>{
    "name": "es6-tutorial",
    "version": "1.0.0",
    "description": "ES6 tutorial",
    "main": "index.js",
    "scripts": {
      "babel": "babel js/main.js -o build/main.bundle.js",
      "start": "http-server",
      "watch": "babel js/main.js -o build/main.bundle.js --watch"
    },
    "author": "me",
    "license": "ISC",
    "devDependencies": {
      "@babel/preset-env": "^7.2.0",
      "babel-cli": "^6.26.0",
      "babel-core": "^6.26.3",
      "babel-preset-es2015": "^6.24.1",
      "http-server": "^0.11.1"
    }
  }
  </code></pre>
  
  <p>Right now to start the compile from ES6 to ES5 I navigate (<code>cd</code>) to the root of this directory and I set up a watch to compile automatically (<code>npm run watch</code>)</p>
  
  <p>This works fine except now I also have functions in <code>myFunctions.js</code> that I want to export and import into <code>main.js</code></p>
  
  <p>When I add this export/import I notice that the compiled file, <code>main.bundle.js</code>, adds this: </p>
  
  <pre><code>`var _myFunctions = require('myFunctions.js');`
  </code></pre>
  
  <p>Then when I go to run the app I get an error in the console:</p>
  
  <pre><code>`Uncaught ReferenceError: require is not defined
  at main.bundle.js:9`
  </code></pre>
  
  <p>After researching this, I think I need to add some sort of plugin for Babel : <a href="https://babeljs.io/docs/en/plugins#modules" rel="noreferrer">https://babeljs.io/docs/en/plugins#modules</a> to handle the export/import (is that right?) but I'm not sure which one I should use and I tried a few but I cannot get any to work after the npm install. </p>
  
  <p>Also, I understand that I do NOT need to add the <code>require.js</code> library right?</p>