2017-11-14 19 views
2

TypeScript을 사용하고 grunt을 사용하여 AMD 모듈의 ES5로 파일을 컴파일하는 중입니다.TypeScript AMD가 브라우저에서 단일 파일로

export const CONFIG = { 
    app  : 'MyApp' 
} 

앱은 결국 실행해야하는 주요 스크립트 내 빌드 출력은 다음과 같습니다 :

import {CONFIG} from './config'; 
console.log(CONFIG.app) 

그리고 config.ts를 예를 들면 다음과 같습니다

나는 app.ts

define("config", ["require", "exports"], function (require, exports) { 
    "use strict"; 
    Object.defineProperty(exports, "__esModule", { value: true }); 
    exports.CONFIG = { 
     app: 'MyApp' 
    }; 
}); 
define("main", ["require", "exports", "config"], function (require, exports, config_1) { 
    "use strict"; 
    Object.defineProperty(exports, "__esModule", { value: true }); 
    console.log(config_1.CONFIG.app); 
}); 

내가 형제에게 달리게 할 수있게하려면 어떻게해야합니까? wser?

require.js를 포함 시키려고했지만 시도하지 않았습니다.

단일 파일으로 으로 제공 될 대규모 프로젝트이므로 단일 파일로 컴파일해야하며 모든 구성을 gruntfile.js에 있어야합니다.

또한 제 3 자 라이브러리가 모든 파일을 하나의 파일로 컴파일하지 않아도되는보다 효율적인 방법이 있습니까?

답변