@module-federation/nextjs-mf 5.12.7 → 5.12.9

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.9](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-5.12.8...nextjs-mf-5.12.9) (2022-11-23)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * 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))
11
+
12
+
13
+
14
+ ## [5.12.8](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-5.12.7...nextjs-mf-5.12.8) (2022-11-22)
15
+
16
+ ### Dependency Updates
17
+
18
+ * `node` updated to version `0.9.6`
19
+
20
+ ### Bug Fixes
21
+
22
+ * 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))
23
+
24
+
25
+
5
26
  ## [5.12.7](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-5.12.6...nextjs-mf-5.12.7) (2022-11-22)
6
27
 
7
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/nextjs-mf",
3
- "version": "5.12.7",
3
+ "version": "5.12.9",
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.5",
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 PUBLIC_PATH to it from webpack
8
- * `export default {"src":__webpack_require__.p+"/static/media/ssl.e3019f0e.svg","height":20,"width":20};`
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
- * __webpack_require__.p - is a global variable in webpack container which contains publicPath
12
- * For example: http://localhost:3000/_next
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,69 @@ 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 PUBLIC_PATH to it from webpack
13
- * `export default {"src":__webpack_require__.p+"/static/media/ssl.e3019f0e.svg","height":20,"width":20};`
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
- * __webpack_require__.p - is a global variable in webpack container which contains publicPath
17
- * For example: http://localhost:3000/_next
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';
28
+ const publicPath = this._compiler?.webpack.RuntimeGlobals.publicPath;
24
29
  const result = await this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!${remaining}`);
25
30
  const content = (result.default || result);
26
31
  const computedAssetPrefix = isServer
27
- ? `new URL(global.__remote_scope__._config[global.remoteEntryName]).origin`
28
- : `(${publicPath} && ${publicPath}.indexOf('://') > 0 ? new URL(${publicPath}).origin : '')`;
32
+ ? `${webpack_1.Template.asString([
33
+ 'function getSSRImagePath(){',
34
+ webpack_1.Template.asString([
35
+ 'try {',
36
+ webpack_1.Template.indent([
37
+ 'const remoteEntry = global.__remote_scope__ && global.remoteEntryName && global.__remote_scope__._config[global.remoteEntryName];',
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 '';`,
45
+ ]),
46
+ '} catch (e) {',
47
+ webpack_1.Template.indent([
48
+ `console.error('failed generating SSR image path', e);`,
49
+ 'return "";',
50
+ ]),
51
+ '}',
52
+ ]),
53
+ '}()',
54
+ ])}`
55
+ : `${webpack_1.Template.asString([
56
+ 'function getCSRImagePath(){',
57
+ webpack_1.Template.indent([
58
+ 'try {',
59
+ webpack_1.Template.indent([
60
+ `if(typeof document === 'undefined')`,
61
+ webpack_1.Template.indent(`return ${publicPath} && ${publicPath}.indexOf('://') > 0 ? new URL(${publicPath}).origin : ''`),
62
+ `const path = document.currentScript && document.currentScript.src;`,
63
+ `const splitted = path.split('/_next')`,
64
+ `return splitted.length === 2 ? splitted[0] : '';`,
65
+ ]),
66
+ '} catch (e) {',
67
+ webpack_1.Template.indent([
68
+ `console.error('failed generating CSR image path', e);`,
69
+ 'return "";',
70
+ ]),
71
+ '}',
72
+ ]),
73
+ '}()',
74
+ ])}`;
29
75
  const constructedObject = Object.entries(content).reduce((acc, [key, value]) => {
30
76
  if (key === 'src') {
31
77
  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;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,cAAc,CAElC,SAAiB;IAEjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAErB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;IACrE,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,yEAAyE;QAC3E,CAAC,CAAC,IAAI,UAAU,OAAO,UAAU,iCAAiC,UAAU,gBAAgB,CAAC;IAE/F,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CACtD,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACpB,IAAI,GAAG,KAAK,KAAK,EAAE;YACjB,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACnC,KAAK,GAAG,cAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC1B;YACD,GAAG,CAAC,IAAI,CACN,GAAG,GAAG,qCAAqC,IAAI,CAAC,SAAS,C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