@module-federation/nextjs-mf 0.0.0-perf-devtools-20260108034446 → 0.0.0-perf-website-code-usage-20260914033703

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.
Files changed (147) hide show
  1. package/dist/LICENSE +21 -0
  2. package/dist/_virtual/_rolldown/runtime.js +29 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +8 -0
  4. package/dist/client/UrlNode.d.mts +17 -0
  5. package/dist/client/UrlNode.js +89 -147
  6. package/dist/client/UrlNode.js.map +1 -1
  7. package/dist/client/UrlNode.mjs +91 -0
  8. package/dist/client/UrlNode.mjs.map +1 -0
  9. package/dist/node.d.mts +1 -0
  10. package/dist/src/federation-noop.d.mts +0 -0
  11. package/dist/src/federation-noop.js +17 -0
  12. package/dist/src/federation-noop.js.map +1 -1
  13. package/dist/src/federation-noop.mjs +23 -0
  14. package/dist/src/federation-noop.mjs.map +1 -0
  15. package/dist/src/index.d.mts +3 -0
  16. package/dist/src/index.js +13 -11
  17. package/dist/src/index.js.map +1 -1
  18. package/dist/src/index.mjs +8 -0
  19. package/dist/src/index.mjs.map +1 -0
  20. package/dist/src/internal.d.mts +50 -0
  21. package/dist/src/internal.js +140 -243
  22. package/dist/src/internal.js.map +1 -1
  23. package/dist/src/internal.mjs +152 -0
  24. package/dist/src/internal.mjs.map +1 -0
  25. package/dist/src/loaders/fixImageLoader.d.mts +22 -0
  26. package/dist/src/loaders/fixImageLoader.js +91 -103
  27. package/dist/src/loaders/fixImageLoader.js.map +1 -1
  28. package/dist/src/loaders/fixImageLoader.mjs +101 -0
  29. package/dist/src/loaders/fixImageLoader.mjs.map +1 -0
  30. package/dist/src/loaders/fixUrlLoader.d.mts +13 -0
  31. package/dist/src/loaders/fixUrlLoader.js +17 -19
  32. package/dist/src/loaders/fixUrlLoader.js.map +1 -1
  33. package/dist/src/loaders/fixUrlLoader.mjs +19 -0
  34. package/dist/src/loaders/fixUrlLoader.mjs.map +1 -0
  35. package/dist/src/loaders/helpers.d.mts +17 -0
  36. package/dist/src/loaders/helpers.js +72 -124
  37. package/dist/src/loaders/helpers.js.map +1 -1
  38. package/dist/src/loaders/helpers.mjs +79 -0
  39. package/dist/src/loaders/helpers.mjs.map +1 -0
  40. package/dist/src/loaders/nextPageMapLoader.d.mts +24 -0
  41. package/dist/src/loaders/nextPageMapLoader.js +126 -144
  42. package/dist/src/loaders/nextPageMapLoader.js.map +1 -1
  43. package/dist/src/loaders/nextPageMapLoader.mjs +143 -0
  44. package/dist/src/loaders/nextPageMapLoader.mjs.map +1 -0
  45. package/dist/src/logger.d.mts +2 -0
  46. package/dist/src/logger.js +7 -7
  47. package/dist/src/logger.js.map +1 -1
  48. package/dist/src/logger.mjs +8 -0
  49. package/dist/src/logger.mjs.map +1 -0
  50. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.mts +5 -0
  51. package/dist/src/plugins/CopyFederationPlugin.d.mts +20 -0
  52. package/dist/src/plugins/CopyFederationPlugin.js +64 -71
  53. package/dist/src/plugins/CopyFederationPlugin.js.map +1 -1
  54. package/dist/src/plugins/CopyFederationPlugin.mjs +65 -0
  55. package/dist/src/plugins/CopyFederationPlugin.mjs.map +1 -0
  56. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.mts +22 -0
  57. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.ts +22 -0
  58. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js +43 -0
  59. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js.map +1 -0
  60. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs +42 -0
  61. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs.map +1 -0
  62. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.mts +23 -0
  63. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +42 -53
  64. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
  65. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs +46 -0
  66. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs.map +1 -0
  67. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.mts +36 -0
  68. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +103 -121
  69. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
  70. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs +111 -0
  71. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs.map +1 -0
  72. package/dist/src/plugins/NextFederationPlugin/index.d.mts +27 -0
  73. package/dist/src/plugins/NextFederationPlugin/index.js +149 -181
  74. package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -1
  75. package/dist/src/plugins/NextFederationPlugin/index.mjs +151 -0
  76. package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -0
  77. package/dist/src/plugins/NextFederationPlugin/manifest-options.d.mts +4 -0
  78. package/dist/src/plugins/NextFederationPlugin/manifest-options.d.ts +4 -0
  79. package/dist/src/plugins/NextFederationPlugin/manifest-options.js +13 -0
  80. package/dist/src/plugins/NextFederationPlugin/manifest-options.js.map +1 -0
  81. package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs +12 -0
  82. package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs.map +1 -0
  83. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +20 -0
  84. package/dist/src/plugins/NextFederationPlugin/next-fragments.js +58 -93
  85. package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
  86. package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs +63 -0
  87. package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs.map +1 -0
  88. package/dist/src/plugins/NextFederationPlugin/{regex-equal.js → regex-equal.d.mts} +2 -13
  89. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.mts +8 -0
  90. package/dist/src/plugins/NextFederationPlugin/set-options.d.mts +6 -0
  91. package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +1 -11
  92. package/dist/src/plugins/NextFederationPlugin/set-options.js +17 -19
  93. package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
  94. package/dist/src/plugins/NextFederationPlugin/set-options.mjs +19 -0
  95. package/dist/src/plugins/NextFederationPlugin/set-options.mjs.map +1 -0
  96. package/dist/src/plugins/NextFederationPlugin/validate-options.d.mts +25 -0
  97. package/dist/src/plugins/NextFederationPlugin/validate-options.js +30 -38
  98. package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
  99. package/dist/src/plugins/NextFederationPlugin/validate-options.mjs +35 -0
  100. package/dist/src/plugins/NextFederationPlugin/validate-options.mjs.map +1 -0
  101. package/dist/src/plugins/container/InvertedContainerPlugin.d.mts +5 -0
  102. package/dist/src/plugins/container/InvertedContainerPlugin.js +23 -25
  103. package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
  104. package/dist/src/plugins/container/InvertedContainerPlugin.mjs +27 -0
  105. package/dist/src/plugins/container/InvertedContainerPlugin.mjs.map +1 -0
  106. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.mts +11 -0
  107. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +1 -1
  108. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +55 -67
  109. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
  110. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs +57 -0
  111. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -0
  112. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.mts +39 -0
  113. package/dist/src/plugins/container/runtimePlugin.d.mts +2 -0
  114. package/dist/src/plugins/container/runtimePlugin.d.ts +1 -1
  115. package/dist/src/plugins/container/runtimePlugin.js +170 -0
  116. package/dist/src/plugins/container/runtimePlugin.js.map +1 -1
  117. package/dist/src/plugins/container/runtimePlugin.mjs +169 -0
  118. package/dist/src/plugins/container/runtimePlugin.mjs.map +1 -0
  119. package/dist/src/plugins/container/types.d.mts +2 -0
  120. package/dist/src/types.d.mts +28 -0
  121. package/dist/utils/flushedChunks.d.mts +22 -0
  122. package/dist/utils/flushedChunks.js +32 -72
  123. package/dist/utils/flushedChunks.js.map +1 -1
  124. package/dist/utils/flushedChunks.mjs +35 -0
  125. package/dist/utils/flushedChunks.mjs.map +1 -0
  126. package/dist/utils/index.d.mts +20 -0
  127. package/dist/utils/index.js +27 -62
  128. package/dist/utils/index.js.map +1 -1
  129. package/dist/utils/index.mjs +22 -0
  130. package/dist/utils/index.mjs.map +1 -0
  131. package/package.json +45 -10
  132. package/dist/node.js +0 -18
  133. package/dist/node.js.map +0 -1
  134. package/dist/package.json +0 -71
  135. package/dist/src/federation-noop.cjs +0 -15
  136. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +0 -19
  137. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +0 -1
  138. package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +0 -1
  139. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +0 -34
  140. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +0 -1
  141. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -78
  142. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
  143. package/dist/src/plugins/container/runtimePlugin.cjs +0 -216
  144. package/dist/src/plugins/container/types.js +0 -3
  145. package/dist/src/plugins/container/types.js.map +0 -1
  146. package/dist/src/types.js +0 -3
  147. package/dist/src/types.js.map +0 -1
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@module-federation/nextjs-mf",
3
- "version": "0.0.0-perf-devtools-20260108034446",
3
+ "version": "0.0.0-perf-website-code-usage-20260914033703",
4
4
  "license": "MIT",
