@module-federation/data-prefetch 0.0.0-next-20240924012324 → 0.0.0-next-20240924091419

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.
package/CHANGELOG.md CHANGED
@@ -1,21 +1,12 @@
1
1
  # @module-federation/data-prefetch
2
2
 
3
- ## 0.0.0-next-20240924012324
3
+ ## 0.0.0-next-20240924091419
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - f10cf55: Refactored the way prefetch entries are imported for improved dynamic loading handling.
8
-
9
- - Changed the import of prefetch entries to use a function wrapper for more dynamic control.
10
- - Updated data types to ensure consistency with the new function-based import approach.
11
- - Modified the `injectPrefetch` function structure to incorporate the new import method.
12
- - Modified the `MFDataPrefetch` class to handle the new import function when resolving exports.
13
-
14
- - Updated dependencies [3837c89]
15
- - Updated dependencies [3837c89]
16
- - Updated dependencies [59e0069]
17
- - @module-federation/runtime@0.0.0-next-20240924012324
18
- - @module-federation/sdk@0.0.0-next-20240924012324
7
+ - Updated dependencies [3082116]
8
+ - @module-federation/runtime@0.0.0-next-20240924091419
9
+ - @module-federation/sdk@0.0.0-next-20240924091419
19
10
 
20
11
  ## 0.6.6
21
12
 
package/dist/cli/index.js CHANGED
@@ -167,16 +167,14 @@ var PrefetchPlugin = class {
167
167
  return Template.asString([
168
168
  import_fs_extra2.default.existsSync(prefetchEntry) ? Template.indent([
169
169
  "function injectPrefetch() {",
170
- Template.indent([
171
- `globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
172
- `globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}'] || {`,
173
- `entryLoading: {},`,
174
- `instance: new Map(),`,
175
- `__PREFETCH_EXPORTS__: {},`,
176
- `};`,
177
- `globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}'] || {};`,
178
- `globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`
179
- ]),
170
+ `globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
171
+ `globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}'] || {`,
172
+ `entryLoading: {},`,
173
+ `instance: new Map(),`,
174
+ `__PREFETCH_EXPORTS__: {},`,
175
+ `};`,
176
+ `globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}'] || {};`,
177
+ `globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}']['${options.name}'] = import('${prefetchEntry}');`,
180
178
  "}",
181
179
  `${federationGlobal}.prefetch = injectPrefetch`
182
180
  ]) : "",
@@ -52,12 +52,12 @@ var MFDataPrefetch = class {
52
52
  }
53
53
  }
54
54
  getProjectExports() {
55
- var _a2, _b;
55
+ var _a2;
56
56
  if (Object.keys(this._exports).length > 0) {
57
57
  return this._exports;
58
58
  }
59
59
  const { name } = this._options;
60
- const exportsPromise = (_b = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name]) == null ? void 0 : _b.call(_a2);
60
+ const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
61
61
  const resolve = exportsPromise.then(
62
62
  (exports = {}) => {
63
63
  const memory = {};
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MFDataPrefetch
3
- } from "./chunk-L7EVPWJ4.js";
3
+ } from "./chunk-ISLXMAIA.js";
4
4
  import {
5
5
  getScope
6
6
  } from "./chunk-AJPO2B2T.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-TTJJJ2WZ.js";
4
4
  import {
5
5
  MFDataPrefetch
6
- } from "./chunk-L7EVPWJ4.js";
6
+ } from "./chunk-ISLXMAIA.js";
7
7
  import {
8
8
  getSignalFromManifest
9
9
  } from "./chunk-AJPO2B2T.js";
@@ -141,16 +141,14 @@ var PrefetchPlugin = class {
141
141
  return Template.asString([
142
142
  fs2.existsSync(prefetchEntry) ? Template.indent([
143
143
  "function injectPrefetch() {",
144
- Template.indent([
145
- `globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
146
- `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,
147
- `entryLoading: {},`,
148
- `instance: new Map(),`,
149
- `__PREFETCH_EXPORTS__: {},`,
150
- `};`,
151
- `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,
152
- `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`
153
- ]),
144
+ `globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
145
+ `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,
146
+ `entryLoading: {},`,
147
+ `instance: new Map(),`,
148
+ `__PREFETCH_EXPORTS__: {},`,
149
+ `};`,
150
+ `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,
151
+ `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = import('${prefetchEntry}');`,
154
152
  "}",
155
153
  `${federationGlobal}.prefetch = injectPrefetch`
156
154
  ]) : "",
package/dist/esm/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  prefetchPlugin
3
- } from "./chunk-EK6Q2YBB.js";
3
+ } from "./chunk-VVZ6XIM6.js";
4
4
  import "./chunk-TTJJJ2WZ.js";
5
5
  import {
6
6
  MFDataPrefetch
7
- } from "./chunk-L7EVPWJ4.js";
7
+ } from "./chunk-ISLXMAIA.js";
8
8
  import "./chunk-AJPO2B2T.js";
9
9
  import "./chunk-EZUCZHGV.js";
10
10
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  plugin_default,
3
3
  prefetchPlugin
4
- } from "./chunk-EK6Q2YBB.js";
4
+ } from "./chunk-VVZ6XIM6.js";
5
5
  import "./chunk-TTJJJ2WZ.js";
