uniapp中,两个node_modules中的三方类库使用同一个另一个三方类库的变量,在小程序上为不同对象,而h5端为相同对象
- Dominant language
- JavaScript
- Stars
- 41.6k
- Forks
- 3.7k
- Avg merge
- 7h 6m
- Merged PRs (30d)
- 6
Description
不是说 esm是 引用变量么, 为什么在小程序上同一个模块导出的是两个不同的对象,就因为使用的项目不同?这两个项目都依赖了另一个项目,于是各新建了一个实体?
而在h5端,两个node_modules中的三方类库项目引用同一个第三方类库中到处的内容,是共享对象的
看小程序源码里面创建了两个这个对象
```
let SocialuniPluginsModule$1 = class SocialuniPluginsModule2 {
constructor() {
__publicField(this, "_router", null);
__publicField(this, "_route", null);
__publicField(this, "uid", UUIDUtil.getUUID());
__publicField(this, "socialuniPlugins", []);
console.trace("创建了socialplus");
}
get route() {
return this._route;
}
setRoute(value) {
this._route = value;
}
get router() {
return this._router;
}
setRouter(value) {
this._router = value;
}
init() {
this.socialuniPlugins = [];
}
addPlugin(...socialuniPlugins) {
this.socialuniPlugins.push(...socialuniPlugins);
}
get plugins() {
return this.socialuniPlugins;
}
};
const socialuniPluginsModule$1 = reactive(new SocialuniPluginsModule$1());
class SocialuniPluginsModule {
constructor() {
this._router = null;
this._route = null;
this.uid = UUIDUtil.getUUID();
this.socialuniPlugins = [];
console.trace("创建了socialplus");
}
get route() {
return this._route;
}
setRoute(value) {
this._route = value;
}
get router() {
return this._router;
}
setRouter(value) {
this._router = value;
}
init() {
this.socialuniPlugins = [];
}
addPlugin(...socialuniPlugins) {
this.socialuniPlugins.push(...socialuniPlugins);
}
get plugins() {
return this.socialuniPlugins;
}
}
const socialuniPluginsModule = reactive(new SocialuniPluginsModule());
```
源码

编译后

Contributor guide
Assessment
This issue has not been assessed yet.