5
5
  "main": "dist/src/index.js",
6
+ "module": "dist/src/index.mjs",
6
7
  "types": "dist/src/index.d.ts",
7
8
  "type": "commonjs",
8
9
  "description": "Module Federation helper for NextJS",
@@ -20,8 +21,26 @@
20
21
  "README.md"
21
22
  ],
22
23
  "exports": {
23
- ".": "./dist/src/index.js",
24
- "./utils": "./dist/utils/index.js",
24
+ ".": {
25
+ "import": {
26
+ "types": "./dist/src/index.d.mts",
27
+ "default": "./dist/src/index.mjs"
28
+ },
29
+ "require": {
30
+ "types": "./dist/src/index.d.ts",
31
+ "default": "./dist/src/index.js"
32
+ }
33
+ },
34
+ "./utils": {
35
+ "import": {
36
+ "types": "./dist/utils/index.d.mts",
37
+ "default": "./dist/utils/index.mjs"
38
+ },
39
+ "require": {
40
+ "types": "./dist/utils/index.d.ts",
41
+ "default": "./dist/utils/index.js"
42
+ }
43
+ },
25
44
  "./*": "./*"
26
45
  },
27
46
  "typesVersions": {
@@ -39,16 +58,19 @@
39
58
  },
40
59
  "dependencies": {
41
60
  "fast-glob": "^3.2.11",
42
- "@module-federation/runtime": "0.0.0-perf-devtools-20260108034446",
43
- "@module-federation/enhanced": "0.0.0-perf-devtools-20260108034446",
44
- "@module-federation/node": "0.0.0-perf-devtools-20260108034446",
45
- "@module-federation/webpack-bundler-runtime": "0.0.0-perf-devtools-20260108034446",
46
- "@module-federation/sdk": "0.0.0-perf-devtools-20260108034446"
61
+ "@module-federation/sdk": "0.0.0-perf-website-code-usage-20260914033703",
62
+ "@module-federation/runtime": "0.0.0-perf-website-code-usage-20260914033703",
63
+ "@module-federation/webpack-bundler-runtime": "0.0.0-perf-website-code-usage-20260914033703",
64
+ "@module-federation/node": "0.0.0-perf-website-code-usage-20260914033703",
65
+ "@module-federation/runtime-core": "0.0.0-perf-website-code-usage-20260914033703",
66
+ "@module-federation/enhanced": "0.0.0-perf-website-code-usage-20260914033703"
47
67
  },
