我正在使用 babel 转译 ES7 js 代码,一切都像开发/登台的魅力。在应用程序内部,我严重依赖ES7 的async/await特性。我的入口文件如下所示:
'use strict';
require("babel-polyfill");
require("babel-core/register");
module.exports = require('./app/server').default();
我不确定是否有必要为生产环境保留babel-polyfill和babel-core/register模块,因为我在部署之前使用 babel-cli 转译了所有内容。我认为即使我删除它们并使入口文件看起来像这样,它也必须正确工作:
import server from './app/server';
server();
但是,如果这样做,我会在启动应用程序时遇到下一个异常:
ReferenceError: regeneratorRuntime is not defined
at C:\Users\Username\Documents\some-service\lib\app\repositories\someRepository.js:18:32
at Object.<anonymous> (C:\Users\Username\Documents\some-service\lib\app\repositories\someRepository.js:40:2)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Users\Username\Documents\some-service\lib\app\controllers\someController.js:15:27)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Users\Username\Documents\some-service\lib\app\server.js:15:26)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
在生产环境中引用babel-polyfill和babel-core/register包是否正常?