@module-federation/nextjs-mf 0.0.0-docs-remove-invalid-lark-link-20251205062649

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 (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/client/UrlNode.d.ts +17 -0
  4. package/dist/client/UrlNode.js +150 -0
  5. package/dist/client/UrlNode.js.map +1 -0
  6. package/dist/node.d.ts +1 -0
  7. package/dist/node.js +18 -0
  8. package/dist/node.js.map +1 -0
  9. package/dist/package.json +71 -0
  10. package/dist/src/federation-noop.cjs +15 -0
  11. package/dist/src/federation-noop.d.ts +0 -0
  12. package/dist/src/federation-noop.js.map +1 -0
  13. package/dist/src/index.d.ts +3 -0
  14. package/dist/src/index.js +12 -0
  15. package/dist/src/index.js.map +1 -0
  16. package/dist/src/internal.d.ts +50 -0
  17. package/dist/src/internal.js +255 -0
  18. package/dist/src/internal.js.map +1 -0
  19. package/dist/src/loaders/fixImageLoader.d.ts +22 -0
  20. package/dist/src/loaders/fixImageLoader.js +116 -0
  21. package/dist/src/loaders/fixImageLoader.js.map +1 -0
  22. package/dist/src/loaders/fixUrlLoader.d.ts +13 -0
  23. package/dist/src/loaders/fixUrlLoader.js +24 -0
  24. package/dist/src/loaders/fixUrlLoader.js.map +1 -0
  25. package/dist/src/loaders/helpers.d.ts +17 -0
  26. package/dist/src/loaders/helpers.js +134 -0
  27. package/dist/src/loaders/helpers.js.map +1 -0
  28. package/dist/src/loaders/nextPageMapLoader.d.ts +24 -0
  29. package/dist/src/loaders/nextPageMapLoader.js +166 -0
  30. package/dist/src/loaders/nextPageMapLoader.js.map +1 -0
  31. package/dist/src/logger.d.ts +2 -0
  32. package/dist/src/logger.js +9 -0
  33. package/dist/src/logger.js.map +1 -0
  34. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
  35. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +19 -0
  36. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
  37. package/dist/src/plugins/CopyFederationPlugin.d.ts +20 -0
  38. package/dist/src/plugins/CopyFederationPlugin.js +74 -0
  39. package/dist/src/plugins/CopyFederationPlugin.js.map +1 -0
  40. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +23 -0
  41. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +58 -0
  42. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -0
  43. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +36 -0
  44. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +135 -0
  45. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -0
  46. package/dist/src/plugins/NextFederationPlugin/index.d.ts +27 -0
  47. package/dist/src/plugins/NextFederationPlugin/index.js +186 -0
  48. package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -0
  49. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.ts +20 -0
  50. package/dist/src/plugins/NextFederationPlugin/next-fragments.js +100 -0
  51. package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -0
  52. package/dist/src/plugins/NextFederationPlugin/regex-equal.d.ts +14 -0
  53. package/dist/src/plugins/NextFederationPlugin/regex-equal.js +25 -0
  54. package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +1 -0
  55. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +8 -0
  56. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +34 -0
  57. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +1 -0
  58. package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +16 -0
  59. package/dist/src/plugins/NextFederationPlugin/set-options.js +22 -0
  60. package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -0
  61. package/dist/src/plugins/NextFederationPlugin/validate-options.d.ts +25 -0
  62. package/dist/src/plugins/NextFederationPlugin/validate-options.js +45 -0
  63. package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -0
  64. package/dist/src/plugins/container/InvertedContainerPlugin.d.ts +5 -0
  65. package/dist/src/plugins/container/InvertedContainerPlugin.js +28 -0
  66. package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -0
  67. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +11 -0
  68. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +69 -0
  69. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -0
  70. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +39 -0
  71. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +78 -0
  72. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +1 -0
  73. package/dist/src/plugins/container/runtimePlugin.cjs +216 -0
  74. package/dist/src/plugins/container/runtimePlugin.d.ts +2 -0
  75. package/dist/src/plugins/container/runtimePlugin.js.map +1 -0
  76. package/dist/src/plugins/container/types.d.ts +2 -0
  77. package/dist/src/plugins/container/types.js +3 -0
  78. package/dist/src/plugins/container/types.js.map +1 -0
  79. package/dist/src/types.d.ts +28 -0
  80. package/dist/src/types.js +3 -0
  81. package/dist/src/types.js.map +1 -0
  82. package/dist/utils/flushedChunks.d.ts +22 -0
  83. package/dist/utils/flushedChunks.js +77 -0
  84. package/dist/utils/flushedChunks.js.map +1 -0
  85. package/dist/utils/index.d.ts +20 -0
  86. package/dist/utils/index.js +66 -0
  87. package/dist/utils/index.js.map +1 -0
  88. package/package.json +71 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":";;;AAaA,MAAM,oBAAoB,GAAG;IAC3B;;OAEG;IACH,MAAM,EAAE,QAAQ;IAChB;;;OAGG;IACH,qBAAqB,EAAE,KAAK;IAC5B;;OAEG;IACH,mBAAmB,E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rB;AAEJ;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,CAAC,KAAY,EAAU,EAAE;IAC3C,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACxB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,IAAI,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;GAMG;AACI,MAAM,eAAe,GAAG,CAAC,GAAY,EAAU,EAAE;IACtD,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B"}
@@ -0,0 +1,22 @@
1
+ import type { LoaderContext } from 'webpack';
2
+ /**
3
+ * This loader is specifically created for tuning the next-image-loader result.
4
+ * It modifies the regular string output of the next-image-loader.
5
+ * For server-side rendering (SSR), it injects the remote scope of a specific remote URL.
6
+ * For client-side rendering (CSR), it injects the document.currentScript.src.
7
+ * After these injections, it selects the full URI before _next.
8
+ *
9
+ * @example
10
+ * http://localhost:1234/test/test2/_next/static/media/ssl.e3019f0e.svg
11
+ * will become
12
+ * http://localhost:1234/test/test2
13
+ *
14
+ * @param {LoaderContext<Record<string, unknown>>} this - The loader context.
15
+ * @param {string} remaining - The remaining part of the resource path.
16
+ * @returns {string} The modified source code with the injected code.
17
+ */
18
+ export declare function fixImageLoader(this: LoaderContext<Record<string, unknown>>, remaining: string): Promise<string>;
19
+ /**
20
+ * The pitch function of the loader, which is the same as the fixImageLoader function.
21
+ */
22
+ export declare const pitch: typeof fixImageLoader;
@@ -0,0 +1,116 @@
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.pitch = void 0;
7
+ exports.fixImageLoader = fixImageLoader;
8
+ const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
9
+ const { Template } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
10
+ const path_1 = __importDefault(require("path"));
11
+ /**
12
+ * This loader is specifically created for tuning the next-image-loader result.
13
+ * It modifies the regular string output of the next-image-loader.
14
+ * For server-side rendering (SSR), it injects the remote scope of a specific remote URL.
15
+ * For client-side rendering (CSR), it injects the document.currentScript.src.
16
+ * After these injections, it selects the full URI before _next.
17
+ *
18
+ * @example
19
+ * http://localhost:1234/test/test2/_next/static/media/ssl.e3019f0e.svg
20
+ * will become
21
+ * http://localhost:1234/test/test2
22
+ *
23
+ * @param {LoaderContext<Record<string, unknown>>} this - The loader context.
24
+ * @param {string} remaining - The remaining part of the resource path.
25
+ * @returns {string} The modified source code with the injected code.
26
+ */
27
+ async function fixImageLoader(remaining) {
28
+ this.cacheable(true);
29
+ const isServer = this._compiler?.options?.name !== 'client';
30
+ const publicPath = this._compiler?.webpack?.RuntimeGlobals?.publicPath ?? '';
31
+ const result = await this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!${remaining}`);
32
+ const content = (result.default || result);
33
+ const computedAssetPrefix = isServer
34
+ ? `${Template.asString([
35
+ 'function getSSRImagePath(){',
36
+ //TODO: use auto public path plugin instead
37
+ `const pubpath = ${publicPath};`,
38
+ Template.asString([
39
+ 'try {',
40
+ Template.indent([
41
+ "const globalThisVal = new Function('return globalThis')();",
42
+ 'const name = __webpack_require__.federation.instance.name',
43
+ `const container = globalThisVal['__FEDERATION__']['__INSTANCES__'].find(
44
+ (instance) => {
45
+ if(!instance) return;
46
+ if (!instance.moduleCache.has(name)) return;
47
+ const container = instance.moduleCache.get(name);
48
+ if (!container.remoteInfo) return;
49
+ return container.remoteInfo.entry;
50
+ },
51
+ );`,
52
+ 'if(!container) return "";',
53
+ 'const cache = container.moduleCache',
54
+ 'const remote = cache.get(name).remoteInfo',
55
+ `const remoteEntry = remote.entry;`,
56
+ `if (remoteEntry) {`,
57
+ Template.indent([
58
+ `const splitted = remoteEntry.split('/_next')`,
59
+ `return splitted.length === 2 ? splitted[0] : '';`,
60
+ ]),
61
+ `}`,
62
+ `return '';`,
63
+ ]),
64
+ '} catch (e) {',
65
+ Template.indent([
66
+ `console.error('failed generating SSR image path', e);`,
67
+ 'return "";',
68
+ ]),
69
+ '}',
70
+ ]),
71
+ '}()',
72
+ ])}`
73
+ : `${Template.asString([
74
+ 'function getCSRImagePath(){',
75
+ Template.indent([
76
+ 'try {',
77
+ Template.indent([
78
+ `const splitted = ${publicPath} ? ${publicPath}.split('/_next') : '';`,
79
+ `return splitted.length === 2 ? splitted[0] : '';`,
80
+ ]),
81
+ '} catch (e) {',
82
+ Template.indent([
83
+ `const path = document.currentScript && document.currentScript.src;`,
84
+ `console.error('failed generating CSR image path', e, path);`,
85
+ 'return "";',
86
+ ]),
87
+ '}',
88
+ ]),
89
+ '}()',
90
+ ])}`;
91
+ const constructedObject = Object.entries(content).reduce((acc, [key, value]) => {
92
+ if (key === 'src') {
93
+ if (value && !value.includes('://')) {
94
+ value = path_1.default.join(value);
95
+ }
96
+ acc.push(`${key}: computedAssetsPrefixReference + ${JSON.stringify(value)}`);
97
+ return acc;
98
+ }
99
+ acc.push(`${key}: ${JSON.stringify(value)}`);
100
+ return acc;
101
+ }, []);
102
+ return Template.asString([
103
+ "let computedAssetsPrefixReference = '';",
104
+ 'try {',
105
+ Template.indent(`computedAssetsPrefixReference = ${computedAssetPrefix};`),
106
+ '} catch (e) {}',
107
+ 'export default {',
108
+ Template.indent(constructedObject.join(',\n')),
109
+ '}',
110
+ ]);
111
+ }
112
+ /**
113
+ * The pitch function of the loader, which is the same as the fixImageLoader function.
114
+ */
115
+ exports.pitch = fixImageLoader;
116
+ //# sourceMappingURL=fixImageLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixImageLoader.js","sourceRoot":"","sources":["../../../src/loaders/fixImageLoader.ts"],"names":[],"mappings":";;;;;;AAuBA,wC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CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACU,QAAA,KAAK,GAAG,cAAc,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `fixUrlLoader` is a custom loader designed to modify the output of the url-loader.
3
+ * It injects the PUBLIC_PATH from the webpack runtime into the output.
4
+ * The output format is: `export default __webpack_require__.p + "/static/media/ssl.e3019f0e.svg"`
5
+ *
6
+ * `__webpack_require__.p` is a global variable in the webpack container that contains the publicPath.
7
+ * For example, it could be: http://localhost:3000/_next
8
+ *
9
+ * @param {string} content - The original output from the url-loader.
10
+ * @returns {string} The modified output with the injected PUBLIC_PATH.
11
+ */
12
+ export declare function fixUrlLoader(content: string): string;
13
+ export default fixUrlLoader;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fixUrlLoader = fixUrlLoader;
4
+ /**
5
+ * `fixUrlLoader` is a custom loader designed to modify the output of the url-loader.
6
+ * It injects the PUBLIC_PATH from the webpack runtime into the output.
7
+ * The output format is: `export default __webpack_require__.p + "/static/media/ssl.e3019f0e.svg"`
8
+ *
9
+ * `__webpack_require__.p` is a global variable in the webpack container that contains the publicPath.
10
+ * For example, it could be: http://localhost:3000/_next
11
+ *
12
+ * @param {string} content - The original output from the url-loader.
13
+ * @returns {string} The modified output with the injected PUBLIC_PATH.
14
+ */
15
+ function fixUrlLoader(content) {
16
+ // This regular expression extracts the hostname from the publicPath.
17
+ // For example, it transforms http://localhost:3000/_next/... into http://localhost:3000
18
+ const currentHostnameCode = "__webpack_require__.p.replace(/(.+\\:\\/\\/[^\\/]+){0,1}\\/.*/i, '$1')";
19
+ // Replace the default export path in the content with the modified path that includes the hostname.
20
+ return content.replace('export default "/', `export default ${currentHostnameCode}+"/`);
21
+ }
22
+ // Export the fixUrlLoader function as the default export of this module.
23
+ exports.default = fixUrlLoader;
24
+ //# sourceMappingURL=fixUrlLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixUrlLoader.js","sourceRoot":"","sources":["../../../src/loaders/fixUrlLoader.ts"],"names":[],"mappings":";;AAWA,oCAWC;AAtBD;;;;;;;;;;GAUG;AACH,SAAgB,YAAY,CAAC,OAAe;IAC1C,qEAAqE;IACrE,wFAAwF;IACxF,MAAM,mBAAmB,GACvB,wEAAwE,CAAC;IAE3E,oGAAoG;IACpG,OAAO,OAAO,CAAC,OAAO,CACpB,mBAAmB,EACnB,kBAAkB,mBAAmB,KAAK,CAC3C,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { RuleSetRule, RuleSetUseItem } from 'webpack';
2
+ export declare function injectRuleLoader(rule: any, loader?: RuleSetUseItem): void;
3
+ /**
4
+ * This function checks if the current module rule has a loader with the provided name.
5
+ *
6
+ * @param {RuleSetRule} rule - The current module rule.
7
+ * @param {string} loaderName - The name of the loader to check.
8
+ * @returns {boolean} Returns true if the current module rule has a loader with the provided name, otherwise false.
9
+ */
10
+ export declare function hasLoader(rule: RuleSetRule, loaderName: string): boolean;
11
+ interface Resource {
12
+ path: string;
13
+ layer?: string;
14
+ issuerLayer?: string;
15
+ }
16
+ export declare function findLoaderForResource(rules: RuleSetRule[], resource: Resource, path?: string[]): RuleSetRule | null;
17
+ export {};
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.injectRuleLoader = injectRuleLoader;
4
+ exports.hasLoader = hasLoader;
5
+ exports.findLoaderForResource = findLoaderForResource;
6
+ function injectRuleLoader(rule, loader = {}) {
7
+ if (rule !== '...') {
8
+ const _rule = rule;
9
+ if (_rule.loader) {
10
+ _rule.use = [loader, { loader: _rule.loader, options: _rule.options }];
11
+ delete _rule.loader;
12
+ delete _rule.options;
13
+ }
14
+ else if (_rule.use) {
15
+ _rule.use = [loader, ..._rule.use];
16
+ }
17
+ }
18
+ }
19
+ /**
20
+ * This function checks if the current module rule has a loader with the provided name.
21
+ *
22
+ * @param {RuleSetRule} rule - The current module rule.
23
+ * @param {string} loaderName - The name of the loader to check.
24
+ * @returns {boolean} Returns true if the current module rule has a loader with the provided name, otherwise false.
25
+ */
26
+ function hasLoader(rule, loaderName) {
27
+ //@ts-ignore
28
+ if (rule !== '...') {
29
+ const _rule = rule;
30
+ if (_rule.loader === loaderName) {
31
+ return true;
32
+ }
33
+ else if (_rule.use && Array.isArray(_rule.use)) {
34
+ for (let i = 0; i < _rule.use.length; i++) {
35
+ const loader = _rule.use[i];
36
+ if (typeof loader !== 'string' &&
37
+ typeof loader !== 'function' &&
38
+ loader.loader &&
39
+ (loader.loader === loaderName ||
40
+ loader.loader.includes(`/${loaderName}/`))) {
41
+ return true;
42
+ }
43
+ else if (typeof loader === 'string') {
44
+ if (loader === loaderName || loader.includes(`/${loaderName}/`)) {
45
+ return true;
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ return false;
52
+ }
53
+ function matchesCondition(condition, resource, currentPath) {
54
+ if (condition instanceof RegExp) {
55
+ return condition.test(resource.path);
56
+ }
57
+ else if (typeof condition === 'string') {
58
+ return resource.path.includes(condition);
59
+ }
60
+ else if (typeof condition === 'function') {
61
+ return condition(resource.path);
62
+ }
63
+ else if (typeof condition === 'object') {
64
+ if ('test' in condition && condition.test) {
65
+ const tests = Array.isArray(condition.test)
66
+ ? condition.test
67
+ : [condition.test];
68
+ if (!tests.some((test) => matchesCondition(test, resource, currentPath))) {
69
+ return false;
70
+ }
71
+ }
72
+ if ('include' in condition && condition.include) {
73
+ const includes = Array.isArray(condition.include)
74
+ ? condition.include
75
+ : [condition.include];
76
+ if (!includes.some((include) => matchesCondition(include, resource, currentPath))) {
77
+ return false;
78
+ }
79
+ }
80
+ if ('exclude' in condition && condition.exclude) {
81
+ const excludes = Array.isArray(condition.exclude)
82
+ ? condition.exclude
83
+ : [condition.exclude];
84
+ if (excludes.some((exclude) => matchesCondition(exclude, resource, currentPath))) {
85
+ return false;
86
+ }
87
+ }
88
+ if ('and' in condition && condition.and) {
89
+ return condition.and.every((cond) => matchesCondition(cond, resource, currentPath));
90
+ }
91
+ if ('or' in condition && condition.or) {
92
+ return condition.or.some((cond) => matchesCondition(cond, resource, currentPath));
93
+ }
94
+ if ('not' in condition && condition.not) {
95
+ return !matchesCondition(condition.not, resource, currentPath);
96
+ }
97
+ if ('layer' in condition && condition.layer) {
98
+ if (!resource.layer ||
99
+ !matchesCondition(condition.layer, { path: resource.layer }, currentPath)) {
100
+ return false;
101
+ }
102
+ }
103
+ if ('issuerLayer' in condition && condition.issuerLayer) {
104
+ if (!resource.issuerLayer ||
105
+ !matchesCondition(condition.issuerLayer, { path: resource.issuerLayer }, currentPath)) {
106
+ return false;
107
+ }
108
+ }
109
+ }
110
+ return true;
111
+ }
112
+ function findLoaderForResource(rules, resource, path = []) {
113
+ let lastMatchedRule = null;
114
+ for (let i = 0; i < rules.length; i++) {
115
+ const rule = rules[i];
116
+ const currentPath = [...path, `rules[${i}]`];
117
+ if (rule.oneOf) {
118
+ for (let j = 0; j < rule.oneOf.length; j++) {
119
+ const subRule = rule.oneOf[j];
120
+ const subPath = [...currentPath, `oneOf[${j}]`];
121
+ if (subRule &&
122
+ matchesCondition(subRule, resource, subPath.join('->'))) {
123
+ return subRule;
124
+ }
125
+ }
126
+ }
127
+ else if (rule &&
128
+ matchesCondition(rule, resource, currentPath.join(' -> '))) {
129
+ lastMatchedRule = rule;
130
+ }
131
+ }
132
+ return lastMatchedRule;
133
+ }
134
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/loaders/helpers.ts"],"names":[],"mappings":";;AAOA,4CAeC;AASD,8BA8BC;AAqGD,sDA6BC;AAxLD,SAAgB,gBAAgB,CAAC,IAAS,EAAE,SAAyB,EAAE;IACrE,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,IAIb,CAAC;QACF,IAAI,KAAK,CAA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C,CAAC,CAAC;gBAC9B,MAAM,OAAO,GAAG,CAAC,GAAG,WAAW,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;gBAEhD,IACE,OAAO;oBACP,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EACvD,CAAC;oBACD,OAAO,OAAO,CAAC;gBACjB,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IACL,IAAI;YACJ,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAC1D,CAAC;YACD,eAAe,GAAG,IAAI,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { LoaderContext } from 'webpack';
2
+ /**
3
+ * Webpack loader which prepares MF map for NextJS pages.
4
+ * This function is the main entry point for the loader.
5
+ * It gets the options passed to the loader and prepares the pages map.
6
+ * If the 'v2' option is passed, it prepares the pages map using the 'preparePageMapV2' function.
7
+ * Otherwise, it uses the 'preparePageMap' function.
8
+ * Finally, it calls the loader's callback function with the prepared pages map.
9
+ *
10
+ * @param {LoaderContext<Record<string, unknown>>} this - The loader context.
11
+ */
12
+ export default function nextPageMapLoader(this: LoaderContext<Record<string, unknown>>): void;
13
+ /**
14
+ * Webpack config generator for `exposes` option.
15
+ * This function generates the webpack config for the 'exposes' option.
16
+ * It creates a map of pages to modules and returns an object with the pages map and the pages map v2.
17
+ *
18
+ * @param {string} cwd - The current working directory.
19
+ * @returns {Record<string, string>} The webpack config for the 'exposes' option.
20
+ */
21
+ export declare function exposeNextjsPages(cwd: string): {
22
+ './pages-map': string;
23
+ './pages-map-v2': string;
24
+ };
@@ -0,0 +1,166 @@
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.default = nextPageMapLoader;
7
+ exports.exposeNextjsPages = exposeNextjsPages;
8
+ const fast_glob_1 = __importDefault(require("fast-glob"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const UrlNode_1 = require("../../client/UrlNode");
11
+ /**
12
+ * Webpack loader which prepares MF map for NextJS pages.
13
+ * This function is the main entry point for the loader.
14
+ * It gets the options passed to the loader and prepares the pages map.
15
+ * If the 'v2' option is passed, it prepares the pages map using the 'preparePageMapV2' function.
16
+ * Otherwise, it uses the 'preparePageMap' function.
17
+ * Finally, it calls the loader's callback function with the prepared pages map.
18
+ *
19
+ * @param {LoaderContext<Record<string, unknown>>} this - The loader context.
20
+ */
21
+ function nextPageMapLoader() {
22
+ // const [pagesRoot] = getNextPagesRoot(this.rootContext);
23
+ // this.addContextDependency(pagesRoot);
24
+ const opts = this.getOptions();
25
+ const pages = getNextPages(this.rootContext);
26
+ let result = {};
27
+ if (Object.hasOwnProperty.call(opts, 'v2')) {
28
+ result = preparePageMapV2(pages);
29
+ }
30
+ else {
31
+ result = preparePageMap(pages);
32
+ }
33
+ this.callback(null, `module.exports = { default: ${JSON.stringify(result)} };`);
34
+ }
35
+ /**
36
+ * Webpack config generator for `exposes` option.
37
+ * This function generates the webpack config for the 'exposes' option.
38
+ * It creates a map of pages to modules and returns an object with the pages map and the pages map v2.
39
+ *
40
+ * @param {string} cwd - The current working directory.
41
+ * @returns {Record<string, string>} The webpack config for the 'exposes' option.
42
+ */
43
+ function exposeNextjsPages(cwd) {
44
+ const pages = getNextPages(cwd);
45
+ const pageModulesMap = {};
46
+ pages.forEach((page) => {
47
+ // Creating a map of pages to modules
48
+ // './pages/storage/index': './pages/storage/index.tsx',
49
+ // './pages/storage/[...slug]': './pages/storage/[...slug].tsx',
50
+ pageModulesMap['./' + sanitizePagePath(page)] = `./${page}`;
51
+ });
52
+ return {
53
+ './pages-map': `${__filename}!${__filename}`,
54
+ './pages-map-v2': `${__filename}?v2!${__filename}`,
55
+ ...pageModulesMap,
56
+ };
57
+ }
58
+ /**
59
+ * This function gets the root directory of the NextJS pages.
60
+ * It checks if the 'src/pages/' directory exists.
61
+ * If it does, it returns the absolute path and the relative path to this directory.
62
+ * If it doesn't, it returns the absolute path and the relative path to the 'pages/' directory.
63
+ *
64
+ * @param {string} appRoot - The root directory of the application.
65
+ * @returns {[string, string]} The absolute path and the relative path to the pages directory.
66
+ */
67
+ function getNextPagesRoot(appRoot) {
68
+ let pagesDir = 'src/pages/';
69
+ let absPageDir = `${appRoot}/${pagesDir}`;
70
+ if (!fs_1.default.existsSync(absPageDir)) {
71
+ pagesDir = 'pages/';
72
+ absPageDir = `${appRoot}/${pagesDir}`;
73
+ }
74
+ return [absPageDir, pagesDir];
75
+ }
76
+ /**
77
+ * This function scans the pages directory and returns a list of user defined pages.
78
+ * It excludes special pages like '_app', '_document', '_error', '404', '500', and federation pages.
79
+ *
80
+ * @param {string} rootDir - The root directory of the application.
81
+ * @returns {string[]} The list of user defined pages.
82
+ */
83
+ function getNextPages(rootDir) {
84
+ const [cwd, pagesDir] = getNextPagesRoot(rootDir);
85
+ // scan all files in pages folder except pages/api
86
+ let pageList = fast_glob_1.default.sync('**/*.{ts,tsx,js,jsx}', {
87
+ cwd,
88
+ onlyFiles: true,
89
+ ignore: ['api/**'],
90
+ });
91
+ // remove specific nextjs pages
92
+ const exclude = [
93
+ /^_app\..*/, // _app.tsx
94
+ /^_document\..*/, // _document.tsx
95
+ /^_error\..*/, // _error.tsx
96
+ /^404\..*/, // 404.tsx
97
+ /^500\..*/, // 500.tsx
98
+ /^\[\.\.\..*\]\..*/, // /[...federationPage].tsx
99
+ ];
100
+ pageList = pageList.filter((page) => {
101
+ return !exclude.some((r) => r.test(page));
102
+ });
103
+ pageList = pageList.map((page) => `${pagesDir}${page}`);
104
+ return pageList;
105
+ }
106
+ /**
107
+ * This function sanitizes a page path.
108
+ * It removes the 'src/pages/' prefix and the file extension.
109
+ *
110
+ * @param {string} item - The page path to sanitize.
111
+ * @returns {string} The sanitized page path.
112
+ */
113
+ function sanitizePagePath(item) {
114
+ return item
115
+ .replace(/^src\/pages\//i, 'pages/')
116
+ .replace(/\.(ts|tsx|js|jsx)$/, '');
117
+ }
118
+ /**
119
+ * This function creates a MF map from a list of NextJS pages.
120
+ * It sanitizes the page paths and sorts them using the 'UrlNode' class.
121
+ * Then, it creates a map with the sorted page paths as keys and the original page paths as values.
122
+ *
123
+ * @param {string[]} pages - The list of NextJS pages.
124
+ * @returns {Record<string, string>} The MF map.
125
+ */
126
+ function preparePageMap(pages) {
127
+ const result = {};
128
+ const clearedPages = pages.map((p) => `/${sanitizePagePath(p)}`);
129
+ // getSortedRoutes @see https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/router/utils/sorted-routes.ts
130
+ const root = new UrlNode_1.UrlNode();
131
+ clearedPages.forEach((pagePath) => root.insert(pagePath));
132
+ // Smoosh will then sort those sublevels up to the point where you get the correct route definition priority
133
+ const sortedPages = root.smoosh();
134
+ sortedPages.forEach((page) => {
135
+ let key = page
136
+ .replace(/\[\.\.\.[^\]]+\]/gi, '*')
137
+ .replace(/\[([^\]]+)\]/gi, ':$1');
138
+ key = key.replace(/^\/pages\//, '/').replace(/\/index$/, '') || '/';
139
+ result[key] = `.${page}`;
140
+ });
141
+ return result;
142
+ }
143
+ /**
144
+ * This function creates a MF list from a list of NextJS pages.
145
+ * It sanitizes the page paths and sorts them using the 'UrlNode' class.
146
+ * Then, it creates a map with the sorted page paths as keys and the original page paths as values.
147
+ * Unlike the 'preparePageMap' function, this function does not replace the '[...]' and '[]' parts in the page paths.
148
+ *
149
+ * @param {string[]} pages - The list of NextJS pages.
150
+ * @returns {Record<string, string>} The MF list.
151
+ */
152
+ function preparePageMapV2(pages) {
153
+ const result = {};
154
+ const clearedPages = pages.map((p) => `/${sanitizePagePath(p)}`);
155
+ // getSortedRoutes @see https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/router/utils/sorted-routes.ts
156
+ const root = new UrlNode_1.UrlNode();
157
+ clearedPages.forEach((pagePath) => root.insert(pagePath));
158
+ // Smoosh will then sort those sublevels up to the point where you get the correct route definition priority
159
+ const sortedPages = root.smoosh();
160
+ sortedPages.forEach((page) => {
161
+ const key = page.replace(/^\/pages\//, '/').replace(/\/index$/, '') || '/';
162
+ result[key] = `.${page}`;
163
+ });
164
+ return result;
165
+ }
166
+ //# sourceMappingURL=nextPageMapLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextPageMapLoader.js","sourceRoot":"","sources":["../../../src/loaders/nextPageMapLoader.ts"],"names":[],"mappings":";;;;;AAiBA,oCAoBC;AAUD,8CAgBC;AA7DD,0DAA2B;AAC3B,4CAAoB;AAEpB,kDAA+C;AAE/C;;;;;;;;;GASG;AACH,SAAwB,iBAAiB;IAGvC,0DAA0D;IAC1D,wCAAwC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAE7C,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,IAAI,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,CAAC,QAAQ,CACX,IAAI,EACJ,+BAA+B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAC3D,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAEhC,MAAM,cAAc,GAAG,EAA4B,CAAC;IACpD,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,qCAAqC;Q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AE,CAAC,IAAI,GAAG,CAAC;QACpE,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CAAC,KAAe;IACvC,MAAM,MAAM,GAAG,EAA4B,CAAC;IAE5C,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAEjE,4HAA4H;IAC5H,MAAM,IAAI,GAAG,IAAI,iBAAO,EAAE,CAAC;IAC3B,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1D,4GAA4G;IAC5G,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAElC,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;QAC3E,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const logger: import("@module-federation/sdk").Logger;
2
+ export default logger;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const sdk_1 = require("@module-federation/sdk");
4
+ const createBundlerLogger = typeof sdk_1.createInfrastructureLogger === 'function'
5
+ ? sdk_1.createInfrastructureLogger
6
+ : sdk_1.createLogger;
7
+ const logger = createBundlerLogger('[ nextjs-mf ]');
8
+ exports.default = logger;
9
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";;AAAA,gDAGgC;AAEhC,MAAM,mBAAmB,GACvB,OAAO,gCAA0B,KAAK,UAAU;IAC9C,CAAC,CAAE,gCAA6D;IAChE,CAAC,CAAC,kBAAY,CAAC;AAEnB,MAAM,MAAM,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAC;AAEpD,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
+ export declare class AddRuntimeRequirementToPromiseExternal implements WebpackPluginInstance {
3
+ apply(compiler: Compiler): void;
4
+ }
5
+ export default AddRuntimeRequirementToPromiseExternal;
@@ -0,0 +1,19 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,20 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
+ /**
3
+ * Plugin to copy build output files.
4
+ * @class
5
+ */
6
+ declare class CopyBuildOutputPlugin implements WebpackPluginInstance {
7
+ private isServer;
8
+ /**
9
+ * @param {boolean} isServer - Indicates if the current environment is server.
10
+ * @constructor
11
+ */
12
+ constructor(isServer: boolean);
13
+ /**
14
+ * Applies the plugin to the compiler.
15
+ * @param {Compiler} compiler - The webpack compiler object.
16
+ * @method
17
+ */
18
+ apply(compiler: Compiler): void;
19
+ }
20
+ export default CopyBuildOutputPlugin;