48
68
  "devDependencies": {
49
69
  "@types/btoa": "^1.2.5",
50
70
  "@types/react": "^18.3.1",
51
- "@types/react-dom": "^18.3.1"
71
+ "@types/react-dom": "^18.3.1",
72
+ "tsdown": "0.20.3",
73
+ "typescript": "7.0.2"
52
74
  },
53
75
  "peerDependencies": {
54
76
  "webpack": "^5.40.0",
@@ -61,11 +83,24 @@
61
83
  "webpack": {
62
84
  "optional": true
63
85
  },
86
+ "next": {
87
+ "optional": true
88
+ },
89
+ "react": {
90
+ "optional": true
91
+ },
92
+ "react-dom": {
93
+ "optional": true
94
+ },
64
95
  "styled-jsx": {
65
96
  "optional": true
66
97
  }
67
98
  },
68
99
  "scripts": {
69
- "postinstall": "echo \"Deprecation Notice: We intend to deprecate 'nextjs-mf'. Please see https://github.com/module-federation/core/issues/3153 for more details.\""
100
+ "postinstall": "echo \"Deprecation Notice: We intend to deprecate 'nextjs-mf'. Please see https://github.com/module-federation/core/issues/3153 for more details.\"",
101
+ "build": "tsdown --config tsdown.config.mts && tsc -p tsconfig.lib.json && node ../../tools/scripts/copy-dts-to-dmts.mjs dist",
102
+ "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.js\" \"**/*.ts\"",
103
+ "test": "pnpm exec jest --config jest.config.js --passWithNoTests",
104
+ "pre-release": "pnpm run test && pnpm run build && rm -f ./dist/package.json"
70
105
  }
