虽然可以先判断一下,然而还是想弄清为什么会有这种差异……
export { main as default, monkeyPath, monkeyRequire };
// for test
import monkey, { monkeyPath, monkeyRequire } from "../../dist/index.mjs";
console.log("typeof monkey:", typeof monkey);
// typeof monkey:function
// for prod
import monkey, { monkeyPath, monkeyRequire } from "rollup-plugin-monkey";
console.log("typeof monkey:", typeof monkey);
// typeof monkey:object
console.log("typeof monkey.default:", typeof monkey.default);
// typeof monkey.default:function
项目源码:
https://github.com/wdssmq/rollup-plugin-monkey
这里可以看到 dist/ 内容:
https://www.npmjs.com/package/rollup-plugin-monkey?activeTab=explore
最终项目使用的配置文件:
https://github.com/wdssmq/rollup-plugin-monkey/blob/main/test/gm/rollup.config.mjs