@ice/mf-runtime 1.0.4 → 1.0.5-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { getExtraInfo, getRemoteInfoFromStore, hasConflict } from './mf-global-store';
2
+ import { getExtraInfo, getMicroMod, getRemoteInfoFromStore, hasConflict } from './mf-global-store';
3
3
  import { FallBack } from './FallBack';
4
4
  const loadRemotePackagedReactAndRender = async (args)=>{
5
5
  var _args_origin_options_shared_reactdom_, _args_origin_options_shared_reactdom, _args_origin_options_shared, _args_origin_options, _remoteInstance_options_shared_reactdom_, _remoteInstance_options_shared_reactdom, _remoteInstance_options_shared, _remoteInstance_options;
@@ -87,6 +87,20 @@ export const runtimePlugin = ()=>({
87
87
  async beforeRequest (args) {
88
88
  const remoteName = args.id.split('/')[0];
89
89
  const hostName = args.options.name;
90
+ // 清除 window 上带版本号的模块(如果存在)
91
+ if (args.id.includes('/')) {
92
+ var _microMod;
93
+ const moduleNameWithDash = remoteName; // 如 guanghe-workspace
94
+ const microMod = getMicroMod(moduleNameWithDash);
95
+ if ((_microMod = microMod) === null || _microMod === void 0 ? void 0 : _microMod.moduleFederatedName) {
96
+ const versionedModuleName = microMod.moduleFederatedName;
97
+ if (window[versionedModuleName]) {
98
+ console.log(`[beforeRequest] Clearing versioned module from window: ${versionedModuleName}`);
99
+ // @ts-expect-error for global module
100
+ window[versionedModuleName] = null;
101
+ }
102
+ }
103
+ }
90
104
  if (!hasConflict(hostName, remoteName)) {
91
105
  return args;
92
106
  }
@@ -1,7 +1,7 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import * as React from "react";
4
- import { getExtraInfo, getRemoteInfoFromStore, hasConflict } from "./mf-global-store";
4
+ import { getExtraInfo, getMicroMod, getRemoteInfoFromStore, hasConflict } from "./mf-global-store";
5
5
  import { FallBack } from "./FallBack";
6
6
  var loadRemotePackagedReactAndRender = function() {
7
7
  var _ref = _async_to_generator(function(args) {
@@ -163,10 +163,24 @@ export var runtimePlugin = function() {
163
163
  },
164
164
  beforeRequest: function beforeRequest(args) {
165
165
  return _async_to_generator(function() {
166
- var remoteName, hostName, newRemoteInfo, requestRemote, hostInstance;
166
+ var remoteName, hostName, _microMod, moduleNameWithDash, microMod, versionedModuleName, newRemoteInfo, requestRemote, hostInstance;
167
167
  return _ts_generator(this, function(_state) {
168
168
  remoteName = args.id.split("/")[0];
169
169
  hostName = args.options.name;
170
+ // 清除 window 上带版本号的模块(如果存在)
171
+ if (args.id.includes("/")) {
172
+ ;
173
+ moduleNameWithDash = remoteName; // 如 guanghe-workspace
174
+ microMod = getMicroMod(moduleNameWithDash);
175
+ if ((_microMod = microMod) === null || _microMod === void 0 ? void 0 : _microMod.moduleFederatedName) {
176
+ versionedModuleName = microMod.moduleFederatedName;
177
+ if (window[versionedModuleName]) {
178
+ console.log("[beforeRequest] Clearing versioned module from window: ".concat(versionedModuleName));
179
+ // @ts-expect-error for global module
180
+ window[versionedModuleName] = null;
181
+ }
182
+ }
183
+ }
170
184
  if (!hasConflict(hostName, remoteName)) {
171
185
  return [
172
186
  2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ice/mf-runtime",
3
- "version": "1.0.4",
3
+ "version": "1.0.5-beta.0",
4
4
  "description": "ice mf runtime",
5
5
  "files": [
6
6
  "esm",