@module-federation/utilities 1.8.0 → 1.8.1-rc.1
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 +174 -0
- package/package.json +4 -1
- package/src/Logger.js +8 -10
- package/src/Logger.js.map +1 -1
- package/src/components/ErrorBoundary.js +13 -16
- package/src/components/ErrorBoundary.js.map +1 -1
- package/src/components/FederationBoundary.js +13 -15
- package/src/components/FederationBoundary.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -1
- package/src/index.js.map +1 -1
- package/src/plugins/DelegateModulesPlugin.d.ts +26 -0
- package/src/plugins/DelegateModulesPlugin.js +88 -0
- package/src/plugins/DelegateModulesPlugin.js.map +1 -0
- package/src/types/index.d.ts +3 -1
- package/src/utils/common.d.ts +4 -1
- package/src/utils/common.js +193 -190
- package/src/utils/common.js.map +1 -1
- package/src/utils/correctImportPath.js +5 -5
- package/src/utils/correctImportPath.js.map +1 -1
- package/src/utils/getRuntimeRemotes.d.ts +2 -0
- package/src/utils/getRuntimeRemotes.js +50 -0
- package/src/utils/getRuntimeRemotes.js.map +1 -0
- package/src/utils/importDelegatedModule.d.ts +2 -0
- package/src/utils/importDelegatedModule.js +77 -0
- package/src/utils/importDelegatedModule.js.map +1 -0
- package/src/utils/importRemote.js +66 -101
- package/src/utils/importRemote.js.map +1 -1
- package/src/utils/isEmpty.js +2 -2
- package/src/utils/isEmpty.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,180 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.8.1-rc.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.1-rc.0...utils-1.8.1-rc.1) (2023-05-23)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [1.8.1-rc.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.0...utils-1.8.1-rc.0) (2023-05-23)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* client prod build issues ([#899](https://github.com/module-federation/nextjs-mf/issues/899)) ([470d7ad](https://github.com/module-federation/nextjs-mf/commit/470d7ad408ae8d64dbccc5a9528eaa2ed60fa2ca))
|
|
15
|
+
* externalization and missing runtime chunks ([#887](https://github.com/module-federation/nextjs-mf/issues/887)) ([c79cd62](https://github.com/module-federation/nextjs-mf/commit/c79cd6226d3134f1d6294cd8eba40c8c33af5cb5))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [1.7.6-rc.2](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.6-rc.1...utils-1.7.6-rc.2) (2023-05-17)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [1.7.6-rc.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.6-rc.0...utils-1.7.6-rc.1) (2023-05-17)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## [1.7.6-rc.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.6-beta.2...utils-1.7.6-rc.0) (2023-05-16)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## [1.7.6-beta.2](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.6-beta.1...utils-1.7.6-beta.2) (2023-05-16)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## [1.7.6-beta.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.6-beta.0...utils-1.7.6-beta.1) (2023-05-16)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [1.7.6-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.5...utils-1.7.6-beta.0) (2023-05-16)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## [1.7.5](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.5-beta.0...utils-1.7.5) (2023-05-16)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## [1.7.5-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.4...utils-1.7.5-beta.0) (2023-05-16)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* Improved Share Scope Properties and Fixed Production Build Issues ([#884](https://github.com/module-federation/nextjs-mf/issues/884)) ([de7b2ce](https://github.com/module-federation/nextjs-mf/commit/de7b2cec7518f6b069818a511275e359c616bb73))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## [1.7.4](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.3...utils-1.7.4) (2023-05-16)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## [1.7.3](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.3-beta.0...utils-1.7.3) (2023-05-13)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## [1.7.3-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.2...utils-1.7.3-beta.0) (2023-05-13)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Features
|
|
68
|
+
|
|
69
|
+
* [v7] Async boundary runtime ([#835](https://github.com/module-federation/nextjs-mf/issues/835)) ([840e3b5](https://github.com/module-federation/nextjs-mf/commit/840e3b5bddfbb99b5d8d0f5f24bf5e179e8b52ad)), closes [#851](https://github.com/module-federation/nextjs-mf/issues/851) [#864](https://github.com/module-federation/nextjs-mf/issues/864)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### BREAKING CHANGES
|
|
73
|
+
|
|
74
|
+
* automaticAsyncBoundary option has been removed
|
|
75
|
+
|
|
76
|
+
* fix: exclude specific pages from page map automatically
|
|
77
|
+
|
|
78
|
+
* refactor: conslidate codebase
|
|
79
|
+
|
|
80
|
+
* fix: improve hot reload share recovery
|
|
81
|
+
|
|
82
|
+
* refactor: remove server jsonp template
|
|
83
|
+
|
|
84
|
+
* chore: remove dead code from runtime modules
|
|
85
|
+
|
|
86
|
+
* fix: clean up jsonp getCustomJsonpCode
|
|
87
|
+
|
|
88
|
+
getting chunk loading global from compiler output options
|
|
89
|
+
|
|
90
|
+
* feat: adding cleanInitArrays runtime helper
|
|
91
|
+
|
|
92
|
+
* chore: remove share scope hoist and module hoisting system
|
|
93
|
+
|
|
94
|
+
* chore: cleanup code
|
|
95
|
+
|
|
96
|
+
* chore: remove dead code from add module runtime plugin
|
|
97
|
+
|
|
98
|
+
likely can remove whole plugin in future
|
|
99
|
+
|
|
100
|
+
* chore: remove logs from delegate modules
|
|
101
|
+
|
|
102
|
+
* chore: remove old utils
|
|
103
|
+
|
|
104
|
+
* fix: add warning on auto page stitch
|
|
105
|
+
|
|
106
|
+
* fix: remove commented out code from InvertedContainerPlugin.ts
|
|
107
|
+
|
|
108
|
+
* chore: improve logging to see if its local load or remote load
|
|
109
|
+
|
|
110
|
+
* chore: clean up old custom promises factories
|
|
111
|
+
|
|
112
|
+
* fix: remove container proxy code
|
|
113
|
+
|
|
114
|
+
* fix: remove container proxy code
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
## [1.7.2](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.2-beta.0...utils-1.7.2) (2023-05-03)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## [1.7.2-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.1...utils-1.7.2-beta.0) (2023-05-03)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## [1.7.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.1-beta.0...utils-1.7.1) (2023-04-28)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
## [1.7.1-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.0...utils-1.7.1-beta.0) (2023-04-28)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
### Features
|
|
134
|
+
|
|
135
|
+
* Improve module chunk connections ([#802](https://github.com/module-federation/nextjs-mf/issues/802)) ([ce0bd7b](https://github.com/module-federation/nextjs-mf/commit/ce0bd7b16e080f712e6db0bdcd3955a8167c274f)), closes [#803](https://github.com/module-federation/nextjs-mf/issues/803) [#808](https://github.com/module-federation/nextjs-mf/issues/808) [#811](https://github.com/module-federation/nextjs-mf/issues/811)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
## [1.5.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.5.1-beta.0...utils-1.5.1) (2023-04-19)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
## [1.5.1-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.5.0...utils-1.5.1-beta.0) (2023-04-19)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
### Bug Fixes
|
|
147
|
+
|
|
148
|
+
* use container proxy on script VM instead of host resolver point ([2929d0f](https://github.com/module-federation/nextjs-mf/commit/2929d0f64d4b8edf268af5ca83f807a02b121861))
|
|
149
|
+
* cache busting and async quirks when mixing delegates ([1fc6e67](https://github.com/module-federation/nextjs-mf/commit/1fc6e67ee33a3efb53ff59d2b3ac333f1d42a158))
|
|
150
|
+
* get delegates working ([#527](https://github.com/module-federation/nextjs-mf/issues/527)) ([7655568](https://github.com/module-federation/nextjs-mf/commit/7655568fcef8dbfda40573deb5d3d029c101074c))
|
|
151
|
+
* improved asset pipeline ([63928b2](https://github.com/module-federation/nextjs-mf/commit/63928b28150c2c4e3adb9e14fb7aa54f5cf1578d))
|
|
152
|
+
* peer dependencies metadata ([d3a2ed0](https://github.com/module-federation/nextjs-mf/commit/d3a2ed0e378b59afdeb632d1e2e0290f05cbca19))
|
|
153
|
+
* put error triggers if delegates are passed non-primitives ([2469383](https://github.com/module-federation/nextjs-mf/commit/2469383de68a8b6ffb7375ad335a2039e563fd71))
|
|
154
|
+
* use EntryPlugin for injection of remotes ([e522c5a](https://github.com/module-federation/nextjs-mf/commit/e522c5ad2b7adcbd6c39f9c5fdb7a3e418277b7a))
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
### Features
|
|
158
|
+
|
|
159
|
+
* chunk flushing in delegates ([07aebc4](https://github.com/module-federation/nextjs-mf/commit/07aebc428166b3f19bb49071fa6745ed705413b8))
|
|
160
|
+
* chunk flushing in delegates ([f8b8af6](https://github.com/module-federation/nextjs-mf/commit/f8b8af6e9e748605dd55d19ae50b0d60b1b0a83f))
|
|
161
|
+
* chunk flushing in delegates ([5e2375f](https://github.com/module-federation/nextjs-mf/commit/5e2375f598437803105ac4bc2237f6b652554d00))
|
|
162
|
+
* delegate module support ([18c9491](https://github.com/module-federation/nextjs-mf/commit/18c94914e5429584e66be49d92781b781adddb38))
|
|
163
|
+
* delegate module support ([8dd154c](https://github.com/module-federation/nextjs-mf/commit/8dd154c261b34183b12250ce204904cd3e085658))
|
|
164
|
+
* delegates part two ([1be2686](https://github.com/module-federation/nextjs-mf/commit/1be2686624798a7df9f447b48279294985b3f592))
|
|
165
|
+
* implement basic single runtime ([2432c3e](https://github.com/module-federation/nextjs-mf/commit/2432c3ec553759ca24d17a46b696c1123a86ec5a))
|
|
166
|
+
* improve chunk correlation ([22d8afc](https://github.com/module-federation/nextjs-mf/commit/22d8afccff101044fcdeba390656950dbc6eafed))
|
|
167
|
+
* new chunk flushing system for exposed modules ([97a75d8](https://github.com/module-federation/nextjs-mf/commit/97a75d8702f2ddc5e12cff2ac4d24aca1df6f990))
|
|
168
|
+
* prepare for v7 ([7bc4b3b](https://github.com/module-federation/nextjs-mf/commit/7bc4b3bd44e0926a52d6a9cbe56f0c4d7bb700ae))
|
|
169
|
+
* support dynamic containers on server ([a2a81dd](https://github.com/module-federation/nextjs-mf/commit/a2a81dd4d54da55dfc132583d9e0d7c75771fb4c))
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
### BREAKING CHANGES
|
|
173
|
+
|
|
174
|
+
* safety breaking change note
|
|
175
|
+
BREAKING_CHANGE: safety breaking change note
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
5
179
|
# [1.8.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.0...utils-1.8.0) (2023-05-22)
|
|
6
180
|
|
|
7
181
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/utilities",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1-rc.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -29,5 +29,8 @@
|
|
|
29
29
|
"react-dom": {
|
|
30
30
|
"optional": true
|
|
31
31
|
}
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"webpack-sources": "3.2.3"
|
|
32
35
|
}
|
|
33
36
|
}
|
package/src/Logger.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Logger = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
Logger.getLogger = function () {
|
|
4
|
+
class Logger {
|
|
5
|
+
static getLogger() {
|
|
8
6
|
return this.loggerInstance;
|
|
9
|
-
}
|
|
10
|
-
|
|
7
|
+
}
|
|
8
|
+
static setLogger(logger) {
|
|
11
9
|
this.loggerInstance = logger || console;
|
|
12
10
|
return logger;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
Logger.loggerInstance = console;
|
|
14
|
+
exports.Logger = Logger;
|
|
17
15
|
//# sourceMappingURL=Logger.js.map
|
package/src/Logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../../packages/utilities/src/Logger.ts"],"names":[],"mappings":";;;AAIA;
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../../packages/utilities/src/Logger.ts"],"names":[],"mappings":";;;AAIA,MAAa,MAAM;IAGjB,MAAM,CAAC,SAAS;QACd,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAA6B;QAC5C,IAAI,CAAC,cAAc,GAAG,MAAM,IAAI,OAAO,CAAC;QACxC,OAAO,MAAM,CAAC;IAChB,CAAC;;AATc,qBAAc,GAAmB,OAAO,CAAC;AAD7C,wBAAM"}
|
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
5
|
/**
|
|
6
6
|
* Generic error boundary component.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
_this.state = {
|
|
8
|
+
class ErrorBoundary extends react_1.default.Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.state = {
|
|
13
12
|
hasError: false,
|
|
14
13
|
};
|
|
15
|
-
return _this;
|
|
16
14
|
}
|
|
17
|
-
|
|
15
|
+
static getDerivedStateFromError( /*error: Error*/) {
|
|
18
16
|
return {
|
|
19
17
|
hasError: true,
|
|
20
18
|
};
|
|
21
|
-
}
|
|
22
|
-
|
|
19
|
+
}
|
|
20
|
+
componentDidCatch(error, errorInfo) {
|
|
23
21
|
console.error(error, errorInfo);
|
|
24
|
-
}
|
|
25
|
-
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
26
24
|
if (this.state.hasError) {
|
|
27
25
|
return 'An error has occurred.';
|
|
28
26
|
}
|
|
29
27
|
return this.props.children;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
}(react_1.default.Component));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
33
30
|
exports.default = ErrorBoundary;
|
|
34
31
|
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/components/ErrorBoundary.tsx"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/components/ErrorBoundary.tsx"],"names":[],"mappings":";;;AAAA,0DAA8C;AAU9C;;GAEG;AACH,MAAM,aAAc,SAAQ,eAAK,CAAC,SAGjC;IACC,YAAY,KAAyB;QACnC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACX,QAAQ,EAAE,KAAK;SAChB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,wBAAwB,EAAC,gBAAgB;QAC9C,OAAO;YACL,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;IAEQ,iBAAiB,CAAC,KAAY,EAAE,SAAoB;QAC3D,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;IAEQ,MAAM;QACb,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,OAAO,wBAAwB,CAAC;SACjC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const dynamic_1 = tslib_1.__importDefault(require("next/dynamic"));
|
|
6
|
+
const ErrorBoundary_1 = tslib_1.__importDefault(require("./ErrorBoundary"));
|
|
7
7
|
/**
|
|
8
8
|
* A fallback component that renders nothing.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
const FallbackComponent = () => {
|
|
11
11
|
return null;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* Wrapper around dynamic import.
|
|
15
15
|
* Adds error boundaries and fallback options.
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
return (0, dynamic_1.default)(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
}, {
|
|
17
|
+
const FederationBoundary = (_a) => {
|
|
18
|
+
var { dynamicImporter, fallback = () => Promise.resolve(FallbackComponent), customBoundary: CustomBoundary = ErrorBoundary_1.default } = _a, rest = tslib_1.__rest(_a, ["dynamicImporter", "fallback", "customBoundary"]);
|
|
19
|
+
const ImportResult = (0, react_1.useMemo)(() => {
|
|
20
|
+
return (0, dynamic_1.default)(() => dynamicImporter().catch((e) => {
|
|
21
|
+
console.error(e);
|
|
22
|
+
return fallback();
|
|
23
|
+
}), {
|
|
26
24
|
ssr: false,
|
|
27
25
|
});
|
|
28
26
|
}, [dynamicImporter, fallback]);
|
|
29
27
|
return (react_1.default.createElement(CustomBoundary, null,
|
|
30
|
-
react_1.default.createElement(ImportResult,
|
|
28
|
+
react_1.default.createElement(ImportResult, Object.assign({}, rest))));
|
|
31
29
|
};
|
|
32
30
|
exports.default = FederationBoundary;
|
|
33
31
|
//# sourceMappingURL=FederationBoundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FederationBoundary.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/components/FederationBoundary.tsx"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"FederationBoundary.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/components/FederationBoundary.tsx"],"names":[],"mappings":";;;AAAA,uDAAuC;AAEvC,mEAAmC;AACnC,4EAA4C;AAE5C;;GAEG;AACH,MAAM,iBAAiB,GAAa,GAAG,EAAE;IACvC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAaF;;;GAGG;AACH,MAAM,kBAAkB,GAAsC,CAAC,EAK9D,EAAE,EAAE;QAL0D,EAC7D,eAAe,EACf,QAAQ,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,EACnD,cAAc,EAAE,cAAc,GAAG,uBAAa,OAE/C,EADI,IAAI,sBAJsD,iDAK9D,CADQ;IAEP,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,OAAO,IAAA,iBAAO,EACZ,GAAG,EAAE,CACH,eAAe,EAAE,CAAC,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE;YACnC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO,QAAQ,EAAE,CAAC;QACpB,CAAC,CAAC,EACJ;YACE,GAAG,EAAE,KAAK;SACX,CACF,CAAC;IACJ,CAAC,EAAE,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEhC,OAAO,CACL,8BAAC,cAAc;QACb,8BAAC,YAAY,oBAAK,IAAI,EAAI,CACX,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.getRuntimeRemotes = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
tslib_1.__exportStar(require("./types"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./utils/common"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./utils/isEmpty"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./utils/importRemote"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./utils/correctImportPath"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("./Logger"), exports);
|
|
11
|
+
var getRuntimeRemotes_1 = require("./utils/getRuntimeRemotes");
|
|
12
|
+
Object.defineProperty(exports, "getRuntimeRemotes", { enumerable: true, get: function () { return getRuntimeRemotes_1.getRuntimeRemotes; } });
|
|
10
13
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/utilities/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/utilities/src/index.ts"],"names":[],"mappings":";;;;AAAA,kDAAwB;AACxB,yDAA+B;AAC/B,0DAAgC;AAChC,+DAAqC;AACrC,oEAA0C;AAC1C,mDAAyB;AACzB,+DAA8D;AAArD,sHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Compiler, Compilation, Chunk, Module } from 'webpack';
|
|
2
|
+
/**
|
|
3
|
+
* A webpack plugin that moves specified modules from chunks to runtime chunk.
|
|
4
|
+
* @class DelegateModulesPlugin
|
|
5
|
+
*/
|
|
6
|
+
declare class DelegateModulesPlugin {
|
|
7
|
+
options: {
|
|
8
|
+
debug: boolean;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
_delegateModules: Set<Module>;
|
|
12
|
+
constructor(options: {
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
});
|
|
16
|
+
getChunkByName(chunks: Iterable<Chunk>, name: string): Chunk | undefined;
|
|
17
|
+
addDelegatesToChunks(compilation: Compilation, chunks: Chunk[]): void;
|
|
18
|
+
removeDelegatesNonRuntimeChunks(compilation: Compilation, chunks: Iterable<Chunk>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Applies the plugin to the webpack compiler.
|
|
21
|
+
* @param {Compiler} compiler - The webpack compiler instance.
|
|
22
|
+
*/
|
|
23
|
+
apply(compiler: Compiler): void;
|
|
24
|
+
resolveDelegateModules(compilation: Compilation): void;
|
|
25
|
+
}
|
|
26
|
+
export default DelegateModulesPlugin;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* A webpack plugin that moves specified modules from chunks to runtime chunk.
|
|
5
|
+
* @class DelegateModulesPlugin
|
|
6
|
+
*/
|
|
7
|
+
class DelegateModulesPlugin {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.options = Object.assign({ debug: false }, options);
|
|
10
|
+
this._delegateModules = new Set();
|
|
11
|
+
}
|
|
12
|
+
getChunkByName(chunks, name) {
|
|
13
|
+
for (const chunk of chunks) {
|
|
14
|
+
if (chunk.name == name) {
|
|
15
|
+
return chunk;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
addDelegatesToChunks(compilation, chunks) {
|
|
21
|
+
for (const chunk of chunks) {
|
|
22
|
+
this._delegateModules.forEach((module) => {
|
|
23
|
+
if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) {
|
|
24
|
+
this.options.debug &&
|
|
25
|
+
console.log('adding ', module.identifier(), ' to chunk', chunk.name);
|
|
26
|
+
compilation.chunkGraph.connectChunkAndModule(chunk, module);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
removeDelegatesNonRuntimeChunks(compilation, chunks) {
|
|
32
|
+
for (const chunk of chunks) {
|
|
33
|
+
if (!chunk.hasRuntime()) {
|
|
34
|
+
this.options.debug &&
|
|
35
|
+
console.log('non-runtime chunk:', chunk.debugId, chunk.id, chunk.name);
|
|
36
|
+
this._delegateModules.forEach((module) => {
|
|
37
|
+
compilation.chunkGraph.disconnectChunkAndModule(chunk, module);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Applies the plugin to the webpack compiler.
|
|
44
|
+
* @param {Compiler} compiler - The webpack compiler instance.
|
|
45
|
+
*/
|
|
46
|
+
apply(compiler) {
|
|
47
|
+
// Tap into compilation hooks
|
|
48
|
+
compiler.hooks.compilation.tap('DelegateModulesPlugin', (compilation) => {
|
|
49
|
+
// fills this._delegateModules set
|
|
50
|
+
this.resolveDelegateModules(compilation);
|
|
51
|
+
compilation.hooks.optimizeChunks.tap('DelegateModulesPlugin', (chunks) => {
|
|
52
|
+
// Change this line
|
|
53
|
+
const { runtime, container } = this.options;
|
|
54
|
+
const runtimeChunk = this.getChunkByName(chunks, runtime);
|
|
55
|
+
if (!runtimeChunk || !runtimeChunk.hasRuntime())
|
|
56
|
+
return;
|
|
57
|
+
// Get the container chunk if specified
|
|
58
|
+
const remoteContainer = container
|
|
59
|
+
? this.getChunkByName(chunks, container)
|
|
60
|
+
: null;
|
|
61
|
+
this.options.debug &&
|
|
62
|
+
console.log(remoteContainer === null || remoteContainer === void 0 ? void 0 : remoteContainer.name, runtimeChunk.name, this._delegateModules.size);
|
|
63
|
+
this.addDelegatesToChunks(compilation, [remoteContainer, runtimeChunk].filter(Boolean));
|
|
64
|
+
this.removeDelegatesNonRuntimeChunks(compilation, chunks);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
resolveDelegateModules(compilation) {
|
|
69
|
+
// Tap into the 'finish-modules' hook to access the module list after they are all processed
|
|
70
|
+
compilation.hooks.finishModules.tapAsync('ModuleIDFinderPlugin', (modules, callback) => {
|
|
71
|
+
const { remotes } = this.options;
|
|
72
|
+
// Get the delegate module names for remote chunks if specified
|
|
73
|
+
const knownDelegates = new Set(remotes
|
|
74
|
+
? Object.values(remotes).map((remote) => remote.replace('internal ', ''))
|
|
75
|
+
: []);
|
|
76
|
+
for (const module of modules) {
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
if (module.resource && knownDelegates.has(module.resource)) {
|
|
79
|
+
this._delegateModules.add(module);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Continue the process
|
|
83
|
+
callback();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.default = DelegateModulesPlugin;
|
|
88
|
+
//# sourceMappingURL=DelegateModulesPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DelegateModulesPlugin.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/plugins/DelegateModulesPlugin.ts"],"names":[],"mappings":";;AAQA;;;GAGG;AACH,MAAM,qBAAqB;IAIzB,YAAY,OAAgD;QAC1D,IAAI,CAAC,OAAO,mBAAK,KAAK,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;QAC5C,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;IACpC,CAAC;IAED,cAAc,CAAC,MAAuB,EAAE,IAAY;QAClD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE;gBACtB,OAAO,KAAK,CAAC;aACd;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,oBAAoB,CAAC,WAAwB,EAAE,MAAe;QAC5D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBACvC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;oBAC1D,IAAI,CAAC,OAAO,CAAC,KAAK;wBAChB,OAAO,CAAC,GAAG,CACT,SAAS,EACT,MAAM,CAAC,UAAU,EAAE,EACnB,WAAW,EACX,KAAK,CAAC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QAAQ,EAAE,CAAC;QACb,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AACD,kBAAe,qBAAqB,CAAC"}
|
package/src/types/index.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export interface NextFederationPluginExtraOptions {
|
|
|
19
19
|
exposePages?: boolean;
|
|
20
20
|
skipSharingNextInternals?: boolean;
|
|
21
21
|
automaticPageStitching?: boolean;
|
|
22
|
-
automaticAsyncBoundary?: boolean;
|
|
23
22
|
}
|
|
24
23
|
export interface NextFederationPluginOptions extends ModuleFederationPluginOptions {
|
|
25
24
|
extraOptions: NextFederationPluginExtraOptions;
|
|
@@ -45,6 +44,8 @@ export type RemoteData = {
|
|
|
45
44
|
};
|
|
46
45
|
export type RuntimeRemote = Partial<RemoteData> & {
|
|
47
46
|
asyncContainer?: AsyncContainer;
|
|
47
|
+
global?: string;
|
|
48
|
+
url?: string;
|
|
48
49
|
};
|
|
49
50
|
export type RuntimeRemotesMap = Record<string, RuntimeRemote>;
|
|
50
51
|
type Module = WebpackOptionsNormalized['module'];
|
|
@@ -64,4 +65,5 @@ export type GetModuleOptions = {
|
|
|
64
65
|
exportName?: string;
|
|
65
66
|
remoteContainer: string | RemoteData;
|
|
66
67
|
};
|
|
68
|
+
export type RemoteVars = Record<string, Promise<WebpackRemoteContainer> | string | (() => Promise<WebpackRemoteContainer>)>;
|
|
67
69
|
export {};
|
package/src/utils/common.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GetModuleOptions, RemoteData, Remotes, RuntimeRemote, WebpackRemoteContainer } from '../types';
|
|
2
|
+
import { RemoteVars } from '../types';
|
|
3
|
+
export declare const remoteVars: RemoteVars;
|
|
2
4
|
export declare const extractUrlAndGlobal: (urlAndGlobal: string) => [string, string];
|
|
3
5
|
export declare const importDelegatedModule: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => Promise<any>;
|
|
4
6
|
export declare const createDelegatedModule: (delegate: string, params: {
|
|
5
7
|
[key: string]: any;
|
|
6
8
|
}) => string;
|
|
9
|
+
export declare const loadScript: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => any;
|
|
7
10
|
/**
|
|
8
11
|
* Return initialized remote container by remote's key or its runtime remote item data.
|
|
9
12
|
*
|