1babel src\app.js --out-file=public\scripts\app.js --presets=env,react --watch
1<!-- v6 <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script> -->
2<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
3<!-- Your custom script here -->
4<script type="text/babel">
1// yarn add @babel/cli @babel/core @babel/node @babel/plugin-transform-runtime @babel/preset-env --dev
2// yarn add @babel/runtime
3"dependencies": {
4 "@babel/runtime": "^7.15.4" //a package to be installed production dependency to avoid duplication across your compiled output.
5 },
6 "devDependencies": {
7 "@babel/cli": "^7.15.7", // A built-in CLI which can be used to compile files from the command line/terminal.
8 "@babel/core": "^7.15.5", // a fundamental package to run any babel setup/configuration
9 "@babel/node": "^7.15.4", //babel-node is a CLI that works the same as the Node.js CLI, with the added benefit of compiling with Babel presets and plugins before running it.
10 "@babel/plugin-transform-runtime": "^7.15.0", // A plugin that enables the re-use of Babel's injected helper code to save on code size.
11 "@babel/preset-env": "^7.15.6" // is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, browser polyfills) are needed by your target environment(s).
12 }
13
14// package.json
15"scripts": {
16 "start": "yarn run build && node ./build/src/app.js",
17 "start:dev": "babel-node ./src/app.js",
18 "clean": "rm -rf build && mkdir build",
19 "build-babel": "babel ./src -d ./build/src",
20 "build": "yarn run clean && yarn run build-babel"
21}
22
23// .babelrc
24{
25 "presets": ["@babel/preset-env"],
26 "plugins": [
27 ["@babel/plugin-transform-runtime"]
28 ]
29}
30