@module-federation/nextjs-mf 5.12.8 → 5.12.10
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 +18 -0
- package/README.md +5 -3
- package/package.json +1 -1
- package/src/loaders/fixImageLoader.js +10 -2
- package/src/loaders/fixImageLoader.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [5.12.10](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-5.12.9...nextjs-mf-5.12.10) (2022-11-23)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* next images when debugging locally ([#395](https://github.com/module-federation/nextjs-mf/issues/395)) ([0379baa](https://github.com/module-federation/nextjs-mf/commit/0379baaae14960d0e7c7353e7d2b0aa1a4a02aa4))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [5.12.9](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-5.12.8...nextjs-mf-5.12.9) (2022-11-23)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* support images for storages and local debug ([#391](https://github.com/module-federation/nextjs-mf/issues/391)) ([9a72311](https://github.com/module-federation/nextjs-mf/commit/9a72311f18b5b3f1ae0badda3f25bd71cc6c8a3b))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
5
23
|
## [5.12.8](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-5.12.7...nextjs-mf-5.12.8) (2022-11-22)
|
|
6
24
|
|
|
7
25
|
### Dependency Updates
|
package/README.md
CHANGED
|
@@ -165,11 +165,12 @@ module.exports = {
|
|
|
165
165
|
|
|
166
166
|
// _app.js or some other file in as high up in the app (like next's new layouts)
|
|
167
167
|
// this ensures various parts of next.js are imported and "used" somewhere so that they wont be tree shaken out
|
|
168
|
-
|
|
168
|
+
// note: this is optional in the latest release, as it is auto-injected by NextFederationPlugin now
|
|
169
|
+
import '@module-federation/nextjs-mf/src/include-defaults';
|
|
169
170
|
```
|
|
170
171
|
|
|
171
172
|
2. For the consuming application, we'll call it "next1", add an instance of the ModuleFederationPlugin to your webpack config, and ensure you have a [custom Next.js App](https://nextjs.org/docs/advanced-features/custom-app) `pages/_app.js` (or `.tsx`):
|
|
172
|
-
Inside that \_app.js or layout.js file, ensure you import `include-defaults` file
|
|
173
|
+
Inside that \_app.js or layout.js file, ensure you import `include-defaults` file (this is now optional as include-defaults is auto injected into _app)
|
|
173
174
|
|
|
174
175
|
```js
|
|
175
176
|
// next.config.js
|
|
@@ -194,7 +195,8 @@ module.exports = {
|
|
|
194
195
|
|
|
195
196
|
// _app.js or some other file in as high up in the app (like next's new layouts)
|
|
196
197
|
// this ensures various parts of next.js are imported and "used" somewhere so that they wont be tree shaken out
|
|
197
|
-
|
|
198
|
+
// note: this is optional in the latest release, as it is auto-injected by NextFederationPlugin now
|
|
199
|
+
import '@module-federation/nextjs-mf/src/include-defaults';
|
|
198
200
|
```
|
|
199
201
|
|
|
200
202
|
4. Use next/dynamic or low level api to import remotes.
|
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@ const path_1 = tslib_1.__importDefault(require("path"));
|
|
|
25
25
|
async function fixImageLoader(remaining) {
|
|
26
26
|
this.cacheable(true);
|
|
27
27
|
const isServer = this._compiler?.options.name !== 'client';
|
|
28
|
+
const publicPath = this._compiler?.webpack.RuntimeGlobals.publicPath;
|
|
28
29
|
const result = await this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!${remaining}`);
|
|
29
30
|
const content = (result.default || result);
|
|
30
31
|
const computedAssetPrefix = isServer
|
|
@@ -34,8 +35,13 @@ async function fixImageLoader(remaining) {
|
|
|
34
35
|
'try {',
|
|
35
36
|
webpack_1.Template.indent([
|
|
36
37
|
'const remoteEntry = global.__remote_scope__ && global.remoteEntryName && global.__remote_scope__._config[global.remoteEntryName];',
|
|
37
|
-
`
|
|
38
|
-
|
|
38
|
+
`if (remoteEntry) {`,
|
|
39
|
+
webpack_1.Template.indent([
|
|
40
|
+
`const splitted = remoteEntry.split('/_next')`,
|
|
41
|
+
`return splitted.length === 2 ? splitted[0] : '';`,
|
|
42
|
+
]),
|
|
43
|
+
`}`,
|
|
44
|
+
`return '';`,
|
|
39
45
|
]),
|
|
40
46
|
'} catch (e) {',
|
|
41
47
|
webpack_1.Template.indent([
|
|
@@ -51,6 +57,8 @@ async function fixImageLoader(remaining) {
|
|
|
51
57
|
webpack_1.Template.indent([
|
|
52
58
|
'try {',
|
|
53
59
|
webpack_1.Template.indent([
|
|
60
|
+
`if(typeof document === 'undefined')`,
|
|
61
|
+
webpack_1.Template.indent(`return ${publicPath} && ${publicPath}.indexOf('://') > 0 ? new URL(${publicPath}).origin : ''`),
|
|
54
62
|
`const path = document.currentScript && document.currentScript.src;`,
|
|
55
63
|
`const splitted = path.split('/_next')`,
|
|
56
64
|
`return splitted.length === 2 ? splitted[0] : '';`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixImageLoader.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/loaders/fixImageLoader.ts"],"names":[],"mappings":";;;;AAEA,qCAAmC;AACnC,wDAAwB;AAExB;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,cAAc,CAElC,SAAiB;IAEjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"fixImageLoader.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/loaders/fixImageLoader.ts"],"names":[],"mappings":";;;;AAEA,qCAAmC;AACnC,wDAAwB;AAExB;;;;;;;;;;;;;;;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