安装
yarn add -D @babel/cli @babel/node
编译entry-server.js
yarn babel ./src/ssr/entry-server.js --presets=@babel/preset-env
var hello = () => {
return "Hello World";
};
console.log(hello());
结果
"use strict";
require("core-js/modules/es6.array.iterator");
require("core-js/modules/es6.promise");
require("core-js/modules/es7.promise.finally");
var hello = function hello() {
return "Hello World";
};
console.log(hello());
Done in 2.28s.
编译并运行entry-server.js
yarn babel-node ./src/ssr/entry-server.js --presets=@babel/preset-env
var hello = () => {
return "Hello World";
};
console.log(hello());
结果
Hello World
Done in 2.90s.