@module-federation/utilities 1.1.2 → 1.2.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 +38 -85
- package/README.md +27 -5
- package/package.json +6 -4
- package/src/Logger.d.ts +1 -1
- package/src/components/ErrorBoundary.d.ts +19 -0
- package/src/components/ErrorBoundary.js +34 -0
- package/src/components/ErrorBoundary.js.map +1 -0
- package/src/components/FederationBoundary.d.ts +14 -0
- package/src/components/FederationBoundary.js +33 -0
- package/src/components/FederationBoundary.js.map +1 -0
- package/src/types/index.d.ts +27 -22
- package/src/utils/common.d.ts +14 -1
- package/src/utils/common.js +79 -1
- package/src/utils/common.js.map +1 -1
- package/src/utils/importRemote.d.ts +1 -1
- package/src/utils/importRemote.js +7 -6
- package/src/utils/importRemote.js.map +1 -1
- package/src/utils/react.d.ts +1 -10
- package/src/utils/react.js +5 -38
- package/src/utils/react.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,66 +2,67 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
-
## [1.1
|
|
5
|
+
## [1.2.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.2.0...utils-1.2.1) (2023-02-09)
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
### Bug Fixes
|
|
9
9
|
|
|
10
|
-
*
|
|
10
|
+
* **federation-boundary:** make custom boundary optional ([#570](https://github.com/module-federation/nextjs-mf/issues/570)) ([e43a387](https://github.com/module-federation/nextjs-mf/commit/e43a387f90587d62a78c40584ed9104328202f8e))
|
|
11
|
+
* **utilities:** fix FederationBoundary implementation ([#575](https://github.com/module-federation/nextjs-mf/issues/575)) ([b94fc28](https://github.com/module-federation/nextjs-mf/commit/b94fc282503c4f5ce2ae267518f7d6f5d4746c24))
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
# [1.2.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.1.2...utils-1.2.0) (2023-01-31)
|
|
15
16
|
|
|
17
|
+
### Bug Fixes
|
|
16
18
|
|
|
19
|
+
- **typescript:** throw error when `vue-tsc` is requested and is not available ([#547](https://github.com/module-federation/nextjs-mf/issues/547)) ([c6f7998](https://github.com/module-federation/nextjs-mf/commit/c6f79981f84fd0042447037c1323fa750566ac0d))
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
### Features
|
|
19
22
|
|
|
23
|
+
- add getModule and getContainer to utilities ([#476](https://github.com/module-federation/nextjs-mf/issues/476)) ([fe381e3](https://github.com/module-federation/nextjs-mf/commit/fe381e33cfb20b3b723daffca2f5c4fb4b843cfb))
|
|
24
|
+
- **typescript:** support vue typescript compiler ([#542](https://github.com/module-federation/nextjs-mf/issues/542)) ([cde5952](https://github.com/module-federation/nextjs-mf/commit/cde5952c42ec19f87c5bc4dddb8d8be6f97c1c55)), closes [#502](https://github.com/module-federation/nextjs-mf/issues/502)
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
## [1.1.2](https://github.com/module-federation/nextjs-mf/compare/utils-1.1.1...utils-1.1.2) (2023-01-21)
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
* **utilities:** set webpack peer dep to ^5.40.0 ([#473](https://github.com/module-federation/nextjs-mf/issues/473)) ([d1ae77e](https://github.com/module-federation/nextjs-mf/commit/d1ae77e63993b6f67d329bce5a30d04776a02b76))
|
|
28
|
+
### Bug Fixes
|
|
25
29
|
|
|
30
|
+
- Utilities - Remove module side effect ([#488](https://github.com/module-federation/nextjs-mf/issues/488)) ([3554de7](https://github.com/module-federation/nextjs-mf/commit/3554de7912eaf7b379a6a863677c4b01da0ccf2c)), closes [#487](https://github.com/module-federation/nextjs-mf/issues/487) [#500](https://github.com/module-federation/nextjs-mf/issues/500) [#496](https://github.com/module-federation/nextjs-mf/issues/496) [#495](https://github.com/module-federation/nextjs-mf/issues/495) [#492](https://github.com/module-federation/nextjs-mf/issues/492) [#455](https://github.com/module-federation/nextjs-mf/issues/455) [#491](https://github.com/module-federation/nextjs-mf/issues/491) [#496](https://github.com/module-federation/nextjs-mf/issues/496) [#495](https://github.com/module-federation/nextjs-mf/issues/495)
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
## [1.1.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.1.0...utils-1.1.1) (2023-01-11)
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
# [1.1.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.0.4...utils-1.1.0) (2022-12-30)
|
|
30
35
|
|
|
36
|
+
### Bug Fixes
|
|
31
37
|
|
|
38
|
+
- **utilities:** move tslib from peer deps into deps ([#474](https://github.com/module-federation/nextjs-mf/issues/474)) ([792806c](https://github.com/module-federation/nextjs-mf/commit/792806c805c746cd681d6345bec88a47462cb26f))
|
|
39
|
+
- **utilities:** set webpack peer dep to ^5.40.0 ([#473](https://github.com/module-federation/nextjs-mf/issues/473)) ([d1ae77e](https://github.com/module-federation/nextjs-mf/commit/d1ae77e63993b6f67d329bce5a30d04776a02b76))
|
|
32
40
|
|
|
33
|
-
|
|
41
|
+
### Features
|
|
34
42
|
|
|
43
|
+
- Utilities - Add async callback to importRemote ([#459](https://github.com/module-federation/nextjs-mf/issues/459)) ([508d83c](https://github.com/module-federation/nextjs-mf/commit/508d83ca1060e1fcc80cde44978b186bdf1feefc)), closes [#461](https://github.com/module-federation/nextjs-mf/issues/461) [#451](https://github.com/module-federation/nextjs-mf/issues/451) [#463](https://github.com/module-federation/nextjs-mf/issues/463)
|
|
35
44
|
|
|
45
|
+
## [1.0.4](https://github.com/module-federation/nextjs-mf/compare/utils-1.0.3...utils-1.0.4) (2022-12-29)
|
|
36
46
|
|
|
37
47
|
## [1.0.3](https://github.com/module-federation/nextjs-mf/compare/utils-1.0.2...utils-1.0.3) (2022-12-27)
|
|
38
48
|
|
|
39
|
-
|
|
40
49
|
### Bug Fixes
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
- bad references to webpack globals ([#458](https://github.com/module-federation/nextjs-mf/issues/458)) ([8ef224b](https://github.com/module-federation/nextjs-mf/commit/8ef224bd08f1e39475cac3795f09debae50bbc0f))
|
|
45
52
|
|
|
46
53
|
## [1.0.2](https://github.com/module-federation/nextjs-mf/compare/utils-1.0.1...utils-1.0.2) (2022-12-27)
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
|
|
50
55
|
## [1.0.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.0.0...utils-1.0.1) (2022-11-20)
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
54
57
|
# [1.0.0](https://github.com/module-federation/nextjs-mf/compare/utils-0.5.0...utils-1.0.0) (2022-11-20)
|
|
55
58
|
|
|
56
|
-
|
|
57
59
|
### Features
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
- **typescript:** excessive recompilation prevention ([#306](https://github.com/module-federation/nextjs-mf/issues/306)) ([6e1967f](https://github.com/module-federation/nextjs-mf/commit/6e1967f019afb25dfbcfe83627b08ae8b1fe97b2))
|
|
61
62
|
|
|
62
63
|
### BREAKING CHANGES
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
- **typescript:** Reimplemented the whole plugin from round-up to enhance performance, prevent excessive recompilation and other issues.
|
|
65
66
|
|
|
66
67
|
Some key changes to the plugin includes:
|
|
67
68
|
|
|
@@ -71,19 +72,15 @@ Some key changes to the plugin includes:
|
|
|
71
72
|
|
|
72
73
|
Please go through plugin `readme.md` file to understand what's changed and how to use the plugin.
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
75
|
# [1.0.0](https://github.com/module-federation/nextjs-mf/compare/utils-0.5.0...utils-1.0.0) (2022-11-20)
|
|
77
76
|
|
|
78
|
-
|
|
79
77
|
### Features
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
- **typescript:** excessive recompilation prevention ([#306](https://github.com/module-federation/nextjs-mf/issues/306)) ([6e1967f](https://github.com/module-federation/nextjs-mf/commit/6e1967f019afb25dfbcfe83627b08ae8b1fe97b2))
|
|
83
80
|
|
|
84
81
|
### BREAKING CHANGES
|
|
85
82
|
|
|
86
|
-
|
|
83
|
+
- **typescript:** Reimplemented the whole plugin from round-up to enhance performance, prevent excessive recompilation and other issues.
|
|
87
84
|
|
|
88
85
|
Some key changes to the plugin includes:
|
|
89
86
|
|
|
@@ -93,125 +90,81 @@ Some key changes to the plugin includes:
|
|
|
93
90
|
|
|
94
91
|
Please go through plugin `readme.md` file to understand what's changed and how to use the plugin.
|
|
95
92
|
|
|
96
|
-
|
|
97
|
-
|
|
98
93
|
# [0.5.0](https://github.com/module-federation/nextjs-mf/compare/utils-0.4.1...utils-0.5.0) (2022-10-31)
|
|
99
94
|
|
|
100
|
-
|
|
101
95
|
### Features
|
|
102
96
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
- **utils:** configurable logger using webpack infrastructure logger ([#355](https://github.com/module-federation/nextjs-mf/issues/355)) ([d6ffcd0](https://github.com/module-federation/nextjs-mf/commit/d6ffcd0de1662c410f33a7742db1fd02aba24aef)), closes [#243](https://github.com/module-federation/nextjs-mf/issues/243)
|
|
106
98
|
|
|
107
99
|
## [0.4.1](https://github.com/module-federation/nextjs-mf/compare/utils-0.4.0...utils-0.4.1) (2022-10-26)
|
|
108
100
|
|
|
109
|
-
|
|
110
101
|
### Bug Fixes
|
|
111
102
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
103
|
+
- set peer dependencies ([#341](https://github.com/module-federation/nextjs-mf/issues/341)) ([fec9608](https://github.com/module-federation/nextjs-mf/commit/fec960813a4e3859a5fb24863bb55e463a2fdfa3))
|
|
115
104
|
|
|
116
105
|
# [0.4.0](https://github.com/module-federation/nextjs-mf/compare/utils-0.3.4...utils-0.4.0) (2022-10-26)
|
|
117
106
|
|
|
118
|
-
|
|
119
107
|
### Features
|
|
120
108
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
109
|
+
- Automatic Async boundary loader ([#330](https://github.com/module-federation/nextjs-mf/issues/330)) ([7e3c08c](https://github.com/module-federation/nextjs-mf/commit/7e3c08cf7835c0407bdce7ed6865b864153074a4))
|
|
124
110
|
|
|
125
111
|
## [0.3.4](https://github.com/module-federation/nextjs-mf/compare/utils-0.3.3...utils-0.3.4) (2022-10-17)
|
|
126
112
|
|
|
127
|
-
|
|
128
113
|
### Bug Fixes
|
|
129
114
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
115
|
+
- remove exports field from package.json ([#318](https://github.com/module-federation/nextjs-mf/issues/318)) ([a9148ae](https://github.com/module-federation/nextjs-mf/commit/a9148ae27f1c05fe4c1586ed5769c79054a7033e))
|
|
133
116
|
|
|
134
117
|
## [0.3.3](https://github.com/module-federation/nextjs-mf/compare/utils-0.3.2...utils-0.3.3) (2022-10-13)
|
|
135
118
|
|
|
136
|
-
|
|
137
119
|
### Bug Fixes
|
|
138
120
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
121
|
+
- **typescript:** fix exposePages type ([#309](https://github.com/module-federation/nextjs-mf/issues/309)) ([c0be839](https://github.com/module-federation/nextjs-mf/commit/c0be839787f97c5e23cea3d7cf501caaa469972f))
|
|
142
122
|
|
|
143
123
|
## [0.3.2](https://github.com/module-federation/nextjs-mf/compare/utils-0.3.1...utils-0.3.2) (2022-10-12)
|
|
144
124
|
|
|
145
|
-
|
|
146
|
-
|
|
147
125
|
## [0.3.1](https://github.com/module-federation/nextjs-mf/compare/utils-0.3.0...utils-0.3.1) (2022-10-11)
|
|
148
126
|
|
|
149
|
-
|
|
150
|
-
|
|
151
127
|
# [0.3.0](https://github.com/module-federation/nextjs-mf/compare/utils-0.2.1...utils-0.3.0) (2022-10-07)
|
|
152
128
|
|
|
153
|
-
|
|
154
129
|
### Features
|
|
155
130
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
131
|
+
- implement **webpack_require**.l functionality in server builds ([99d1231](https://github.com/module-federation/nextjs-mf/commit/99d12314f68ac526000fa5410a14072a11b260a4))
|
|
159
132
|
|
|
160
133
|
## [0.2.1](https://github.com/module-federation/nextjs-mf/compare/utils-0.2.0...utils-0.2.1) (2022-10-07)
|
|
161
134
|
|
|
162
|
-
|
|
163
135
|
### Bug Fixes
|
|
164
136
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
137
|
+
- fix node plugin fs augments when outside next child compiler ([#284](https://github.com/module-federation/nextjs-mf/issues/284)) ([dfa99c8](https://github.com/module-federation/nextjs-mf/commit/dfa99c86fdd8d73091764532d52be5f81b89a508))
|
|
138
|
+
- **package.json:** fix package export fields for utils ([#285](https://github.com/module-federation/nextjs-mf/issues/285)) ([99d6b77](https://github.com/module-federation/nextjs-mf/commit/99d6b779696b5dbebea9cf3c870a5caa5d9d7c6f))
|
|
169
139
|
|
|
170
140
|
## [0.2.1](https://github.com/module-federation/nextjs-mf/compare/utils-0.2.0...utils-0.2.1) (2022-10-07)
|
|
171
141
|
|
|
172
|
-
|
|
173
142
|
### Bug Fixes
|
|
174
143
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
144
|
+
- fix node plugin fs augments when outside next child compiler ([#284](https://github.com/module-federation/nextjs-mf/issues/284)) ([dfa99c8](https://github.com/module-federation/nextjs-mf/commit/dfa99c86fdd8d73091764532d52be5f81b89a508))
|
|
145
|
+
- **package.json:** fix package export fields for utils ([#285](https://github.com/module-federation/nextjs-mf/issues/285)) ([99d6b77](https://github.com/module-federation/nextjs-mf/commit/99d6b779696b5dbebea9cf3c870a5caa5d9d7c6f))
|
|
179
146
|
|
|
180
147
|
## [0.2.1](https://github.com/module-federation/nextjs-mf/compare/utils-0.2.0...utils-0.2.1) (2022-10-06)
|
|
181
148
|
|
|
182
|
-
|
|
183
149
|
### Bug Fixes
|
|
184
150
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
151
|
+
- fix node plugin fs augments when outside next child compiler ([#284](https://github.com/module-federation/nextjs-mf/issues/284)) ([dfa99c8](https://github.com/module-federation/nextjs-mf/commit/dfa99c86fdd8d73091764532d52be5f81b89a508))
|
|
152
|
+
- **package.json:** fix package export fields for utils ([#285](https://github.com/module-federation/nextjs-mf/issues/285)) ([99d6b77](https://github.com/module-federation/nextjs-mf/commit/99d6b779696b5dbebea9cf3c870a5caa5d9d7c6f))
|
|
189
153
|
|
|
190
154
|
## [0.2.1](https://github.com/module-federation/nextjs-mf/compare/utils-0.2.0...utils-0.2.1) (2022-10-06)
|
|
191
155
|
|
|
192
|
-
|
|
193
156
|
### Bug Fixes
|
|
194
157
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
158
|
+
- fix node plugin fs augments when outside next child compiler ([#284](https://github.com/module-federation/nextjs-mf/issues/284)) ([dfa99c8](https://github.com/module-federation/nextjs-mf/commit/dfa99c86fdd8d73091764532d52be5f81b89a508))
|
|
198
159
|
|
|
199
160
|
# [0.2.0](https://github.com/module-federation/nextjs-mf/compare/utils-0.1.0...utils-0.2.0) (2022-10-06)
|
|
200
161
|
|
|
201
|
-
|
|
202
|
-
|
|
203
162
|
## [0.1.1](https://github.com/module-federation/nextjs-mf/compare/utils-0.1.0...utils-0.1.1) (2022-10-06)
|
|
204
163
|
|
|
205
|
-
|
|
206
|
-
|
|
207
164
|
## [0.1.1](https://github.com/module-federation/nextjs-mf/compare/utils-0.1.0...utils-0.1.1) (2022-10-06)
|
|
208
165
|
|
|
209
|
-
|
|
210
|
-
|
|
211
166
|
## [0.1.1](https://github.com/module-federation/nextjs-mf/compare/utils-0.1.0...utils-0.1.1) (2022-10-06)
|
|
212
167
|
|
|
213
|
-
|
|
214
|
-
|
|
215
168
|
## [0.1.1](https://github.com/module-federation/nextjs-mf/compare/utils-0.1.0...utils-0.1.1) (2022-10-06)
|
|
216
169
|
|
|
217
170
|
# [0.2.0](https://github.com/module-federation/nextjs-mf/compare/utils-0.1.0...utils-0.2.0) (2022-10-05)
|
package/README.md
CHANGED
|
@@ -25,15 +25,19 @@ Any extra props will be passed directly to the imported module.
|
|
|
25
25
|
Usage looks something like this:
|
|
26
26
|
|
|
27
27
|
```js
|
|
28
|
-
import { FederationBoundary } from '@module-federation/utilities/src/react';
|
|
28
|
+
import { FederationBoundary } from '@module-federation/utilities/src/utils/react';
|
|
29
|
+
|
|
30
|
+
// defining dynamicImport and fallback outside the Component to keep the component identity
|
|
31
|
+
// another alternative would be to use useMemo
|
|
32
|
+
const dynamicImport = () =>
|
|
33
|
+
import('some_remote_host_name').then((m) => m.Component);
|
|
34
|
+
const fallback = () => import('@npm/backup').then((m) => m.Component);
|
|
29
35
|
|
|
30
36
|
const MyPage = () => {
|
|
31
37
|
return (
|
|
32
38
|
<FederationBoundary
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
fallback={() => import('@npm/backup').then((m) => m.Component)}
|
|
39
|
+
dynamicImporter={dynamicImport}
|
|
40
|
+
fallback={fallback}
|
|
37
41
|
customBoundary={CustomErrorBoundary}
|
|
38
42
|
/>
|
|
39
43
|
);
|
|
@@ -114,6 +118,24 @@ return (
|
|
|
114
118
|
);
|
|
115
119
|
```
|
|
116
120
|
|
|
121
|
+
```js
|
|
122
|
+
// You can also combine importRemote and FederationBoundary to have a dynamic remote URL and a fallback when there is an error on the remote
|
|
123
|
+
|
|
124
|
+
const dynamicImporter = () =>
|
|
125
|
+
importRemote({
|
|
126
|
+
url: 'http://localhost:3001',
|
|
127
|
+
scope: 'Foo',
|
|
128
|
+
module: 'Bar',
|
|
129
|
+
});
|
|
130
|
+
const fallback = () => import('@npm/backup').then((m) => m.Component);
|
|
131
|
+
|
|
132
|
+
const Bar = () => {
|
|
133
|
+
return (
|
|
134
|
+
<FederationBoundary dynamicImporter={dynamicImporter} fallback={fallback} />
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
```
|
|
138
|
+
|
|
117
139
|
Apart from **url**, **scope** and **module** you can also pass additional options to the **importRemote()** function:
|
|
118
140
|
|
|
119
141
|
- **remoteEntryFileName**: The name of the remote entry file. Defaults to "remoteEntry.js".
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/utilities",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -14,13 +14,15 @@
|
|
|
14
14
|
"next": "^12 || ^13"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
17
|
+
"next": "13.1.6",
|
|
18
|
+
"react": "18.2.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
+
"next": "13.1.6",
|
|
21
22
|
"webpack": "^5.40.0"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"
|
|
25
|
+
"react": "18.2.0",
|
|
26
|
+
"react-dom": "18.2.0"
|
|
25
27
|
}
|
|
26
28
|
}
|
package/src/Logger.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Compilation } from 'webpack';
|
|
2
|
-
export
|
|
2
|
+
export type LoggerInstance = Compilation['logger'] | Console;
|
|
3
3
|
export declare class Logger {
|
|
4
4
|
private static loggerInstance;
|
|
5
5
|
static getLogger(): LoggerInstance;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { type ErrorInfo } from 'react';
|
|
2
|
+
export interface ErrorBoundaryProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export interface ErrorBoundaryState {
|
|
6
|
+
hasError: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Generic error boundary component.
|
|
10
|
+
*/
|
|
11
|
+
declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
12
|
+
constructor(props: ErrorBoundaryProps);
|
|
13
|
+
static getDerivedStateFromError(): {
|
|
14
|
+
hasError: boolean;
|
|
15
|
+
};
|
|
16
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
17
|
+
render(): React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export default ErrorBoundary;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
/**
|
|
6
|
+
* Generic error boundary component.
|
|
7
|
+
*/
|
|
8
|
+
var ErrorBoundary = /** @class */ (function (_super) {
|
|
9
|
+
tslib_1.__extends(ErrorBoundary, _super);
|
|
10
|
+
function ErrorBoundary(props) {
|
|
11
|
+
var _this = _super.call(this, props) || this;
|
|
12
|
+
_this.state = {
|
|
13
|
+
hasError: false,
|
|
14
|
+
};
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
ErrorBoundary.getDerivedStateFromError = function ( /*error: Error*/) {
|
|
18
|
+
return {
|
|
19
|
+
hasError: true,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
ErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
|
|
23
|
+
console.error(error, errorInfo);
|
|
24
|
+
};
|
|
25
|
+
ErrorBoundary.prototype.render = function () {
|
|
26
|
+
if (this.state.hasError) {
|
|
27
|
+
return 'An error has occurred.';
|
|
28
|
+
}
|
|
29
|
+
return this.props.children;
|
|
30
|
+
};
|
|
31
|
+
return ErrorBoundary;
|
|
32
|
+
}(react_1.default.Component));
|
|
33
|
+
exports.default = ErrorBoundary;
|
|
34
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/components/ErrorBoundary.tsx"],"names":[],"mappings":";;;AAAA,wDAA8C;AAU9C;;GAEG;AACH;IAA4B,yCAG3B;IACC,uBAAY,KAAyB;QAArC,YACE,kBAAM,KAAK,CAAC,SAIb;QAHC,KAAI,CAAC,KAAK,GAAG;YACX,QAAQ,EAAE,KAAK;SAChB,CAAC;;IACJ,CAAC;IAEM,sCAAwB,GAA/B,WAAgC,gBAAgB;QAC9C,OAAO;YACL,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;IAEQ,yCAAiB,GAA1B,UAA2B,KAAY,EAAE,SAAoB;QAC3D,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;IAEQ,8BAAM,GAAf;QACE,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,OAAO,wBAAwB,CAAC;SACjC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;IACH,oBAAC;AAAD,CAAC,AA5BD,CAA4B,eAAK,CAAC,SAAS,GA4B1C;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ComponentClass, ComponentType, PropsWithChildren } from 'react';
|
|
3
|
+
export interface FederationBoundaryProps {
|
|
4
|
+
dynamicImporter: () => Promise<ComponentType<any>>;
|
|
5
|
+
fallback?: () => Promise<ComponentType<any>>;
|
|
6
|
+
customBoundary?: ComponentClass<PropsWithChildren<any>>;
|
|
7
|
+
[props: string]: any;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Wrapper around dynamic import.
|
|
11
|
+
* Adds error boundaries and fallback options.
|
|
12
|
+
*/
|
|
13
|
+
declare const FederationBoundary: React.FC<FederationBoundaryProps>;
|
|
14
|
+
export default FederationBoundary;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
var dynamic_1 = tslib_1.__importDefault(require("next/dynamic"));
|
|
6
|
+
var ErrorBoundary_1 = tslib_1.__importDefault(require("./ErrorBoundary"));
|
|
7
|
+
/**
|
|
8
|
+
* A fallback component that renders nothing.
|
|
9
|
+
*/
|
|
10
|
+
var FallbackComponent = function () {
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Wrapper around dynamic import.
|
|
15
|
+
* Adds error boundaries and fallback options.
|
|
16
|
+
*/
|
|
17
|
+
var FederationBoundary = function (_a) {
|
|
18
|
+
var dynamicImporter = _a.dynamicImporter, _b = _a.fallback, fallback = _b === void 0 ? function () { return Promise.resolve(FallbackComponent); } : _b, _c = _a.customBoundary, CustomBoundary = _c === void 0 ? ErrorBoundary_1.default : _c, rest = tslib_1.__rest(_a, ["dynamicImporter", "fallback", "customBoundary"]);
|
|
19
|
+
var ImportResult = (0, react_1.useMemo)(function () {
|
|
20
|
+
return (0, dynamic_1.default)(function () {
|
|
21
|
+
return dynamicImporter().catch(function (e) {
|
|
22
|
+
console.error(e);
|
|
23
|
+
return fallback();
|
|
24
|
+
});
|
|
25
|
+
}, {
|
|
26
|
+
ssr: false,
|
|
27
|
+
});
|
|
28
|
+
}, [dynamicImporter, fallback]);
|
|
29
|
+
return (react_1.default.createElement(CustomBoundary, null,
|
|
30
|
+
react_1.default.createElement(ImportResult, tslib_1.__assign({}, rest))));
|
|
31
|
+
};
|
|
32
|
+
exports.default = FederationBoundary;
|
|
33
|
+
//# sourceMappingURL=FederationBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FederationBoundary.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/components/FederationBoundary.tsx"],"names":[],"mappings":";;;AAAA,qDAAuC;AAEvC,iEAAmC;AACnC,0EAA4C;AAE5C;;GAEG;AACH,IAAM,iBAAiB,GAAa;IAClC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAaF;;;GAGG;AACH,IAAM,kBAAkB,GAAsC,UAAC,EAK9D;IAJC,IAAA,eAAe,qBAAA,EACf,gBAAmD,EAAnD,QAAQ,mBAAG,cAAM,OAAA,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAlC,CAAkC,KAAA,EACnD,sBAA8C,EAA9B,cAAc,mBAAG,uBAAa,KAAA,EAC3C,IAAI,sBAJsD,iDAK9D,CADQ;IAEP,IAAM,YAAY,GAAG,IAAA,eAAO,EAAC;QAC3B,OAAO,IAAA,iBAAO,EACZ;YACE,OAAA,eAAe,EAAE,CAAC,KAAK,CAAC,UAAC,CAAQ;gBAC/B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACjB,OAAO,QAAQ,EAAE,CAAC;YACpB,CAAC,CAAC;QAHF,CAGE,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,uBAAK,IAAI,EAAI,CACX,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
|
package/src/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="webpack/module" />
|
|
2
2
|
import type { container, WebpackOptionsNormalized } from 'webpack';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type ModuleFederationPluginOptions = ConstructorParameters<typeof container.ModuleFederationPlugin>['0'];
|
|
4
|
+
export type WebpackRequire = {
|
|
5
5
|
l: (url: string, cb: (event: any) => void, id: string) => Record<string, unknown>;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type WebpackShareScopes = Record<string, Record<string, {
|
|
8
8
|
loaded?: 1;
|
|
9
9
|
get: () => Promise<unknown>;
|
|
10
10
|
from: string;
|
|
@@ -24,38 +24,43 @@ export interface NextFederationPluginExtraOptions {
|
|
|
24
24
|
export interface NextFederationPluginOptions extends ModuleFederationPluginOptions {
|
|
25
25
|
extraOptions: NextFederationPluginExtraOptions;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
27
|
+
export type Shared = ModuleFederationPluginOptions['shared'];
|
|
28
|
+
export type Remotes = ModuleFederationPluginOptions['remotes'];
|
|
29
|
+
export type SharedObject = Extract<Shared, ModuleFederationPluginOptions>;
|
|
30
|
+
export type SharedConfig = Extract<SharedObject[keyof SharedObject], {
|
|
31
31
|
eager?: boolean;
|
|
32
32
|
}>;
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
export
|
|
33
|
+
export type ExternalsType = Required<ModuleFederationPluginOptions['remoteType']>;
|
|
34
|
+
type ModulePath = string;
|
|
35
|
+
export type WebpackRemoteContainer = {
|
|
36
36
|
get(modulePath: ModulePath): () => any;
|
|
37
37
|
init: (obj?: typeof __webpack_share_scopes__) => void;
|
|
38
38
|
};
|
|
39
|
-
export
|
|
40
|
-
export
|
|
39
|
+
export type AsyncContainer = Promise<WebpackRemoteContainer>;
|
|
40
|
+
export type RemoteData = {
|
|
41
41
|
global: string;
|
|
42
42
|
url: string;
|
|
43
43
|
uniqueKey?: string;
|
|
44
44
|
};
|
|
45
|
-
export
|
|
45
|
+
export type RuntimeRemote = Partial<RemoteData> & {
|
|
46
46
|
asyncContainer?: AsyncContainer;
|
|
47
47
|
};
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export
|
|
52
|
-
|
|
48
|
+
export type RuntimeRemotesMap = Record<string, RuntimeRemote>;
|
|
49
|
+
type Module = WebpackOptionsNormalized['module'];
|
|
50
|
+
type Rules = Module['rules'];
|
|
51
|
+
export type RuleSetRuleUnion = Rules[0];
|
|
52
|
+
type RuleSetRule = Extract<RuleSetRuleUnion, {
|
|
53
53
|
loader?: string;
|
|
54
54
|
}>;
|
|
55
|
-
export
|
|
55
|
+
export type Loader = Extract<RuleSetRule['use'], {
|
|
56
56
|
loader?: string;
|
|
57
57
|
}>;
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
export
|
|
58
|
+
export type EventTypes = 'loadStart' | 'loadComplete' | 'loadError';
|
|
59
|
+
type NextRoute = string;
|
|
60
|
+
export type PageMap = Record<NextRoute, ModulePath>;
|
|
61
|
+
export type GetModuleOptions = {
|
|
62
|
+
modulePath: string;
|
|
63
|
+
exportName?: string;
|
|
64
|
+
remoteContainer: string | RemoteData;
|
|
65
|
+
};
|
|
61
66
|
export {};
|
package/src/utils/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Remotes, RuntimeRemote, WebpackRemoteContainer } from '../types';
|
|
1
|
+
import type { Remotes, RuntimeRemote, WebpackRemoteContainer, RemoteData, GetModuleOptions } from '../types';
|
|
2
2
|
export declare const extractUrlAndGlobal: (urlAndGlobal: string) => [string, string];
|
|
3
3
|
/**
|
|
4
4
|
* Return initialized remote container by remote's key or its runtime remote item data.
|
|
@@ -10,3 +10,16 @@ export declare const extractUrlAndGlobal: (urlAndGlobal: string) => [string, str
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const injectScript: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => Promise<WebpackRemoteContainer>;
|
|
12
12
|
export declare const createRuntimeVariables: (remotes: Remotes) => Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Returns initialized webpack RemoteContainer.
|
|
15
|
+
* If its' script does not loaded - then load & init it firstly.
|
|
16
|
+
*/
|
|
17
|
+
export declare const getContainer: (remoteContainer: string | RemoteData) => Promise<WebpackRemoteContainer | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Return remote module from container.
|
|
20
|
+
* If you provide `exportName` it automatically return exact property value from module.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* remote.getModule('./pages/index', 'default')
|
|
24
|
+
*/
|
|
25
|
+
export declare const getModule: ({ remoteContainer, modulePath, exportName, }: GetModuleOptions) => Promise<any>;
|
package/src/utils/common.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createRuntimeVariables = exports.injectScript = exports.extractUrlAndGlobal = void 0;
|
|
4
|
+
exports.getModule = exports.getContainer = exports.createRuntimeVariables = exports.injectScript = exports.extractUrlAndGlobal = void 0;
|
|
5
|
+
var tslib_1 = require("tslib");
|
|
5
6
|
// split the @ syntax into url and global
|
|
6
7
|
var extractUrlAndGlobal = function (urlAndGlobal) {
|
|
7
8
|
var index = urlAndGlobal.indexOf('@');
|
|
@@ -154,4 +155,81 @@ var createRuntimeVariables = function (remotes) {
|
|
|
154
155
|
}, {});
|
|
155
156
|
};
|
|
156
157
|
exports.createRuntimeVariables = createRuntimeVariables;
|
|
158
|
+
/**
|
|
159
|
+
* Returns initialized webpack RemoteContainer.
|
|
160
|
+
* If its' script does not loaded - then load & init it firstly.
|
|
161
|
+
*/
|
|
162
|
+
var getContainer = function (remoteContainer) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
163
|
+
var container;
|
|
164
|
+
return tslib_1.__generator(this, function (_a) {
|
|
165
|
+
switch (_a.label) {
|
|
166
|
+
case 0:
|
|
167
|
+
if (!remoteContainer) {
|
|
168
|
+
throw Error("Remote container options is empty");
|
|
169
|
+
}
|
|
170
|
+
if (!(typeof remoteContainer === 'string')) return [3 /*break*/, 1];
|
|
171
|
+
if (window[remoteContainer]) {
|
|
172
|
+
return [2 /*return*/, window[remoteContainer]];
|
|
173
|
+
}
|
|
174
|
+
return [2 /*return*/];
|
|
175
|
+
case 1:
|
|
176
|
+
if (window['uniqueKey']) {
|
|
177
|
+
return [2 /*return*/, window['uniqueKey']];
|
|
178
|
+
}
|
|
179
|
+
return [4 /*yield*/, (0, exports.injectScript)({
|
|
180
|
+
global: remoteContainer.global,
|
|
181
|
+
url: remoteContainer.url,
|
|
182
|
+
})];
|
|
183
|
+
case 2:
|
|
184
|
+
container = _a.sent();
|
|
185
|
+
if (container) {
|
|
186
|
+
return [2 /*return*/, container];
|
|
187
|
+
}
|
|
188
|
+
throw Error("Remote container ".concat(remoteContainer.url, " is empty"));
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}); };
|
|
192
|
+
exports.getContainer = getContainer;
|
|
193
|
+
/**
|
|
194
|
+
* Return remote module from container.
|
|
195
|
+
* If you provide `exportName` it automatically return exact property value from module.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* remote.getModule('./pages/index', 'default')
|
|
199
|
+
*/
|
|
200
|
+
var getModule = function (_a) {
|
|
201
|
+
var remoteContainer = _a.remoteContainer, modulePath = _a.modulePath, exportName = _a.exportName;
|
|
202
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
203
|
+
var container, modFactory, mod, error_1;
|
|
204
|
+
return tslib_1.__generator(this, function (_b) {
|
|
205
|
+
switch (_b.label) {
|
|
206
|
+
case 0: return [4 /*yield*/, (0, exports.getContainer)(remoteContainer)];
|
|
207
|
+
case 1:
|
|
208
|
+
container = _b.sent();
|
|
209
|
+
_b.label = 2;
|
|
210
|
+
case 2:
|
|
211
|
+
_b.trys.push([2, 4, , 5]);
|
|
212
|
+
return [4 /*yield*/, (container === null || container === void 0 ? void 0 : container.get(modulePath))];
|
|
213
|
+
case 3:
|
|
214
|
+
modFactory = _b.sent();
|
|
215
|
+
if (!modFactory)
|
|
216
|
+
return [2 /*return*/, undefined];
|
|
217
|
+
mod = modFactory();
|
|
218
|
+
if (exportName) {
|
|
219
|
+
return [2 /*return*/, mod && typeof mod === 'object' ? mod[exportName] : undefined];
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
return [2 /*return*/, mod];
|
|
223
|
+
}
|
|
224
|
+
return [3 /*break*/, 5];
|
|
225
|
+
case 4:
|
|
226
|
+
error_1 = _b.sent();
|
|
227
|
+
console.log(error_1);
|
|
228
|
+
return [2 /*return*/, undefined];
|
|
229
|
+
case 5: return [2 /*return*/];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
exports.getModule = getModule;
|
|
157
235
|
//# sourceMappingURL=common.js.map
|
package/src/utils/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/common.ts"],"names":[],"mappings":";AAAA,sDAAsD
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/common.ts"],"names":[],"mappings":";AAAA,sDAAsD;;;;AAmBtD,yCAAyC;AAClC,IAAM,mBAAmB,GAAG,UAAC,YAAoB;IACtD,IAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,KAAK,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QACnD,MAAM,IAAI,KAAK,CAAC,4BAAoB,YAAY,OAAG,CAAC,CAAC;KACtD;IACD,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEF,IAAM,iBAAiB,GAAG;IACxB,YAAY;IACZ,IAAM,UAAU,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAe,CAAC;IAE7D,IAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,UACvD,GAAG,EACH,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AAC,GAAG;qBACzB,CAAC,EAAA;;gBAHI,SAAS,GAAG,SAGhB;gBAEF,IAAI,SAAS,EAAE;oBACb,sBAAO,SAAS,EAAC;iBAClB;gBAED,MAAM,KAAK,CAAC,2BAAoB,eAAe,CAAC,GAAG,cAAW,CAAC,CAAC;;;KAEnE,CAAC;AA7BW,QAAA,YAAY,gBA6BvB;AAEF;;;;;;GAMG;AACI,IAAM,SAAS,GAAG,UAAO,EAIb;QAHjB,eAAe,qBAAA,EACf,UAAU,gBAAA,EACV,UAAU,gBAAA;;;;;wBAEQ,qBAAM,IAAA,oBAAY,EAAC,eAAe,CAAC,EAAA;;oBAA/C,SAAS,GAAG,SAAmC;;;;oBAEhC,qBAAM,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAC,UAAU,CAAC,CAAA,EAAA;;oBAA7C,UAAU,GAAG,SAAgC;oBACnD,IAAI,CAAC,UAAU;wBAAE,sBAAO,SAAS,EAAC;oBAC5B,GAAG,GAAG,UAAU,EAAE,CAAC;oBACzB,IAAI,UAAU,EAAE;wBACd,sBAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,EAAC;qBACrE;yBAAM;wBACL,sBAAO,GAAG,EAAC;qBACZ;;;;oBAED,OAAO,CAAC,GAAG,CAAC,OAAK,CAAC,CAAC;oBACnB,sBAAO,SAAS,EAAC;;;;;CAEpB,CAAC;AAnBW,QAAA,SAAS,aAmBpB"}
|
|
@@ -68,11 +68,12 @@ var initContainer = function (containerScope) { return tslib_1.__awaiter(void 0,
|
|
|
68
68
|
var importRemote = function (_a) {
|
|
69
69
|
var url = _a.url, scope = _a.scope, module = _a.module, _b = _a.remoteEntryFileName, remoteEntryFileName = _b === void 0 ? REMOTE_ENTRY_FILE : _b, _c = _a.bustRemoteEntryCache, bustRemoteEntryCache = _c === void 0 ? true : _c;
|
|
70
70
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
71
|
-
var remoteUrl, _d, moduleFactory, moduleFactory;
|
|
71
|
+
var remoteScope, remoteUrl, _d, moduleFactory, moduleFactory;
|
|
72
72
|
return tslib_1.__generator(this, function (_e) {
|
|
73
73
|
switch (_e.label) {
|
|
74
74
|
case 0:
|
|
75
|
-
|
|
75
|
+
remoteScope = scope;
|
|
76
|
+
if (!!window[remoteScope]) return [3 /*break*/, 6];
|
|
76
77
|
remoteUrl = '';
|
|
77
78
|
if (!(typeof url === 'string')) return [3 /*break*/, 1];
|
|
78
79
|
remoteUrl = url;
|
|
@@ -90,17 +91,17 @@ var importRemote = function (_a) {
|
|
|
90
91
|
case 4:
|
|
91
92
|
// Load the remote and initialize the share scope if it's empty
|
|
92
93
|
_e.sent();
|
|
93
|
-
if (!window[
|
|
94
|
+
if (!window[remoteScope]) {
|
|
94
95
|
throw new Error("Remote loaded successfully but ".concat(scope, " could not be found! Verify that the name is correct in the Webpack configuration!"));
|
|
95
96
|
}
|
|
96
97
|
return [4 /*yield*/, Promise.all([
|
|
97
|
-
initContainer(window[
|
|
98
|
-
window[
|
|
98
|
+
initContainer(window[remoteScope]),
|
|
99
|
+
window[remoteScope].get(module.startsWith('./') ? module : "./".concat(module)),
|
|
99
100
|
])];
|
|
100
101
|
case 5:
|
|
101
102
|
_d = _e.sent(), moduleFactory = _d[1];
|
|
102
103
|
return [2 /*return*/, moduleFactory()];
|
|
103
|
-
case 6: return [4 /*yield*/, window[
|
|
104
|
+
case 6: return [4 /*yield*/, window[remoteScope].get(module.startsWith('./') ? module : "./".concat(module))];
|
|
104
105
|
case 7:
|
|
105
106
|
moduleFactory = _e.sent();
|
|
106
107
|
return [2 /*return*/, moduleFactory()];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importRemote.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/importRemote.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"importRemote.js","sour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b,yCAAkC,KAAK,uFAAoF,CAC5H,CAAC;qBACH;oBAEyB,qBAAM,OAAO,CAAC,GAAG,CAAC;4BAC1C,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;4BACjC,MAAM,CAAC,WAAW,CAAuC,CAAC,GAAG,CAC5D,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAK,MAAM,CAAE,CACjD;yBACF,CAAC,EAAA;;oBALI,KAAoB,SAKxB,EALO,aAAa,QAAA;oBAMtB,sBAAO,aAAa,EAAE,EAAC;wBAED,qBACpB,MAAM,CAAC,WAAW,CACnB,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAK,MAAM,CAAE,CAAC,EAAA;;oBAFjD,aAAa,GAAG,SAEiC;oBACvD,sBAAO,aAAa,EAAE,EAAC;;;;CAE1B,CAAC;AA7CW,QAAA,YAAY,gBA6CvB"}
|
package/src/utils/react.d.ts
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Wrapper around dynamic import.
|
|
4
|
-
* Adds error boundaries and fallback options
|
|
5
|
-
*/
|
|
6
|
-
export declare const FederationBoundary: ({ dynamicImporter, fallback, customBoundary: CustomBoundary, ...rest }: {
|
|
7
|
-
dynamicImporter: () => Promise<any>;
|
|
8
|
-
fallback: () => Promise<any> | null;
|
|
9
|
-
customBoundary: ComponentType;
|
|
10
|
-
}) => JSX.Element;
|
|
1
|
+
export { default as FederationBoundary } from '../components/FederationBoundary';
|
package/src/utils/react.js
CHANGED
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.FederationBoundary = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
var dynamic_1 = tslib_1.__importDefault(require("next/dynamic"));
|
|
7
|
-
var ErrorBoundary = /** @class */ (function (_super) {
|
|
8
|
-
tslib_1.__extends(ErrorBoundary, _super);
|
|
9
|
-
function ErrorBoundary(props) {
|
|
10
|
-
return _super.call(this, props) || this;
|
|
11
|
-
}
|
|
12
|
-
ErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
|
|
13
|
-
// You can also log the error to an error reporting service
|
|
14
|
-
console.error(error, errorInfo);
|
|
15
|
-
};
|
|
16
|
-
ErrorBoundary.prototype.render = function () {
|
|
17
|
-
return this.props['children'];
|
|
18
|
-
};
|
|
19
|
-
return ErrorBoundary;
|
|
20
|
-
}(react_1.default.Component));
|
|
21
|
-
/**
|
|
22
|
-
* Wrapper around dynamic import.
|
|
23
|
-
* Adds error boundaries and fallback options
|
|
24
|
-
*/
|
|
25
|
-
var FederationBoundary = function (_a) {
|
|
26
|
-
var dynamicImporter = _a.dynamicImporter, _b = _a.fallback, fallback = _b === void 0 ? function () { return null; } : _b, CustomBoundary = _a.customBoundary, rest = tslib_1.__rest(_a, ["dynamicImporter", "fallback", "customBoundary"]);
|
|
27
|
-
return (0, react_1.useMemo)(function () {
|
|
28
|
-
var ImportResult = (0, dynamic_1.default)(function () {
|
|
29
|
-
return dynamicImporter().catch(function (e) {
|
|
30
|
-
console.error(e);
|
|
31
|
-
return fallback();
|
|
32
|
-
});
|
|
33
|
-
}, {
|
|
34
|
-
ssr: false,
|
|
35
|
-
});
|
|
36
|
-
var Boundary = CustomBoundary !== undefined ? CustomBoundary : ErrorBoundary;
|
|
37
|
-
return (react_1.default.createElement(Boundary, null,
|
|
38
|
-
react_1.default.createElement(ImportResult, tslib_1.__assign({}, rest))));
|
|
39
|
-
}, [dynamicImporter, fallback]);
|
|
40
|
-
};
|
|
41
|
-
exports.FederationBoundary = FederationBoundary;
|
|
7
|
+
var FederationBoundary_1 = require("../components/FederationBoundary");
|
|
8
|
+
Object.defineProperty(exports, "FederationBoundary", { enumerable: true, get: function () { return __importDefault(FederationBoundary_1).default; } });
|
|
42
9
|
//# sourceMappingURL=react.js.map
|
package/src/utils/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/react.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/react.tsx"],"names":[],"mappings":";;;;;;AAAA,uEAAiF;AAAxE,yIAAA,OAAO,OAAsB"}
|