我正在使用
打字脚本
并使用AMD模块将其编译成一个文件到ES5
咕哝
.
例如,我有
app.ts
import {CONFIG} from './config';
console.log(CONFIG.app)
和
config.ts
:
export const CONFIG = {
app : 'MyApp'
}
App是最终需要执行的主脚本,我的构建输出如下:
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);
});
我该如何让它在浏览器上运行?
我试着把需求包括在内。但js并没有成功做到这一点。
我需要把它编译成一个文件,所有的配置都需要在gruntfile上。js因为这将是一个大型项目,将作为
单个文件
.
还有,有没有更有效的方法不需要第三方库将其编译成一个文件?