71
106
  }
package/dist/node.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("@module-federation/node"), exports);
18
- //# sourceMappingURL=node.js.map
package/dist/node.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
package/dist/package.json DELETED
@@ -1,71 +0,0 @@
1
- {
2
- "name": "@module-federation/nextjs-mf",
3
- "version": "0.0.0-perf-devtools-20260108034446",
4
- "license": "MIT",
5
- "main": "dist/src/index.js",
6
- "types": "dist/src/index.d.ts",
7
- "type": "commonjs",
8
- "description": "Module Federation helper for NextJS",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/module-federation/core.git",
12
- "directory": "packages/nextjs-mf"
13
- },
14
- "author": "Zack Jackson <zackary.l.jackson@gmail.com>",
15
- "contributors": [
16
- "Pavel Chertorogov, nodkz <pavel.chertorogov@gmail.com> (www.ps.kz)"
17
- ],
18
- "files": [
19
- "dist/",
20
- "README.md"
21
- ],
22
- "scripts": {
23
- "postinstall": "echo \"Deprecation Notice: We intend to deprecate 'nextjs-mf'. Please see https://github.com/module-federation/core/issues/3153 for more details.\""
24
- },
25
- "exports": {
26
- ".": "./dist/src/index.js",
27
- "./utils": "./dist/utils/index.js",
28
- "./*": "./*"
29
- },
30
- "typesVersions": {
31
- "*": {
32
- ".": [
33
- "./dist/src/index.d.ts"
34
- ],
35
- "utils": [
36
- "./dist/utils/index.d.ts"
37
- ]
38
- }
39
- },
40
- "publishConfig": {
41
- "access": "public"
42
- },
43
- "dependencies": {
44
- "fast-glob": "^3.2.11",
45
- "@module-federation/runtime": "workspace:*",
46
- "@module-federation/sdk": "workspace:*",
47
- "@module-federation/enhanced": "workspace:*",
48
- "@module-federation/node": "workspace:*",
49
- "@module-federation/webpack-bundler-runtime": "workspace:*"
50
- },
51
- "devDependencies": {
52
- "@types/btoa": "^1.2.5",
53
- "@types/react": "^18.3.1",
54
- "@types/react-dom": "^18.3.1"
55
- },
56
- "peerDependencies": {
57
- "webpack": "^5.40.0",
58
- "next": "^12 || ^13 || ^14 || ^15",
59
- "react": "^17 || ^18 || ^19",
60
- "react-dom": "^17 || ^18 || ^19",
61
- "styled-jsx": "*"
62
- },
63
- "peerDependenciesMeta": {
64
- "webpack": {
65
- "optional": true
66
- },
67
- "styled-jsx": {
68
- "optional": true
69
- }
70
- }
71
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- require('next/head');
3
- require('next/router');
4
- require('next/link');
5
- require('next/script');
6
- require('next/image');
7
- require('next/dynamic');
8
- require('next/error');
9
- require('next/amp');
10
- require('styled-jsx');
11
- require('styled-jsx/style');
12
- require('next/image');
13
- // require('react/jsx-dev-runtime');
14
- require('react/jsx-runtime');
15
- //# sourceMappingURL=federation-noop.js.map
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AddRuntimeRequirementToPromiseExternal = void 0;
4
- class AddRuntimeRequirementToPromiseExternal {
5
- apply(compiler) {
6
- compiler.hooks.compilation.tap('AddRuntimeRequirementToPromiseExternal', (compilation) => {
7
- const { RuntimeGlobals } = compiler.webpack;
8
- compilation.hooks.additionalModuleRuntimeRequirements.tap('AddRuntimeRequirementToPromiseExternal', (module, set) => {
9
- if (module.externalType === 'promise') {
10
- set.add(RuntimeGlobals.loadScript);
11
- set.add(RuntimeGlobals.require);
12
- }
13
- });
14
- });
15
- }
16
- }
17
- exports.AddRuntimeRequirementToPromiseExternal = AddRuntimeRequirementToPromiseExternal;
18
- exports.default = AddRuntimeRequirementToPromiseExternal;
19
- //# sourceMappingURL=AddRuntimeRequirementToPromiseExternalPlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AddRuntimeRequirementToPromiseExternalPlugin.js","sourceRoot":"","sources":["../../../src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.ts"],"names":[],"mappings":";;;AAEA,MAAa,sCAAsC;IAGjD,KAAK,CAAC,QAAkB;QACtB,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAC5B,wCAAwC,EACxC,CAAC,WAAW,EAAE,EAAE;YACd,MAAM,EAAE,cAAc,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC;YAC5C,WAAW,CAAC,KAAK,CAAC,mCAAmC,CAAC,GAAG,CACvD,wCAAwC,EACxC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;gBACd,IAAK,MAAc,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;oBAC/C,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;oBACnC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;gBAClC,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AApBD,wFAoBC;AAED,kBAAe,sCAAsC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"regex-equal.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/regex-equal.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACI,MAAM,UAAU,GAAG,CACxB,CAKa,EACb,CAAS,EACA,EAAE;IACX,OAAO,CACL,CAAC,YAAY,MAAM;QACnB,CAAC,YAAY,MAAM;QACnB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU;QAC7B,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,CAC5B,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,UAAU,cAiBrB"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.removeUnnecessarySharedKeys = removeUnnecessarySharedKeys;
7
- /**
8
- * Utility function to remove unnecessary shared keys from the default share scope.
9
- * It checks each key in the shared object against the default share scope.
10
- * If a key is found in the default share scope, a warning is logged and the key is removed from the shared object.
11
- *
12
- * @param {Record<string, unknown>} shared - The shared object to be checked.
13
- */
14
- const internal_1 = require("../../internal");
15
- const logger_1 = __importDefault(require("../../logger"));
16
- /**
17
- * Function to remove unnecessary shared keys from the default share scope.
18
- * It iterates over each key in the shared object and checks against the default share scope.
19
- * If a key is found in the default share scope, a warning is logged and the key is removed from the shared object.
20
- *
21
- * @param {Record<string, unknown>} shared - The shared object to be checked.
22
- */
23
- function removeUnnecessarySharedKeys(shared) {
24
- Object.keys(shared).forEach((key) => {
25
- /**
26
- * If the key is found in the default share scope, log a warning and remove the key from the shared object.
27
- */
28
- if (internal_1.DEFAULT_SHARE_SCOPE[key]) {
29
- logger_1.default.warn(`You are sharing ${key} from the default share scope. This is not necessary and can be removed.`);
30
- delete shared[key];
31
- }
32
- });
33
- }
34
- //# sourceMappingURL=remove-unnecessary-shared-keys.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove-unnecessary-shared-keys.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.ts"],"names":[],"mappings":";;;;;AAiBA,kEAcC;AA/BD;;;;;;GAMG;AACH,6CAAqD;AACrD,0DAAkC;AAElC;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACzC,MAA+B;IAE/B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;QAC1C;;WAEG;QACH,IAAI,8BAAmB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,gBAAM,CAAC,IAAI,CACT,mBAAmB,GAAG,0EAA0E,CACjG,CAAC;YACF,OAAQ,MAAqC,CAAC,GAAG,CAAC,CAAC;QACrD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const sdk_1 = require("@module-federation/sdk");
7
- const logger_1 = __importDefault(require("../../logger"));
8
- /**
9
- * This plugin removes eager modules from the runtime.
10
- * @class RemoveEagerModulesFromRuntimePlugin
11
- */
12
- class RemoveEagerModulesFromRuntimePlugin {
13
- /**
14
- * Creates an instance of RemoveEagerModulesFromRuntimePlugin.
15
- * @param {Object} options - The options for the plugin.
16
- * @param {string} options.container - The container to remove modules from.
17
- * @param {boolean} options.debug - Whether to log debug information.
18
- */
19
- constructor(options) {
20
- this.container = options.container;
21
- this.debug = options.debug || false;
22
- this.modulesToProcess = new Set();
23
- }
24
- /**
25
- * Applies the plugin to the compiler.
26
- * @param {Compiler} compiler - The webpack compiler.
27
- */
28
- apply(compiler) {
29
- if (!this.container) {
30
- logger_1.default.warn(`RemoveEagerModulesFromRuntimePlugin container is not defined: ${this.container}`);
31
- return;
32
- }
33
- (0, sdk_1.bindLoggerToCompiler)(logger_1.default, compiler, 'RemoveEagerModulesFromRuntimePlugin');
34
- compiler.hooks.thisCompilation.tap('RemoveEagerModulesFromRuntimePlugin', (compilation) => {
35
- compilation.hooks.optimizeChunkModules.tap('RemoveEagerModulesFromRuntimePlugin', (chunks, modules) => {
36
- for (const chunk of chunks) {
37
- if (chunk.hasRuntime() && chunk.name === this.container) {
38
- this.processModules(compilation, chunk, modules);
39
- }
40
- }
41
- });
42
- });
43
- }
44
- /**
45
- * Processes the modules in the chunk.
46
- * @param {Compilation} compilation - The webpack compilation.
47
- * @param {Chunk} chunk - The chunk to process.
48
- * @param {Iterable<Module>} modules - The modules in the chunk.
49
- */
50
- processModules(compilation, chunk, modules) {
51
- for (const module of modules) {
52
- if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) {
53
- continue;
54
- }
55
- if (module.constructor.name === 'NormalModule') {
56
- this.modulesToProcess.add(module);
57
- }
58
- }
59
- this.removeModules(compilation, chunk);
60
- }
61
- /**
62
- * Removes the modules from the chunk.
63
- * @param {Compilation} compilation - The webpack compilation.
64
- * @param {Chunk} chunk - The chunk to remove modules from.
65
- */
66
- removeModules(compilation, chunk) {
67
- for (const moduleToRemove of this.modulesToProcess) {
68
- if (this.debug) {
69
- logger_1.default.info(`removing ${moduleToRemove.constructor.name}`);
70
- }
71
- if (compilation.chunkGraph.isModuleInChunk(moduleToRemove, chunk)) {
72
- compilation.chunkGraph.disconnectChunkAndModule(chunk, moduleToRemove);
73
- }
74
- }
75
- }
76
- }
77
- exports.default = RemoveEagerModulesFromRuntimePlugin;
78
- //# sourceMappingURL=RemoveEagerModulesFromRuntimePlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RemoveEagerModulesFromRuntimePlugin.js","sourceRoot":"","sources":["../../../../src/plugins/container/RemoveEagerModulesFromRuntimePlugin.ts"],"names":[],"mappings":";;;;;AACA,gDAA8D;AAC9D,0DAAkC;AAElC;;;GAGG;AACH,MAAM,mCAAmC;IAKvC;;;;;OAKG;IACH,YAAY,OAAgD;QAC1D,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;QACpC,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAkB;QACtB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,gBAAM,CAAC,IAAI,CACT,iEAAiE,IAAI,CAAC,SAAS,EAAE,CAClF,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAA,0BAAoB,EAClB,gBAAM,EACN,QAAQ,EACR,qCAAqC,CACtC,CAAC;QAEF,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAChC,qCAAqC,EACrC,CAAC,WAAwB,EAAE,EAAE;YAC3B,WAAW,CAAC,KAAK,CAAC,oBAAoB,CAAC,GAAG,CACxC,qCAAqC,EACrC,CAAC,MAAuB,EAAE,OAAyB,EAAE,EAAE;gBACrD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC3B,IAAI,KAAK,CAAC,UAAU,EAAE,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;wBACxD,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;oBACnD,CAAC;gBACH,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACK,cAAc,CACpB,WAAwB,EACxB,KAAY,EACZ,OAAyB;QAEzB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC;gBAC3D,SAAS;YACX,CAAC;YAED,IAAI,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;gBAC/C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACK,aAAa,CAAC,WAAwB,EAAE,KAAY;QAC1D,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACnD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,gBAAM,CAAC,IAAI,CAAC,YAAY,cAAc,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7D,CAAC;YAED,IAAI,WAAW,CAAC,UAAU,CAAC,eAAe,CAAC,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;gBAClE,WAAW,CAAC,UAAU,CAAC,wBAAwB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,kBAAe,mCAAmC,CAAC"}
@@ -1,216 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- function default_1() {
5
- return {
6
- name: 'next-internal-plugin',
7
- createScript: function (args) {
8
- const url = args.url;
9
- const attrs = args.attrs;
10
- if (typeof window !== 'undefined') {
11
- const script = document.createElement('script');
12
- script.src = url;
13
- script.async = true;
14
- delete attrs?.['crossorigin'];
15
- return { script: script, timeout: 8000 };
16
- }
17
- return undefined;
18
- },
19
- errorLoadRemote: function (args) {
20
- const id = args.id;
21
- const error = args.error;
22
- const from = args.from;
23
- //@ts-ignore
24
- globalThis.moduleGraphDirty = true;
25
- console.error(id, 'offline');
26
- const pg = function () {
27
- console.error(id, 'offline', error);
28
- return null;
29
- };
30
- pg.getInitialProps = function (ctx) {
31
- return {};
32
- };
33
- let mod;
34
- if (from === 'build') {
35
- mod = function () {
36
- return {
37
- __esModule: true,
38
- default: pg,
39
- getServerSideProps: function () {
40
- return { props: {} };
41
- },
42
- };
43
- };
44
- }
45
- else {
46
- mod = {
47
- default: pg,
48
- getServerSideProps: function () {
49
- return { props: {} };
50
- },
51
- };
52
- }
53
- return mod;
54
- },
55
- beforeInit: function (args) {
56
- if (!globalThis.usedChunks)
57
- globalThis.usedChunks = new Set();
58
- if (typeof __webpack_runtime_id__ === 'string' &&
59
- !__webpack_runtime_id__.startsWith('webpack')) {
60
- return args;
61
- }
62
- const moduleCache = args.origin.moduleCache;
63
- const name = args.origin.name;
64
- let gs;
65
- try {
66
- gs = new Function('return globalThis')();
67
- }
68
- catch (e) {
69
- gs = globalThis; // fallback for browsers without 'unsafe-eval' CSP policy enabled
70
- }
71
- //@ts-ignore
72
- const attachedRemote = gs[name];
73
- if (attachedRemote) {
74
- moduleCache.set(name, attachedRemote);
75
- }
76
- return args;
77
- },
78
- init: function (args) {
79
- return args;
80
- },
81
- beforeRequest: function (args) {
82
- const options = args.options;
83
- const id = args.id;
84
- const remoteName = id.split('/').shift();
85
- const remote = options.remotes.find(function (remote) {
86
- return remote.name === remoteName;
87
- });
88
- if (!remote)
89
- return args;
90
- if (remote && remote.entry && remote.entry.includes('?t=')) {
91
- return args;
92
- }
93
- remote.entry = remote.entry + '?t=' + Date.now();
94
- return args;
95
- },
96
- afterResolve: function (args) {
97
- return args;
98
- },
99
- onLoad: function (args) {
100
- const exposeModuleFactory = args.exposeModuleFactory;
101
- const exposeModule = args.exposeModule;
102
- const id = args.id;
103
- const moduleOrFactory = exposeModuleFactory || exposeModule;
104
- if (!moduleOrFactory)
105
- return args;
106
- if (typeof window === 'undefined') {
107
- let exposedModuleExports;
108
- try {
109
- exposedModuleExports = moduleOrFactory();
110
- }
111
- catch (e) {
112
- exposedModuleExports = moduleOrFactory;
113
- }
114
- const handler = {
115
- get: function (target, prop, receiver) {
116
- if (target === exposedModuleExports &&
117
- typeof exposedModuleExports[prop] === 'function') {
118
- return function () {
119
- globalThis.usedChunks.add(id);
120
- //eslint-disable-next-line
121
- return exposedModuleExports[prop].apply(this, arguments);
122
- };
123
- }
124
- const originalMethod = target[prop];
125
- if (typeof originalMethod === 'function') {
126
- const proxiedFunction = function () {
127
- globalThis.usedChunks.add(id);
128
- //eslint-disable-next-line
129
- return originalMethod.apply(this, arguments);
130
- };
131
- Object.keys(originalMethod).forEach(function (prop) {
132
- Object.defineProperty(proxiedFunction, prop, {
133
- value: originalMethod[prop],
134
- writable: true,
135
- enumerable: true,
136
- configurable: true,
137
- });
138
- });
139
- return proxiedFunction;
140
- }
141
- return Reflect.get(target, prop, receiver);
142
- },
143
- };
144
- if (typeof exposedModuleExports === 'function') {
145
- exposedModuleExports = new Proxy(exposedModuleExports, handler);
146
- const staticProps = Object.getOwnPropertyNames(exposedModuleExports);
147
- staticProps.forEach(function (prop) {
148
- if (typeof exposedModuleExports[prop] === 'function') {
149
- exposedModuleExports[prop] = new Proxy(exposedModuleExports[prop], handler);
150
- }
151
- });
152
- return function () {
153
- return exposedModuleExports;
154
- };
155
- }
156
- else {
157
- exposedModuleExports = new Proxy(exposedModuleExports, handler);
158
- }
159
- return exposedModuleExports;
160
- }
161
- return args;
162
- },
163
- loadRemoteSnapshot(args) {
164
- const { from, remoteSnapshot, manifestUrl, manifestJson, options } = args;
165
- // ensure snapshot is loaded from manifest
166
- if (from !== 'manifest' ||
167
- !manifestUrl ||
168
- !manifestJson ||
169
- !('publicPath' in remoteSnapshot)) {
170
- return args;
171
- }
172
- // re-assign publicPath based on remoteEntry location if in browser nextjs remote
173
- const { publicPath } = remoteSnapshot;
174
- if (options.inBrowser && publicPath.includes('/_next/')) {
175
- remoteSnapshot.publicPath = publicPath.substring(0, publicPath.lastIndexOf('/_next/') + 7);
176
- }
177
- else {
178
- const serverPublicPath = manifestUrl.substring(0, manifestUrl.indexOf('mf-manifest.json'));
179
- remoteSnapshot.publicPath = serverPublicPath;
180
- }
181
- if ('publicPath' in manifestJson.metaData) {
182
- manifestJson.metaData.publicPath = remoteSnapshot.publicPath;
183
- }
184
- return args;
185
- },
186
- resolveShare: function (args) {
187
- if (args.pkgName !== 'react' &&
188
- args.pkgName !== 'react-dom' &&
189
- !args.pkgName.startsWith('next/')) {
190
- return args;
191
- }
192
- const shareScopeMap = args.shareScopeMap;
193
- const scope = args.scope;
194
- const pkgName = args.pkgName;
195
- const version = args.version;
196
- const GlobalFederation = args.GlobalFederation;
197
- const host = GlobalFederation['__INSTANCES__'][0];
198
- if (!host) {
199
- return args;
200
- }
201
- if (!host.options.shared[pkgName]) {
202
- return args;
203
- }
204
- args.resolver = function () {
205
- shareScopeMap[scope][pkgName][version] =
206
- host.options.shared[pkgName][0];
207
- return shareScopeMap[scope][pkgName][version];
208
- };
209
- return args;
210
- },
211
- beforeLoadShare: async function (args) {
212
- return args;
213
- },
214
- };
215
- }
216
- //# sourceMappingURL=runtimePlugin.js.map
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/plugins/container/types.ts"],"names":[],"mappings":""}
package/dist/src/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}