6
- import "./chunk-L7EVPWJ4.js";
6
+ import "./chunk-ISLXMAIA.js";
7
7
  import "./chunk-AJPO2B2T.js";
8
8
  import "./chunk-EZUCZHGV.js";
9
9
  export {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  prefetch
3
- } from "../chunk-FKXFJ2Y4.js";
3
+ } from "../chunk-KI4QGPIS.js";
4
4
  import {
5
5
  logger_default
6
6
  } from "../chunk-TTJJJ2WZ.js";
7
7
  import {
8
8
  MFDataPrefetch
9
- } from "../chunk-L7EVPWJ4.js";
9
+ } from "../chunk-ISLXMAIA.js";
10
10
  import {
11
11
  getScope
12
12
  } from "../chunk-AJPO2B2T.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  prefetch
3
- } from "../chunk-FKXFJ2Y4.js";
4
- import "../chunk-L7EVPWJ4.js";
3
+ } from "../chunk-KI4QGPIS.js";
4
+ import "../chunk-ISLXMAIA.js";
5
5
  import "../chunk-AJPO2B2T.js";
6
6
  import "../chunk-EZUCZHGV.js";
7
7
  export {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { D as DataPrefetchOptions, M as MFDataPrefetch, p as prefetchOptions } from './prefetch-c08be471.js';
1
+ export { D as DataPrefetchOptions, M as MFDataPrefetch, p as prefetchOptions } from './prefetch-4e9646e4.js';
2
2
  export { default as prefetchPlugin } from './plugin.js';
3
3
  import '@module-federation/runtime';
4
4
  import '@module-federation/sdk';
package/dist/index.js CHANGED
@@ -89,12 +89,12 @@ var MFDataPrefetch = class {
89
89
  }
90
90
  }
