@module-federation/nextjs-mf 5.12.6 → 5.12.8
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
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [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
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `node` updated to version `0.9.6`
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* normalize options private variable on plugin constructors ([#390](https://github.com/module-federation/nextjs-mf/issues/390)) ([5654acd](https://github.com/module-federation/nextjs-mf/commit/5654acdf8e79f0b10f34bb58c6eb09c1b83675cb))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [5.12.7](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-5.12.6...nextjs-mf-5.12.7) (2022-11-22)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* improve syntax of loaders ([#389](https://github.com/module-federation/nextjs-mf/issues/389)) ([d7b7910](https://github.com/module-federation/nextjs-mf/commit/d7b79109343e4e39fc1f97cef999cb7620d80081))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
5
26
|
## [5.12.6](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-5.12.5...nextjs-mf-5.12.6) (2022-11-22)
|
|
6
27
|
|
|
7
28
|
### Dependency Updates
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/nextjs-mf",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"fast-glob": "^3.2.11",
|
|
20
20
|
"webpack-sources": "^3.2.3",
|
|
21
21
|
"eventemitter3": "^4.0.7",
|
|
22
|
-
"@module-federation/node": "0.9.
|
|
22
|
+
"@module-federation/node": "0.9.6",
|
|
23
23
|
"@module-federation/utilities": "1.0.1",
|
|
24
24
|
"@swc/core": "^1.3.3",
|
|
25
25
|
"tslib": "^2.3.0"
|
|
@@ -4,12 +4,17 @@ import type { LoaderContext } from 'webpack';
|
|
|
4
4
|
* see https://github.com/vercel/next.js/blob/canary/packages/next/build/webpack/loaders/next-image-loader.js
|
|
5
5
|
* It takes regular string
|
|
6
6
|
* `export default {"src":"/_next/static/media/ssl.e3019f0e.svg","height":20,"width":20};`
|
|
7
|
-
* And injects
|
|
8
|
-
*
|
|
7
|
+
* And injects the following code:
|
|
8
|
+
* for ssr:
|
|
9
|
+
* remote scope of specific remote url
|
|
10
|
+
* for csr:
|
|
11
|
+
* document.currentScript.src
|
|
12
|
+
* after that, it will choose the full uri before _next
|
|
9
13
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
14
|
+
* for example:
|
|
15
|
+
* http://localhost:1234/test/test2/_next/static/media/ssl.e3019f0e.svg
|
|
16
|
+
* will become
|
|
17
|
+
* http://localhost:1234/test/test2
|
|
13
18
|
*
|
|
14
19
|
*/
|
|
15
20
|
export declare function fixImageLoader(this: LoaderContext<Record<string, unknown>>, remaining: string): Promise<string>;
|
|
@@ -9,23 +9,61 @@ const path_1 = tslib_1.__importDefault(require("path"));
|
|
|
9
9
|
* see https://github.com/vercel/next.js/blob/canary/packages/next/build/webpack/loaders/next-image-loader.js
|
|
10
10
|
* It takes regular string
|
|
11
11
|
* `export default {"src":"/_next/static/media/ssl.e3019f0e.svg","height":20,"width":20};`
|
|
12
|
-
* And injects
|
|
13
|
-
*
|
|
12
|
+
* And injects the following code:
|
|
13
|
+
* for ssr:
|
|
14
|
+
* remote scope of specific remote url
|
|
15
|
+
* for csr:
|
|
16
|
+
* document.currentScript.src
|
|
17
|
+
* after that, it will choose the full uri before _next
|
|
14
18
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
19
|
+
* for example:
|
|
20
|
+
* http://localhost:1234/test/test2/_next/static/media/ssl.e3019f0e.svg
|
|
21
|
+
* will become
|
|
22
|
+
* http://localhost:1234/test/test2
|
|
18
23
|
*
|
|
19
24
|
*/
|
|
20
25
|
async function fixImageLoader(remaining) {
|
|
21
26
|
this.cacheable(true);
|
|
22
|
-
const publicPath = this._compiler?.webpack.RuntimeGlobals.publicPath;
|
|
23
27
|
const isServer = this._compiler?.options.name !== 'client';
|
|
24
28
|
const result = await this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!${remaining}`);
|
|
25
29
|
const content = (result.default || result);
|
|
26
30
|
const computedAssetPrefix = isServer
|
|
27
|
-
?
|
|
28
|
-
|
|
31
|
+
? `${webpack_1.Template.asString([
|
|
32
|
+
'function getSSRImagePath(){',
|
|
33
|
+
webpack_1.Template.asString([
|
|
34
|
+
'try {',
|
|
35
|
+
webpack_1.Template.indent([
|
|
36
|
+
'const remoteEntry = global.__remote_scope__ && global.remoteEntryName && global.__remote_scope__._config[global.remoteEntryName];',
|
|
37
|
+
`const splitted = remoteEntry.split('/_next')`,
|
|
38
|
+
`return splitted.length === 2 ? splitted[0] : '';`,
|
|
39
|
+
]),
|
|
40
|
+
'} catch (e) {',
|
|
41
|
+
webpack_1.Template.indent([
|
|
42
|
+
`console.error('failed generating SSR image path', e);`,
|
|
43
|
+
'return "";',
|
|
44
|
+
]),
|
|
45
|
+
'}',
|
|
46
|
+
]),
|
|
47
|
+
'}()',
|
|
48
|
+
])}`
|
|
49
|
+
: `${webpack_1.Template.asString([
|
|
50
|
+
'function getCSRImagePath(){',
|
|
51
|
+
webpack_1.Template.indent([
|
|
52
|
+
'try {',
|
|
53
|
+
webpack_1.Template.indent([
|
|
54
|
+
`const path = document.currentScript && document.currentScript.src;`,
|
|
55
|
+
`const splitted = path.split('/_next')`,
|
|
56
|
+
`return splitted.length === 2 ? splitted[0] : '';`,
|
|
57
|
+
]),
|
|
58
|
+
'} catch (e) {',
|
|
59
|
+
webpack_1.Template.indent([
|
|
60
|
+
`console.error('failed generating CSR image path', e);`,
|
|
61
|
+
'return "";',
|
|
62
|
+
]),
|
|
63
|
+
'}',
|
|
64
|
+
]),
|
|
65
|
+
'}()',
|
|
66
|
+
])}`;
|
|
29
67
|
const constructedObject = Object.entries(content).reduce((acc, [key, value]) => {
|
|
30
68
|
if (key === 'src') {
|
|
31
69
|
if (value && !value.includes('://')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixImageLoader.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/loaders/fixImageLoader.ts"],"names":[],"mappings":";;;;AAEA,qCAAmC;AACnC,wDAAwB;AAExB
|
|
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;IAE3D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CACpC,GAAG,IAAI,CAAC,YAAY,+BAA+B,SAAS,EAAE,CAC/D,CAAC;IAEF,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAA2B,CAAC;IAErE,MAAM,mBAAmB,GAAG,QAAQ;QAClC,CAAC,CAAC,GAAG,kBAAQ,CAAC,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