2

저는 ES7 코드를 번역하기 위해 바벨을 사용하고 있습니다. 모든 것이 dev/staging의 매력처럼 작동합니다. 애플리케이션 내부에서 나는 비동기식/ ES7의 기능에 크게 의존한다. 내 입력 파일은 다음과 같다 :생산 입력 파일에 babel-polyfill 사용

'use strict'; 
require("babel-polyfill"); 
require("babel-core/register"); 
module.exports = require('./app/server').default(); 

나는 내가 babel- 사용하여 모든 transpile 이후 생산 환경 모듈/바벨 - polyfill바벨 코어를 유지 등록 할 필요가 있는지의 여부를 확실하지 않다 배포 전 cli. 나는이 같은 항목 파일보기 뭔가를 사람들을 제거 할 경우 제대로에도 일을해야 가정

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) 

인가 이렇게하면 응용 프로그램을 시작하는 동안

import server from './app/server'; 
server(); 

그러나, 나는 다음 예외를 얻었다 그 표준에 대한 참조가 babel-polyfillbabel-core/register 패키지가 프로덕션 환경에 있습니까?

+0

polyfill은 항상 필요합니다. – Bergi

+0

@Bergi, 그게 내가 생각하는 것. 내가 원한 것은 이것을 말하는 문서에 대한 링크입니다. 이것은 누군가에게 명백 할 수도 있지만 프로덕션 환경 사용에 대한 언급은 발견하지 못했습니다. – Ivan

+0

'async/await'는 ES7 (ES2016)의 일부가 아닙니다. 그것은 올해의 릴리스 (ES2017)의 일부가 될 것입니다. –

답변

2

개발 중에 이러한 모듈 (babel-polyfill 및 babel-core/register)을 사용하는 경우 프로덕션 파일에도 필요합니다. 증산 공정은 Object.assign 또는 Promise과 같은 폴리 필을 추가하지 않습니다.

docs page for the babel polyfills은 개발자 및 제작에 다른 라이브러리를 포함해야한다고 명시 적으로 말하지 않습니다. 하지만 이 원하는 기능에 대해 특정 폴리필을 포함해야한다고 말하면 어떤 환경에서도 이 필요하다고 말하는 것 같습니다.

짧은 답변 : 바벨에 의한 증발은 자체적으로 폴리 필을 추가하지 않으므로 모든 환경에 폴리 필을 포함시키는 것이 표준입니다.

+1

답장을 보내 주셔서 감사합니다. 아무도 이의가없는 것 같아 답변으로 표시됩니다. – Ivan