@module-federation/data-prefetch 0.6.6 → 0.6.7
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 +17 -0
- package/LICENSE +1 -1
- package/__tests__/prefetch.spec.ts +3 -2
- package/__tests__/react.spec.ts +1 -1
- package/dist/LICENSE +21 -0
- package/dist/babel.cjs.d.ts +2 -0
- package/dist/babel.cjs.js +62 -0
- package/dist/babel.esm.js +56 -0
- package/dist/cli.cjs.d.ts +1 -0
- package/dist/cli.cjs.js +3579 -0
- package/dist/cli.esm.js +3565 -0
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +15 -0
- package/dist/index.cjs2.js +7 -0
- package/dist/index.esm.js +6 -0
- package/dist/index.esm2.js +5 -0
- package/dist/package.json +99 -0
- package/dist/plugin.cjs.d.ts +2 -0
- package/dist/plugin.cjs.js +362 -0
- package/dist/plugin.esm.js +357 -0
- package/dist/prefetch.cjs.js +351 -0
- package/dist/prefetch.esm.js +349 -0
- package/dist/react.cjs.d.ts +1 -0
- package/dist/react.cjs.js +163 -0
- package/dist/react.esm.js +159 -0
- package/dist/runtime-utils.cjs.js +31 -0
- package/dist/runtime-utils.esm.js +26 -0
- package/dist/shared.cjs.d.ts +2 -0
- package/dist/shared.cjs.js +26 -0
- package/dist/shared.esm.js +24 -0
- package/dist/{cli → src/cli}/babel.d.ts +2 -4
- package/dist/{cli → src/cli}/index.d.ts +5 -8
- package/dist/src/common/constant.d.ts +1 -0
- package/dist/src/common/index.d.ts +1 -0
- package/dist/src/common/node-utils.d.ts +2 -0
- package/dist/src/common/runtime-utils.d.ts +5 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/logger/index.d.ts +3 -0
- package/dist/src/plugin.d.ts +3 -0
- package/dist/{prefetch-4e9646e4.d.ts → src/prefetch.d.ts} +5 -7
- package/dist/src/react/hooks.d.ts +11 -0
- package/dist/src/react/index.d.ts +1 -0
- package/dist/src/react/utils.d.ts +1 -0
- package/dist/src/shared/index.d.ts +3 -0
- package/dist/src/universal/index.d.ts +2 -0
- package/dist/universal.cjs.d.ts +1 -0
- package/dist/universal.cjs.js +38 -0
- package/dist/universal.esm.js +34 -0
- package/jest.config.js +2 -2
- package/package.json +31 -28
- package/project.json +46 -4
- package/rollup.config.js +25 -0
- package/src/cli/index.ts +12 -10
- package/src/prefetch.ts +6 -2
- package/tsconfig.json +1 -1
- package/tsconfig.lib.json +10 -0
- package/dist/cli/babel.js +0 -84
- package/dist/cli/index.js +0 -205
- package/dist/esm/chunk-AJPO2B2T.js +0 -30
- package/dist/esm/chunk-EZUCZHGV.js +0 -11
- package/dist/esm/chunk-ISLXMAIA.js +0 -155
- package/dist/esm/chunk-KI4QGPIS.js +0 -32
- package/dist/esm/chunk-TTJJJ2WZ.js +0 -7
- package/dist/esm/chunk-VVZ6XIM6.js +0 -166
- package/dist/esm/cli/babel.js +0 -57
- package/dist/esm/cli/index.js +0 -178
- package/dist/esm/index.js +0 -13
- package/dist/esm/plugin.js +0 -12
- package/dist/esm/react/index.js +0 -94
- package/dist/esm/shared/index.js +0 -27
- package/dist/esm/universal/index.js +0 -9
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -350
- package/dist/plugin.d.ts +0 -5
- package/dist/plugin.js +0 -346
- package/dist/react/index.d.ts +0 -16
- package/dist/react/index.js +0 -286
- package/dist/shared/index.d.ts +0 -5
- package/dist/shared/index.js +0 -48
- package/dist/universal/index.d.ts +0 -8
- package/dist/universal/index.js +0 -204
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @module-federation/data-prefetch
|
|
2
2
|
|
|
3
|
+
## 0.6.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9e32644: 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 [9e32644]
|
|
15
|
+
- Updated dependencies [9e32644]
|
|
16
|
+
- Updated dependencies [9e32644]
|
|
17
|
+
- @module-federation/runtime@0.6.7
|
|
18
|
+
- @module-federation/sdk@0.6.7
|
|
19
|
+
|
|
3
20
|
## 0.6.6
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024-present nieyan(nyqykk)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -65,13 +65,14 @@ describe('MF Data Prefetch', () => {
|
|
|
65
65
|
[encodeName(exposeId)]: exposeExport,
|
|
66
66
|
};
|
|
67
67
|
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__[options.name] =
|
|
68
|
-
Promise.resolve(projectExport);
|
|
68
|
+
() => Promise.resolve(projectExport);
|
|
69
69
|
|
|
70
70
|
await prefetch.getProjectExports();
|
|
71
71
|
expect(prefetch.getExposeExports(`${options.name}/button`)).toEqual(
|
|
72
72
|
exposeExport,
|
|
73
73
|
);
|
|
74
74
|
});
|
|
75
|
+
|
|
75
76
|
// Prefetching with memory and executing prefetch function
|
|
76
77
|
it('executes prefetch using prefetch function with and without memory', async () => {
|
|
77
78
|
const id = options.name;
|
|
@@ -84,7 +85,7 @@ describe('MF Data Prefetch', () => {
|
|
|
84
85
|
const prefetchExports = { [functionId]: executePrefetch };
|
|
85
86
|
|
|
86
87
|
// Mock Project Exports
|
|
87
|
-
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__[id] =
|
|
88
|
+
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__[id] = () =>
|
|
88
89
|
Promise.resolve({
|
|
89
90
|
[encodeName(exposeId)]: prefetchExports,
|
|
90
91
|
});
|
package/__tests__/react.spec.ts
CHANGED
|
@@ -71,7 +71,7 @@ describe('usePrefetch', () => {
|
|
|
71
71
|
[ModuleFederationSDK.encodeName(exposeId)]: exposeExport,
|
|
72
72
|
};
|
|
73
73
|
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__[options.name] =
|
|
74
|
-
Promise.resolve(projectExport);
|
|
74
|
+
() => Promise.resolve(projectExport);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
afterEach(() => {
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present nieyan(nyqykk)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var require$$1 = require('path');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
8
|
+
|
|
9
|
+
// no used now
|
|
10
|
+
var attribute = 'id';
|
|
11
|
+
var hookId = 'usePrefetch';
|
|
12
|
+
var importPackage = '@module-federation/data-prefetch/react';
|
|
13
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
14
|
+
function babel(babel, options) {
|
|
15
|
+
var t = babel.types;
|
|
16
|
+
var shouldHandle = false;
|
|
17
|
+
var scope = '';
|
|
18
|
+
var name = options.name, exposes = options.exposes;
|
|
19
|
+
if (!exposes) {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
var exposesKey = Object.keys(exposes);
|
|
23
|
+
var processedExposes = exposesKey.map(function(expose) {
|
|
24
|
+
return {
|
|
25
|
+
key: expose.replace('.', ''),
|
|
26
|
+
value: require$$1__default["default"].resolve(// @ts-ignore
|
|
27
|
+
typeof exposes[expose] === 'string' ? exposes[expose] : exposes[expose].import)
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
visitor: {
|
|
32
|
+
ImportDeclaration: function ImportDeclaration(nodePath, // biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
33
|
+
state) {
|
|
34
|
+
var source = nodePath.node.source.value;
|
|
35
|
+
var specifiers = nodePath.node.specifiers;
|
|
36
|
+
var filename = state.file.opts.filename;
|
|
37
|
+
if (source === importPackage) {
|
|
38
|
+
shouldHandle = specifiers.some(function(specifier) {
|
|
39
|
+
return specifier.imported && specifier.imported.name === hookId && processedExposes.find(// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
|
40
|
+
function(expose) {
|
|
41
|
+
return expose.value === filename && (scope = expose.key);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
CallExpression: function CallExpression(nodePath) {
|
|
47
|
+
if (shouldHandle && t.isIdentifier(nodePath.node.callee, {
|
|
48
|
+
name: hookId
|
|
49
|
+
}) && nodePath.node.arguments.length > 0) {
|
|
50
|
+
var objectExpression = nodePath.node.arguments[0];
|
|
51
|
+
if (objectExpression && t.isObjectExpression(objectExpression) && !objectExpression.properties.find(function(p) {
|
|
52
|
+
return p.key.name === attribute;
|
|
53
|
+
})) {
|
|
54
|
+
objectExpression.properties.push(t.objectProperty(t.identifier(attribute), t.stringLiteral(name + scope)));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = babel;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import require$$1 from 'path';
|
|
2
|
+
|
|
3
|
+
// no used now
|
|
4
|
+
var attribute = 'id';
|
|
5
|
+
var hookId = 'usePrefetch';
|
|
6
|
+
var importPackage = '@module-federation/data-prefetch/react';
|
|
7
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
8
|
+
function babel(babel, options) {
|
|
9
|
+
var t = babel.types;
|
|
10
|
+
var shouldHandle = false;
|
|
11
|
+
var scope = '';
|
|
12
|
+
var name = options.name, exposes = options.exposes;
|
|
13
|
+
if (!exposes) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
var exposesKey = Object.keys(exposes);
|
|
17
|
+
var processedExposes = exposesKey.map(function(expose) {
|
|
18
|
+
return {
|
|
19
|
+
key: expose.replace('.', ''),
|
|
20
|
+
value: require$$1.resolve(// @ts-ignore
|
|
21
|
+
typeof exposes[expose] === 'string' ? exposes[expose] : exposes[expose].import)
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
visitor: {
|
|
26
|
+
ImportDeclaration: function ImportDeclaration(nodePath, // biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
27
|
+
state) {
|
|
28
|
+
var source = nodePath.node.source.value;
|
|
29
|
+
var specifiers = nodePath.node.specifiers;
|
|
30
|
+
var filename = state.file.opts.filename;
|
|
31
|
+
if (source === importPackage) {
|
|
32
|
+
shouldHandle = specifiers.some(function(specifier) {
|
|
33
|
+
return specifier.imported && specifier.imported.name === hookId && processedExposes.find(// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
|
34
|
+
function(expose) {
|
|
35
|
+
return expose.value === filename && (scope = expose.key);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
CallExpression: function CallExpression(nodePath) {
|
|
41
|
+
if (shouldHandle && t.isIdentifier(nodePath.node.callee, {
|
|
42
|
+
name: hookId
|
|
43
|
+
}) && nodePath.node.arguments.length > 0) {
|
|
44
|
+
var objectExpression = nodePath.node.arguments[0];
|
|
45
|
+
if (objectExpression && t.isObjectExpression(objectExpression) && !objectExpression.properties.find(function(p) {
|
|
46
|
+
return p.key.name === attribute;
|
|
47
|
+
})) {
|
|
48
|
+
objectExpression.properties.push(t.objectProperty(t.identifier(attribute), t.stringLiteral(name + scope)));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { babel as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/cli/index";
|