@module-federation/utilities 3.1.98 → 3.1.99
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.
|
@@ -39,6 +39,7 @@ __webpack_require__.r = (exports) => {
|
|
|
39
39
|
})();
|
|
40
40
|
var __webpack_exports__ = {};
|
|
41
41
|
__webpack_require__.r(__webpack_exports__);
|
|
42
|
+
const REMOTE_REFERENCE_PREFIX = /^(?:webpack|rspack)\/container\/reference/;
|
|
42
43
|
class DelegateModulesPlugin {
|
|
43
44
|
getChunkByName(chunks, name) {
|
|
44
45
|
for (const chunk of chunks){
|
|
@@ -82,7 +83,7 @@ class DelegateModulesPlugin {
|
|
|
82
83
|
const normalModule = module;
|
|
83
84
|
if (normalModule) {
|
|
84
85
|
const mid = normalModule.identifier();
|
|
85
|
-
if (normalModule?.userRequest
|
|
86
|
+
if (normalModule?.userRequest && REMOTE_REFERENCE_PREFIX.test(normalModule.userRequest)) {
|
|
86
87
|
this._delegateModules.set(mid, normalModule);
|
|
87
88
|
}
|
|
88
89
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
3
|
+
return typeof document === 'undefined'
|
|
4
|
+
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
5
|
+
: (document.currentScript && document.currentScript.src) ||
|
|
6
|
+
new URL('main.js', document.baseURI).href;
|
|
7
|
+
})();
|
|
8
|
+
;
|
|
9
|
+
// The require scope
|
|
10
|
+
var __webpack_require__ = {};
|
|
11
|
+
|
|
12
|
+
// webpack/runtime/compat_get_default_export
|
|
13
|
+
(() => {
|
|
14
|
+
// getDefaultExport function for compatibility with non-ESM modules
|
|
15
|
+
__webpack_require__.n = (module) => {
|
|
16
|
+
var getter = module && module.__esModule ?
|
|
17
|
+
() => (module['default']) :
|
|
18
|
+
() => (module);
|
|
19
|
+
__webpack_require__.d(getter, { a: getter });
|
|
20
|
+
return getter;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
})();
|
|
24
|
+
// webpack/runtime/define_property_getters
|
|
25
|
+
(() => {
|
|
26
|
+
__webpack_require__.d = (exports, getters, values) => {
|
|
27
|
+
var define = (defs, kind) => {
|
|
28
|
+
for(var key in defs) {
|
|
29
|
+
if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
|
|
30
|
+
Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
define(getters, "get");
|
|
35
|
+
define(values, "value");
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
// webpack/runtime/has_own_property
|
|
39
|
+
(() => {
|
|
40
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
41
|
+
})();
|
|
42
|
+
var __webpack_exports__ = {};
|
|
43
|
+
|
|
44
|
+
;// CONCATENATED MODULE: external "./DelegateModulesPlugin.js"
|
|
45
|
+
const external_DelegateModulesPlugin_js_namespaceObject = require("./DelegateModulesPlugin.js");
|
|
46
|
+
var external_DelegateModulesPlugin_js_default = /*#__PURE__*/__webpack_require__.n(external_DelegateModulesPlugin_js_namespaceObject);
|
|
47
|
+
;// CONCATENATED MODULE: ./src/plugins/DelegateModulesPlugin.test.ts
|
|
48
|
+
|
|
49
|
+
describe('DelegateModulesPlugin', ()=>{
|
|
50
|
+
it.each([
|
|
51
|
+
'webpack',
|
|
52
|
+
'rspack'
|
|
53
|
+
])('collects %s container reference modules as delegates', (bundler)=>{
|
|
54
|
+
const remoteModule = {
|
|
55
|
+
identifier: ()=>`${bundler}/container/reference/app2`,
|
|
56
|
+
userRequest: `${bundler}/container/reference/app2`
|
|
57
|
+
};
|
|
58
|
+
const finishModules = {
|
|
59
|
+
tapAsync: jest.fn((_name, handler)=>handler([
|
|
60
|
+
remoteModule
|
|
61
|
+
], jest.fn()))
|
|
62
|
+
};
|
|
63
|
+
const compilation = {
|
|
64
|
+
hooks: {
|
|
65
|
+
finishModules,
|
|
66
|
+
optimizeChunks: {
|
|
67
|
+
tap: jest.fn()
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const compiler = {
|
|
72
|
+
hooks: {
|
|
73
|
+
thisCompilation: {
|
|
74
|
+
tap: jest.fn((_name, handler)=>handler(compilation))
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const plugin = new (external_DelegateModulesPlugin_js_default())({});
|
|
79
|
+
plugin.apply(compiler);
|
|
80
|
+
expect(plugin._delegateModules.get(remoteModule.identifier())).toBe(remoteModule);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
for(var __rspack_i in __webpack_exports__) {
|
|
85
|
+
exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
86
|
+
}
|
|
87
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const REMOTE_REFERENCE_PREFIX = /^(?:webpack|rspack)\/container\/reference/;
|
|
1
2
|
class DelegateModulesPlugin {
|
|
2
3
|
getChunkByName(chunks, name) {
|
|
3
4
|
for (const chunk of chunks){
|
|
@@ -41,7 +42,7 @@ class DelegateModulesPlugin {
|
|
|
41
42
|
const normalModule = module;
|
|
42
43
|
if (normalModule) {
|
|
43
44
|
const mid = normalModule.identifier();
|
|
44
|
-
if (normalModule?.userRequest
|
|
45
|
+
if (normalModule?.userRequest && REMOTE_REFERENCE_PREFIX.test(normalModule.userRequest)) {
|
|
45
46
|
this._delegateModules.set(mid, normalModule);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import DelegateModulesPlugin from "./DelegateModulesPlugin.mjs";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
describe('DelegateModulesPlugin', ()=>{
|
|
6
|
+
it.each([
|
|
7
|
+
'webpack',
|
|
8
|
+
'rspack'
|
|
9
|
+
])('collects %s container reference modules as delegates', (bundler)=>{
|
|
10
|
+
const remoteModule = {
|
|
11
|
+
identifier: ()=>`${bundler}/container/reference/app2`,
|
|
12
|
+
userRequest: `${bundler}/container/reference/app2`
|
|
13
|
+
};
|
|
14
|
+
const finishModules = {
|
|
15
|
+
tapAsync: jest.fn((_name, handler)=>handler([
|
|
16
|
+
remoteModule
|
|
17
|
+
], jest.fn()))
|
|
18
|
+
};
|
|
19
|
+
const compilation = {
|
|
20
|
+
hooks: {
|
|
21
|
+
finishModules,
|
|
22
|
+
optimizeChunks: {
|
|
23
|
+
tap: jest.fn()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const compiler = {
|
|
28
|
+
hooks: {
|
|
29
|
+
thisCompilation: {
|
|
30
|
+
tap: jest.fn((_name, handler)=>handler(compilation))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const plugin = new DelegateModulesPlugin({});
|
|
35
|
+
plugin.apply(compiler);
|
|
36
|
+
expect(plugin._delegateModules.get(remoteModule.identifier())).toBe(remoteModule);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/utilities",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.99",
|
|
4
4
|
"main": "./dist/cjs/index.js",
|
|
5
5
|
"module": "./dist/esm/index.mjs",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"rsbuild-plugin-publint": "^0.2.1"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@module-federation/sdk": "2.
|
|
26
|
+
"@module-federation/sdk": "2.8.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": "^16 || ^17 || ^18",
|