var __getOwnPropNames = Object.getOwnPropertyNames; // 相当于Object.keys()
var __commonJS = (cb, mod) => function __require() {
// 3. 执行a函数并传入{exports:{}}和exports:{} 返回exports对象
return mod || cb[__getOwnPropNames(cb)[0]](mod = { exports: {} }, mod), mod.exports;
};
var test = __commonJS({
// 1. 定义了exports和module
"a"(exports, module) {
(function () {
module.exports = {
a: 1, b: 2
}
// 2. 绑定上下文环境
}).call(exports);
}
}, undefined);
export default test();
总结
- 给函数绑定上下文,并设置exports和module变量
- export default返回exports