- Open your command-line application and navigate to the directory containing the 02-creating-client-bundles package.
- Start the Python HTTP server.
- Update the main.js file to use the arrow function syntax:
import { atlas, saturnV } from './rockets/index.js'
export function main () {
const rockets = [saturnV, atlas];
rockets.map((rocket) => rocket.launch() );
}
- Install Babel, the preset-es2015, and the associated webpack loader:
npm install --save-dev babel-cli babel-preset-es2015 babel-loader
- Create a Babel configuration file named .babelrc:
// .babelrc
{
"presets": ["es2015"]
}
- Configure webpack to use Babel for transpiling new language features:
const path = require('path');
module.exports = {
entry: ['babel-polyfill', './index.js'],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname)
}, module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
}
};
- Add a webpack build command to the script section of the package.json file:
{
/* package.json configuration */
"scripts": {
"bundle": "webpack --config webpack.config.js",
}
/* remaining properties */
}
- Run the webpack build:
npm run bundle
- Now, open a browser and open the Developer Console while visiting the URL:
http://localhost:8000/.
- You should see the code running correctly:
