@module-federation/modern-js 0.21.5 → 0.22.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.
- package/dist/cjs/cli/configPlugin.js +301 -357
- package/dist/cjs/cli/index.js +103 -93
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +51 -41
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +73 -75
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +50 -40
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +55 -44
- package/dist/cjs/cli/ssrPlugin.js +266 -298
- package/dist/cjs/cli/utils.js +84 -81
- package/dist/cjs/constant.js +37 -28
- package/dist/cjs/interfaces/bundler.js +17 -15
- package/dist/cjs/logger.js +37 -25
- package/dist/cjs/react/index.js +55 -19
- package/dist/cjs/react/plugin.js +62 -37
- package/dist/cjs/react/v18.js +55 -19
- package/dist/cjs/react/v19.js +55 -19
- package/dist/cjs/runtime/index.js +55 -19
- package/dist/cjs/server/fileCache.js +76 -76
- package/dist/cjs/server/index.js +65 -57
- package/dist/cjs/server/staticMiddleware.js +84 -84
- package/dist/cjs/ssr-runtime/SSRLiveReload.js +40 -34
- package/dist/cjs/ssr-runtime/devPlugin.js +63 -67
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +44 -36
- package/dist/cjs/types/index.js +17 -15
- package/dist/esm/cli/configPlugin.mjs +305 -0
- package/dist/esm/cli/index.mjs +83 -0
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs +12 -0
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +58 -0
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs +21 -0
- package/dist/esm/cli/server/data-fetch-server-plugin.mjs +17 -0
- package/dist/esm/cli/ssrPlugin.mjs +254 -0
- package/dist/esm/cli/utils.mjs +40 -0
- package/dist/esm/constant.mjs +3 -0
- package/dist/esm/logger.mjs +5 -0
- package/dist/esm/react/plugin.mjs +3 -0
- package/dist/esm/server/fileCache.mjs +90 -0
- package/dist/esm/server/index.mjs +36 -0
- package/dist/esm/server/staticMiddleware.mjs +87 -0
- package/dist/esm/ssr-runtime/SSRLiveReload.mjs +22 -0
- package/dist/esm/ssr-runtime/devPlugin.mjs +70 -0
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.mjs +34 -0
- package/dist/esm-node/cli/configPlugin.mjs +263 -0
- package/dist/esm-node/cli/index.mjs +67 -0
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.mjs +10 -0
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +46 -0
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.mjs +19 -0
- package/dist/esm-node/cli/server/data-fetch-server-plugin.mjs +15 -0
- package/dist/esm-node/cli/ssrPlugin.mjs +228 -0
- package/dist/esm-node/cli/utils.mjs +40 -0
- package/dist/esm-node/constant.mjs +3 -0
- package/dist/esm-node/logger.mjs +5 -0
- package/dist/esm-node/react/plugin.mjs +3 -0
- package/dist/esm-node/server/fileCache.mjs +37 -0
- package/dist/esm-node/server/index.mjs +34 -0
- package/dist/esm-node/server/staticMiddleware.mjs +42 -0
- package/dist/esm-node/ssr-runtime/SSRLiveReload.mjs +15 -0
- package/dist/esm-node/ssr-runtime/devPlugin.mjs +33 -0
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.mjs +14 -0
- package/package.json +32 -31
- package/dist/cjs/cli/configPlugin.spec.js +0 -112
- package/dist/cjs/server/fileCache.spec.js +0 -28
- package/dist/cjs/server/staticMiddleware.spec.js +0 -185
- package/dist/esm/cli/configPlugin.js +0 -395
- package/dist/esm/cli/configPlugin.spec.js +0 -108
- package/dist/esm/cli/index.js +0 -92
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js +0 -16
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js +0 -74
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.js +0 -25
- package/dist/esm/cli/server/data-fetch-server-plugin.js +0 -20
- package/dist/esm/cli/ssrPlugin.js +0 -305
- package/dist/esm/cli/utils.js +0 -53
- package/dist/esm/constant.js +0 -6
- package/dist/esm/logger.js +0 -7
- package/dist/esm/react/plugin.js +0 -5
- package/dist/esm/server/fileCache.js +0 -98
- package/dist/esm/server/fileCache.spec.js +0 -50
- package/dist/esm/server/index.js +0 -41
- package/dist/esm/server/staticMiddleware.js +0 -104
- package/dist/esm/server/staticMiddleware.spec.js +0 -328
- package/dist/esm/ssr-runtime/SSRLiveReload.js +0 -26
- package/dist/esm/ssr-runtime/devPlugin.js +0 -73
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js +0 -34
- package/dist/esm-node/cli/configPlugin.js +0 -347
- package/dist/esm-node/cli/configPlugin.spec.js +0 -89
- package/dist/esm-node/cli/index.js +0 -72
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.js +0 -14
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.js +0 -62
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.js +0 -23
- package/dist/esm-node/cli/server/data-fetch-server-plugin.js +0 -18
- package/dist/esm-node/cli/ssrPlugin.js +0 -280
- package/dist/esm-node/cli/utils.js +0 -53
- package/dist/esm-node/constant.js +0 -6
- package/dist/esm-node/logger.js +0 -7
- package/dist/esm-node/react/plugin.js +0 -5
- package/dist/esm-node/server/fileCache.js +0 -49
- package/dist/esm-node/server/fileCache.spec.js +0 -27
- package/dist/esm-node/server/index.js +0 -39
- package/dist/esm-node/server/staticMiddleware.js +0 -55
- package/dist/esm-node/server/staticMiddleware.spec.js +0 -162
- package/dist/esm-node/ssr-runtime/SSRLiveReload.js +0 -19
- package/dist/esm-node/ssr-runtime/devPlugin.js +0 -37
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.js +0 -16
- /package/dist/esm/interfaces/{bundler.js → bundler.mjs} +0 -0
- /package/dist/esm/react/{index.js → index.mjs} +0 -0
- /package/dist/esm/react/{v18.js → v18.mjs} +0 -0
- /package/dist/esm/react/{v19.js → v19.mjs} +0 -0
- /package/dist/esm/runtime/{index.js → index.mjs} +0 -0
- /package/dist/esm/types/{index.js → index.mjs} +0 -0
- /package/dist/esm-node/interfaces/{bundler.js → bundler.mjs} +0 -0
- /package/dist/esm-node/react/{index.js → index.mjs} +0 -0
- /package/dist/esm-node/react/{v18.js → v18.mjs} +0 -0
- /package/dist/esm-node/react/{v19.js → v19.mjs} +0 -0
- /package/dist/esm-node/runtime/{index.js → index.mjs} +0 -0
- /package/dist/esm-node/types/{index.js → index.mjs} +0 -0
package/dist/cjs/react/v19.js
CHANGED
|
@@ -1,22 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"@module-federation/bridge-react/v19" (module) {
|
|
4
|
+
module.exports = require("@module-federation/bridge-react/v19");
|
|
5
|
+
}
|
|
13
6
|
};
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
var __webpack_module_cache__ = {};
|
|
8
|
+
function __webpack_require__(moduleId) {
|
|
9
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
+
exports: {}
|
|
13
|
+
};
|
|
14
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
+
return module.exports;
|
|
16
|
+
}
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.n = (module)=>{
|
|
19
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
20
|
+
__webpack_require__.d(getter, {
|
|
21
|
+
a: getter
|
|
22
|
+
});
|
|
23
|
+
return getter;
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
28
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: definition[key]
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
(()=>{
|
|
35
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
36
|
+
})();
|
|
37
|
+
(()=>{
|
|
38
|
+
__webpack_require__.r = (exports1)=>{
|
|
39
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
40
|
+
value: 'Module'
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __webpack_exports__ = {};
|
|
48
|
+
(()=>{
|
|
49
|
+
__webpack_require__.r(__webpack_exports__);
|
|
50
|
+
var _module_federation_bridge_react_v19__rspack_import_0 = __webpack_require__("@module-federation/bridge-react/v19");
|
|
51
|
+
var __rspack_reexport = {};
|
|
52
|
+
for(const __rspack_import_key in _module_federation_bridge_react_v19__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_module_federation_bridge_react_v19__rspack_import_0[__rspack_import_key];
|
|
53
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
54
|
+
})();
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
22
58
|
});
|
|
@@ -1,22 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"@module-federation/enhanced/runtime" (module) {
|
|
4
|
+
module.exports = require("@module-federation/enhanced/runtime");
|
|
5
|
+
}
|
|
13
6
|
};
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
var __webpack_module_cache__ = {};
|
|
8
|
+
function __webpack_require__(moduleId) {
|
|
9
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
+
exports: {}
|
|
13
|
+
};
|
|
14
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
+
return module.exports;
|
|
16
|
+
}
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.n = (module)=>{
|
|
19
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
20
|
+
__webpack_require__.d(getter, {
|
|
21
|
+
a: getter
|
|
22
|
+
});
|
|
23
|
+
return getter;
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
28
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: definition[key]
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
(()=>{
|
|
35
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
36
|
+
})();
|
|
37
|
+
(()=>{
|
|
38
|
+
__webpack_require__.r = (exports1)=>{
|
|
39
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
40
|
+
value: 'Module'
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __webpack_exports__ = {};
|
|
48
|
+
(()=>{
|
|
49
|
+
__webpack_require__.r(__webpack_exports__);
|
|
50
|
+
var _module_federation_enhanced_runtime__rspack_import_0 = __webpack_require__("@module-federation/enhanced/runtime");
|
|
51
|
+
var __rspack_reexport = {};
|
|
52
|
+
for(const __rspack_import_key in _module_federation_enhanced_runtime__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_module_federation_enhanced_runtime__rspack_import_0[__rspack_import_key];
|
|
53
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
54
|
+
})();
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
22
58
|
});
|
|
@@ -1,84 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
FileCache: ()=>FileCache,
|
|
37
|
+
fileCache: ()=>fileCache
|
|
33
38
|
});
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
39
|
+
const external_fs_extra_namespaceObject = require("fs-extra");
|
|
40
|
+
var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
|
|
41
|
+
const external_lru_cache_namespaceObject = require("lru-cache");
|
|
37
42
|
class FileCache {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
async getFile(filepath) {
|
|
44
|
+
if (!await external_fs_extra_default().pathExists(filepath)) return null;
|
|
45
|
+
try {
|
|
46
|
+
const stat = await external_fs_extra_default().lstat(filepath);
|
|
47
|
+
const currentModified = stat.mtimeMs;
|
|
48
|
+
const cachedEntry = this.cache.get(filepath);
|
|
49
|
+
if (cachedEntry && currentModified <= cachedEntry.lastModified) return {
|
|
50
|
+
content: cachedEntry.content,
|
|
51
|
+
lastModified: cachedEntry.lastModified
|
|
52
|
+
};
|
|
53
|
+
const content = await external_fs_extra_default().readFile(filepath, 'utf-8');
|
|
54
|
+
const newEntry = {
|
|
55
|
+
content,
|
|
56
|
+
lastModified: currentModified
|
|
57
|
+
};
|
|
58
|
+
this.cache.set(filepath, newEntry, {
|
|
59
|
+
size: stat.size || content.length
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
content,
|
|
63
|
+
lastModified: currentModified
|
|
64
|
+
};
|
|
65
|
+
} catch (err) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
46
68
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (cachedEntry && currentModified <= cachedEntry.lastModified) {
|
|
52
|
-
return {
|
|
53
|
-
content: cachedEntry.content,
|
|
54
|
-
lastModified: cachedEntry.lastModified
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const content = await import_fs_extra.default.readFile(filepath, "utf-8");
|
|
58
|
-
const newEntry = {
|
|
59
|
-
content,
|
|
60
|
-
lastModified: currentModified
|
|
61
|
-
};
|
|
62
|
-
this.cache.set(filepath, newEntry, {
|
|
63
|
-
size: stat.size || content.length
|
|
64
|
-
});
|
|
65
|
-
return {
|
|
66
|
-
content,
|
|
67
|
-
lastModified: currentModified
|
|
68
|
-
};
|
|
69
|
-
} catch (err) {
|
|
70
|
-
return null;
|
|
69
|
+
constructor(){
|
|
70
|
+
this.cache = new external_lru_cache_namespaceObject.LRUCache({
|
|
71
|
+
maxSize: 209715200
|
|
72
|
+
});
|
|
71
73
|
}
|
|
72
|
-
}
|
|
73
|
-
constructor() {
|
|
74
|
-
this.cache = new import_lru_cache.LRUCache({
|
|
75
|
-
maxSize: 200 * 1024 * 1024
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
74
|
}
|
|
79
75
|
const fileCache = new FileCache();
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
exports.FileCache = __webpack_exports__.FileCache;
|
|
77
|
+
exports.fileCache = __webpack_exports__.fileCache;
|
|
78
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
79
|
+
"FileCache",
|
|
80
|
+
"fileCache"
|
|
81
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
82
|
+
Object.defineProperty(exports, '__esModule', {
|
|
83
|
+
value: true
|
|
84
84
|
});
|
package/dist/cjs/server/index.js
CHANGED
|
@@ -1,63 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var server_exports = {};
|
|
20
|
-
__export(server_exports, {
|
|
21
|
-
default: () => server_default,
|
|
22
|
-
staticServePlugin: () => staticServePlugin
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(server_exports);
|
|
25
|
-
var import_staticMiddleware = require("./staticMiddleware");
|
|
26
|
-
const staticServePlugin = () => ({
|
|
27
|
-
name: "@modern-js/module-federation/server",
|
|
28
|
-
setup: (api) => {
|
|
29
|
-
api.onPrepare(() => {
|
|
30
|
-
var _config_output, _config_server;
|
|
31
|
-
if (process.env.NODE_ENV === "development") {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const { middlewares } = api.getServerContext();
|
|
35
|
-
const config = api.getServerConfig();
|
|
36
|
-
const assetPrefix = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.assetPrefix) || "";
|
|
37
|
-
if ((_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.ssr) {
|
|
38
|
-
const context = api.getServerContext();
|
|
39
|
-
const pwd = context.distDirectory;
|
|
40
|
-
const serverStaticMiddleware = (0, import_staticMiddleware.createStaticMiddleware)({
|
|
41
|
-
assetPrefix,
|
|
42
|
-
pwd
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
43
8
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
47
18
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const corsMiddleware = (0, import_staticMiddleware.createCorsMiddleware)();
|
|
51
|
-
middlewares.push({
|
|
52
|
-
name: "module-federation-cors",
|
|
53
|
-
handler: corsMiddleware
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
54
21
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
default: ()=>server,
|
|
28
|
+
staticServePlugin: ()=>staticServePlugin
|
|
58
29
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
30
|
+
const external_staticMiddleware_js_namespaceObject = require("./staticMiddleware.js");
|
|
31
|
+
const staticServePlugin = ()=>({
|
|
32
|
+
name: '@modern-js/module-federation/server',
|
|
33
|
+
setup: (api)=>{
|
|
34
|
+
api.onPrepare(()=>{
|
|
35
|
+
var _config_output, _config_server;
|
|
36
|
+
if ('development' === process.env.NODE_ENV) return;
|
|
37
|
+
const { middlewares } = api.getServerContext();
|
|
38
|
+
const config = api.getServerConfig();
|
|
39
|
+
const assetPrefix = (null == (_config_output = config.output) ? void 0 : _config_output.assetPrefix) || '';
|
|
40
|
+
if (null == (_config_server = config.server) ? void 0 : _config_server.ssr) {
|
|
41
|
+
const context = api.getServerContext();
|
|
42
|
+
const pwd = context.distDirectory;
|
|
43
|
+
const serverStaticMiddleware = (0, external_staticMiddleware_js_namespaceObject.createStaticMiddleware)({
|
|
44
|
+
assetPrefix,
|
|
45
|
+
pwd
|
|
46
|
+
});
|
|
47
|
+
middlewares.push({
|
|
48
|
+
name: 'module-federation-serve-manifest',
|
|
49
|
+
handler: serverStaticMiddleware
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (process.env.MODERN_MF_AUTO_CORS) {
|
|
53
|
+
const corsMiddleware = (0, external_staticMiddleware_js_namespaceObject.createCorsMiddleware)();
|
|
54
|
+
middlewares.push({
|
|
55
|
+
name: 'module-federation-cors',
|
|
56
|
+
handler: corsMiddleware
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const server = staticServePlugin;
|
|
63
|
+
exports["default"] = __webpack_exports__["default"];
|
|
64
|
+
exports.staticServePlugin = __webpack_exports__.staticServePlugin;
|
|
65
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
66
|
+
"default",
|
|
67
|
+
"staticServePlugin"
|
|
68
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
69
|
+
Object.defineProperty(exports, '__esModule', {
|
|
70
|
+
value: true
|
|
63
71
|
});
|
|
@@ -1,90 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
createStaticMiddleware: ()=>createStaticMiddleware,
|
|
37
|
+
createCorsMiddleware: ()=>createCorsMiddleware
|
|
33
38
|
});
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
49
|
-
const createStaticMiddleware = (options) => {
|
|
50
|
-
const { assetPrefix, pwd } = options;
|
|
51
|
-
return async (c, next) => {
|
|
52
|
-
const pathname = c.req.path;
|
|
53
|
-
if (import_node_path.default.extname(pathname) !== ".js") {
|
|
54
|
-
return next();
|
|
55
|
-
}
|
|
56
|
-
const prefixWithoutHost = removeHost(assetPrefix);
|
|
57
|
-
const prefixWithBundle = import_node_path.default.join(prefixWithoutHost, bundlesAssetPrefix);
|
|
58
|
-
if (!pathname.startsWith(prefixWithBundle)) {
|
|
59
|
-
return next();
|
|
39
|
+
const external_fs_extra_namespaceObject = require("fs-extra");
|
|
40
|
+
var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
|
|
41
|
+
const external_path_namespaceObject = require("path");
|
|
42
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
43
|
+
const external_fileCache_js_namespaceObject = require("./fileCache.js");
|
|
44
|
+
const bundlesAssetPrefix = '/bundles';
|
|
45
|
+
const removeHost = (url)=>{
|
|
46
|
+
try {
|
|
47
|
+
const hasProtocol = url.includes('://');
|
|
48
|
+
const hasDomain = hasProtocol || url.startsWith('//');
|
|
49
|
+
const pathname = hasDomain ? new URL(hasProtocol ? url : `http:${url}`).pathname : url;
|
|
50
|
+
return pathname;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
return url;
|
|
60
53
|
}
|
|
61
|
-
const pathnameWithoutPrefix = pathname.replace(prefixWithBundle, "");
|
|
62
|
-
const filepath = import_node_path.default.join(pwd, bundlesAssetPrefix, pathnameWithoutPrefix);
|
|
63
|
-
if (!await import_fs_extra.default.pathExists(filepath)) {
|
|
64
|
-
return next();
|
|
65
|
-
}
|
|
66
|
-
const fileResult = await import_fileCache.fileCache.getFile(filepath);
|
|
67
|
-
if (!fileResult) {
|
|
68
|
-
return next();
|
|
69
|
-
}
|
|
70
|
-
c.header("Content-Type", "application/javascript");
|
|
71
|
-
c.header("Content-Length", String(fileResult.content.length));
|
|
72
|
-
return c.body(fileResult.content, 200);
|
|
73
|
-
};
|
|
74
54
|
};
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
55
|
+
const createStaticMiddleware = (options)=>{
|
|
56
|
+
const { assetPrefix, pwd } = options;
|
|
57
|
+
return async (c, next)=>{
|
|
58
|
+
const pathname = c.req.path;
|
|
59
|
+
if ('.js' !== external_path_default().extname(pathname)) return next();
|
|
60
|
+
const prefixWithoutHost = removeHost(assetPrefix);
|
|
61
|
+
const prefixWithBundle = external_path_default().join(prefixWithoutHost, bundlesAssetPrefix);
|
|
62
|
+
if (!pathname.startsWith(prefixWithBundle)) return next();
|
|
63
|
+
const pathnameWithoutPrefix = pathname.replace(prefixWithBundle, '');
|
|
64
|
+
const filepath = external_path_default().join(pwd, bundlesAssetPrefix, pathnameWithoutPrefix);
|
|
65
|
+
if (!await external_fs_extra_default().pathExists(filepath)) return next();
|
|
66
|
+
const fileResult = await external_fileCache_js_namespaceObject.fileCache.getFile(filepath);
|
|
67
|
+
if (!fileResult) return next();
|
|
68
|
+
c.header('Content-Type', "application/javascript");
|
|
69
|
+
c.header('Content-Length', String(fileResult.content.length));
|
|
70
|
+
return c.body(fileResult.content, 200);
|
|
71
|
+
};
|
|
85
72
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
73
|
+
const createCorsMiddleware = ()=>async (c, next)=>{
|
|
74
|
+
const pathname = c.req.path;
|
|
75
|
+
if (external_path_default().extname(pathname)) {
|
|
76
|
+
c.header('Access-Control-Allow-Origin', '*');
|
|
77
|
+
c.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
|
78
|
+
c.header('Access-Control-Allow-Headers', '*');
|
|
79
|
+
}
|
|
80
|
+
return next();
|
|
81
|
+
};
|
|
82
|
+
exports.createCorsMiddleware = __webpack_exports__.createCorsMiddleware;
|
|
83
|
+
exports.createStaticMiddleware = __webpack_exports__.createStaticMiddleware;
|
|
84
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
85
|
+
"createCorsMiddleware",
|
|
86
|
+
"createStaticMiddleware"
|
|
87
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
88
|
+
Object.defineProperty(exports, '__esModule', {
|
|
89
|
+
value: true
|
|
90
90
|
});
|