Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 1. Initialize your project using npm init and create a directory called src -- creates a package.json file in the root directory
- To install babel dependencies
- 2. In terminal window, type this to install one of the two required Babel packages : npm install babel-cli
- 3. Then type this to install the second of two required Babel packages: npm install babel-preset-env
- 4. Type touch .babelrc to create file inside your project and add the following code inside it:
- {
- "presets": ["env"]
- }
- 5. Add the following script to your scripts object in package.json:
- "build": "babel src -d lib"
- 6. Lastly, type this to see the newly created lib directory : npm run build -- to transpile your code from your src to lib directories.
- */
- //Original ES6 code
- var pasta = "Spaghetti"; // ES5 syntax
- const meat = "Pancetta"; // ES6 syntax
- let sauce = "Eggs and cheese"; // ES6 syntax
- // Template literals, like the one below, were introduced in ES6
- const carbonara = `You can make carbonara with ${pasta}, ${meat}, and a sauce made with ${sauce}.`;
- =======================================================================================================================
- //Transpiled ES5 code
- "use strict";
- var pasta = "Spaghetti"; // ES5 syntax
- var meat = "Pancetta";
- var sauce = "Eggs and cheese";
- // Template literals, like the one below, were introduced in ES6
- var carbonara = "You can make carbonara with " + pasta + ", " + meat + ", and a sauce made with " + sauce + ".";
Add Comment
Please, Sign In to add comment