如何使用webpack和babel编译我的代码,以便导出的函数在全局范围内可用.
例如:
export function test(){console.log('test')}
Run Code Online (Sandbox Code Playgroud)
应该在window.test().
当我跑步时,babel -d我得到了我所期望的:
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.test = test;
function test() {
console.log('test');
}
Run Code Online (Sandbox Code Playgroud)
但webpack输出如下所示:
!function(e) {
function t(r) {
if (o[r])return o[r].exports;
var n = o[r] = {exports: {}, id: r, loaded: !1};
return e[r].call(n.exports, n, n.exports, t), n.loaded = !0, n.exports
}
var o = {};
return t.m = e, t.c = o, t.p = "", t(0)
}([function(e, t) {
"use strict";
function o() …Run Code Online (Sandbox Code Playgroud)