91
91
  getProjectExports() {
92
- var _a2, _b;
92
+ var _a2;
93
93
  if (Object.keys(this._exports).length > 0) {
94
94
  return this._exports;
95
95
  }
96
96
  const { name } = this._options;
97
- const exportsPromise = (_b = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name]) == null ? void 0 : _b.call(_a2);
97
+ const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
98
98
  const resolve = exportsPromise.then(
99
99
  (exports = {}) => {
100
100
  const memory = {};
package/dist/plugin.js CHANGED
@@ -88,12 +88,12 @@ var MFDataPrefetch = class {
88
88
  }
89
89
  }
90
90
  getProjectExports() {
91
- var _a2, _b;
91
+ var _a2;
92
92
  if (Object.keys(this._exports).length > 0) {
93
93
  return this._exports;
94
94
  }
95
95
  const { name } = this._options;
96
- const exportsPromise = (_b = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name]) == null ? void 0 : _b.call(_a2);
96
+ const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
97
97
  const resolve = exportsPromise.then(
98
98
  (exports = {}) => {
99
99
  const memory = {};
@@ -7,7 +7,7 @@ declare module '@module-federation/runtime' {
7
7
  __PREFETCH__: {
8
8
  entryLoading: Record<string, undefined | Promise<void>>;
9
9
  instance: Map<string, MFDataPrefetch>;
10
- __PREFETCH_EXPORTS__: Record<string, () => Promise<Record<string, any>>>;
10
+ __PREFETCH_EXPORTS__: Record<string, Promise<Record<string, any>>>;
11
11
  };
12
12
  }
13
13
  }
@@ -1,4 +1,4 @@
1
- import { p as prefetchOptions } from '../prefetch-c08be471.js';
1
+ import { p as prefetchOptions } from '../prefetch-4e9646e4.js';
2
2
  import '@module-federation/runtime';
3
3
  import '@module-federation/sdk';
4
4
  import '@module-federation/runtime/types';
@@ -86,12 +86,12 @@ var MFDataPrefetch = class {
86
86
  }
87
87
  }
88
88
  getProjectExports() {
89
- var _a2, _b;
89
+ var _a2;
90
90
  if (Object.keys(this._exports).length > 0) {
91
91
  return this._exports;
92
92
  }
93
93
  const { name } = this._options;
94
- const exportsPromise = (_b = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name]) == null ? void 0 : _b.call(_a2);
94
+ const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
95
95
  const resolve = exportsPromise.then(
96
96
  (exports = {}) => {
97
97
  const memory = {};
@@ -1,4 +1,4 @@
1
- import { p as prefetchOptions } from '../prefetch-c08be471.js';
1
+ import { p as prefetchOptions } from '../prefetch-4e9646e4.js';
2
2
  import '@module-federation/runtime';
3
3
  import '@module-federation/sdk';
4
4
  import '@module-federation/runtime/types';
@@ -79,12 +79,12 @@ var MFDataPrefetch = class {
79
79
  }
80
80
  }
81
81
  getProjectExports() {
82
- var _a2, _b;
82
+ var _a2;
83
83
  if (Object.keys(this._exports).length > 0) {
84
84
  return this._exports;
85
85
  }
86
86
  const { name } = this._options;
87
- const exportsPromise = (_b = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name]) == null ? void 0 : _b.call(_a2);
87
+ const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
88
88
  const resolve = exportsPromise.then(
89
89
  (exports = {}) => {
90
90
  const memory = {};
package/jest.config.js CHANGED
@@ -24,6 +24,6 @@ module.exports = {
24
24
  '^.+\\.(t|j)sx?$': ['@swc/jest', { swcrc: false }],
25
25
  },
26
26
  rootDir: __dirname,
27
- testMatch: ['<rootDir>/__tests__/**/*.spec.[jt]s?(x)'],
27
+ testMatch: ['<rootDir>__tests__/**/**.spec.[jt]s?(x)'],
28
28
  testPathIgnorePatterns: ['/node_modules/'],
29
29
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@module-federation/data-prefetch",
3
3
  "description": "Module Federation Data Prefetch",
4
- "version": "0.0.0-next-20240924012324",
4
+ "version": "0.0.0-next-20240924091419",
5
5
  "author": "nieyan <nyqykk@foxmail.com>",
6
6
  "homepage": "https://github.com/module-federation/core",
7
7
  "license": "MIT",
@@ -85,8 +85,8 @@
85
85
  },
86
86
  "dependencies": {
87
87
  "fs-extra": "9.1.0",
88
- "@module-federation/sdk": "0.0.0-next-20240924012324",
89
- "@module-federation/runtime": "0.0.0-next-20240924012324"
88
+ "@module-federation/sdk": "0.0.0-next-20240924091419",
89
+ "@module-federation/runtime": "0.0.0-next-20240924091419"
90
90
  },
91
91
  "scripts": {
92
92
  "dev": "cross-env WATCH=true tsup",
package/src/cli/index.ts CHANGED
@@ -135,16 +135,14 @@ export class PrefetchPlugin implements WebpackPluginInstance {
135
135
  fs.existsSync(prefetchEntry)
136
136
  ? Template.indent([
137
137
  'function injectPrefetch() {',
138
- Template.indent([
139
- `globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
140
- `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,
141
- `entryLoading: {},`,
142
- `instance: new Map(),`,
143
- `__PREFETCH_EXPORTS__: {},`,
144
- `};`,
145
- `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,
146
- `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`,
147
- ]),
138
+ `globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
139
+ `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,
140
+ `entryLoading: {},`,
141
+ `instance: new Map(),`,
142
+ `__PREFETCH_EXPORTS__: {},`,
143
+ `};`,
144
+ `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,
145
+ `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = import('${prefetchEntry}');`,
148
146
  '}',
149
147
  `${federationGlobal}.prefetch = injectPrefetch`,
150
148
  ])
package/src/prefetch.ts CHANGED
@@ -17,7 +17,7 @@ declare module '@module-federation/runtime' {
17
17
  __PREFETCH__: {
18
18
  entryLoading: Record<string, undefined | Promise<void>>;
19
19
  instance: Map<string, MFDataPrefetch>;
20
- __PREFETCH_EXPORTS__: Record<string, () => Promise<Record<string, any>>>;
20
+ __PREFETCH_EXPORTS__: Record<string, Promise<Record<string, any>>>;
21
21
  };
22
22
  }
23
23
  }
@@ -95,7 +95,7 @@ export class MFDataPrefetch {
95
95
  }
96
96
  const { name } = this._options;
97
97
  const exportsPromise =
98
- globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__?.[name]?.();
98
+ globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__?.[name];
99
99
  const resolve = exportsPromise.then(
100
100
  (exports: Record<string, Record<string, any>> = {}) => {
101
101
  // Match prefetch based on the function name suffix so that other capabilities can be expanded later.