@module-federation/nextjs-mf 8.8.55 → 8.8.57

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 (143) 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.js +89 -147
  5. package/dist/client/UrlNode.js.map +1 -1
  6. package/dist/client/UrlNode.mjs +91 -0
  7. package/dist/client/UrlNode.mjs.map +1 -0
  8. package/dist/src/federation-noop.d.mts +1 -0
  9. package/dist/src/federation-noop.d.ts +1 -0
  10. package/dist/src/federation-noop.js +17 -0
  11. package/dist/src/federation-noop.js.map +1 -1
  12. package/dist/src/federation-noop.mjs +23 -0
  13. package/dist/src/federation-noop.mjs.map +1 -0
  14. package/dist/src/index.d.mts +2 -0
  15. package/dist/src/index.d.ts +2 -3
  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.js +140 -243
  21. package/dist/src/internal.js.map +1 -1
  22. package/dist/src/internal.mjs +152 -0
  23. package/dist/src/internal.mjs.map +1 -0
  24. package/dist/src/loaders/fixImageLoader.d.mts +27 -0
  25. package/dist/src/loaders/fixImageLoader.d.ts +8 -3
  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 +16 -0
  31. package/dist/src/loaders/fixUrlLoader.d.ts +5 -2
  32. package/dist/src/loaders/fixUrlLoader.js +17 -19
  33. package/dist/src/loaders/fixUrlLoader.js.map +1 -1
  34. package/dist/src/loaders/fixUrlLoader.mjs +19 -0
  35. package/dist/src/loaders/fixUrlLoader.mjs.map +1 -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 +29 -0
  41. package/dist/src/loaders/nextPageMapLoader.d.ts +10 -5
  42. package/dist/src/loaders/nextPageMapLoader.js +126 -144
  43. package/dist/src/loaders/nextPageMapLoader.js.map +1 -1
  44. package/dist/src/loaders/nextPageMapLoader.mjs +143 -0
  45. package/dist/src/loaders/nextPageMapLoader.mjs.map +1 -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/CopyFederationPlugin.js +64 -71
  51. package/dist/src/plugins/CopyFederationPlugin.js.map +1 -1
  52. package/dist/src/plugins/CopyFederationPlugin.mjs +65 -0
  53. package/dist/src/plugins/CopyFederationPlugin.mjs.map +1 -0
  54. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +36 -53
  55. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
  56. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs +40 -0
  57. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs.map +1 -0
  58. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +103 -121
  59. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
  60. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs +111 -0
  61. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs.map +1 -0
  62. package/dist/src/plugins/NextFederationPlugin/index.d.mts +31 -0
  63. package/dist/src/plugins/NextFederationPlugin/index.d.ts +27 -23
  64. package/dist/src/plugins/NextFederationPlugin/index.js +147 -181
  65. package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -1
  66. package/dist/src/plugins/NextFederationPlugin/index.mjs +150 -0
  67. package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -0
  68. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +18 -0
  69. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.ts +16 -18
  70. package/dist/src/plugins/NextFederationPlugin/next-fragments.js +62 -92
  71. package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
  72. package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs +68 -0
  73. package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs.map +1 -0
  74. package/dist/src/plugins/NextFederationPlugin/set-options.js +17 -19
  75. package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
  76. package/dist/src/plugins/NextFederationPlugin/set-options.mjs +19 -0
  77. package/dist/src/plugins/NextFederationPlugin/set-options.mjs.map +1 -0
  78. package/dist/src/plugins/NextFederationPlugin/validate-options.js +30 -38
  79. package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
  80. package/dist/src/plugins/NextFederationPlugin/validate-options.mjs +35 -0
  81. package/dist/src/plugins/NextFederationPlugin/validate-options.mjs.map +1 -0
  82. package/dist/src/plugins/container/InvertedContainerPlugin.js +22 -25
  83. package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
  84. package/dist/src/plugins/container/InvertedContainerPlugin.mjs +23 -0
  85. package/dist/src/plugins/container/InvertedContainerPlugin.mjs.map +1 -0
  86. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +55 -67
  87. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
  88. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs +57 -0
  89. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -0
  90. package/dist/src/plugins/container/runtimePlugin.d.mts +7 -0
  91. package/dist/src/plugins/container/runtimePlugin.d.ts +6 -2
  92. package/dist/src/plugins/container/runtimePlugin.js +167 -0
  93. package/dist/src/plugins/container/runtimePlugin.js.map +1 -1
  94. package/dist/src/plugins/container/runtimePlugin.mjs +166 -0
  95. package/dist/src/plugins/container/runtimePlugin.mjs.map +1 -0
  96. package/dist/utils/flushedChunks.d.mts +29 -0
  97. package/dist/utils/flushedChunks.d.ts +12 -5
  98. package/dist/utils/flushedChunks.js +32 -72
  99. package/dist/utils/flushedChunks.js.map +1 -1
  100. package/dist/utils/flushedChunks.mjs +35 -0
  101. package/dist/utils/flushedChunks.mjs.map +1 -0
  102. package/dist/utils/index.d.mts +14 -0
  103. package/dist/utils/index.d.ts +8 -14
  104. package/dist/utils/index.js +27 -62
  105. package/dist/utils/index.js.map +1 -1
  106. package/dist/utils/index.mjs +22 -0
  107. package/dist/utils/index.mjs.map +1 -0
  108. package/package.json +29 -9
  109. package/dist/client/UrlNode.d.ts +0 -17
  110. package/dist/node.d.ts +0 -1
  111. package/dist/node.js +0 -18
  112. package/dist/node.js.map +0 -1
  113. package/dist/package.json +0 -80
  114. package/dist/src/federation-noop.cjs +0 -15
  115. package/dist/src/internal.d.ts +0 -50
  116. package/dist/src/loaders/helpers.d.ts +0 -17
  117. package/dist/src/logger.d.ts +0 -2
  118. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +0 -5
  119. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +0 -19
  120. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +0 -1
  121. package/dist/src/plugins/CopyFederationPlugin.d.ts +0 -20
  122. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +0 -23
  123. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +0 -36
  124. package/dist/src/plugins/NextFederationPlugin/regex-equal.d.ts +0 -14
  125. package/dist/src/plugins/NextFederationPlugin/regex-equal.js +0 -25
  126. package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +0 -1
  127. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +0 -8
  128. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +0 -34
  129. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +0 -1
  130. package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +0 -16
  131. package/dist/src/plugins/NextFederationPlugin/validate-options.d.ts +0 -25
  132. package/dist/src/plugins/container/InvertedContainerPlugin.d.ts +0 -5
  133. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +0 -11
  134. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +0 -39
  135. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -78
  136. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
  137. package/dist/src/plugins/container/runtimePlugin.cjs +0 -219
  138. package/dist/src/plugins/container/types.d.ts +0 -2
  139. package/dist/src/plugins/container/types.js +0 -3
  140. package/dist/src/plugins/container/types.js.map +0 -1
  141. package/dist/src/types.d.ts +0 -28
  142. package/dist/src/types.js +0 -3
  143. package/dist/src/types.js.map +0 -1
@@ -1,134 +1,82 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectRuleLoader = injectRuleLoader;
4
- exports.hasLoader = hasLoader;
5
- exports.findLoaderForResource = findLoaderForResource;
1
+
2
+ //#region src/loaders/helpers.ts
6
3
  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
- }
4
+ if (rule !== "...") {
5
+ const _rule = rule;
6
+ if (_rule.loader) {
7
+ _rule.use = [loader, {
8
+ loader: _rule.loader,
9
+ options: _rule.options
10
+ }];
11
+ delete _rule.loader;
12
+ delete _rule.options;
13
+ } else if (_rule.use) _rule.use = [loader, ..._rule.use];
14
+ }
18
15
  }
19
16
  /**
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
- */
17
+ * This function checks if the current module rule has a loader with the provided name.
18
+ *
19
+ * @param {RuleSetRule} rule - The current module rule.
20
+ * @param {string} loaderName - The name of the loader to check.
21
+ * @returns {boolean} Returns true if the current module rule has a loader with the provided name, otherwise false.
22
+ */
26
23
  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;
24
+ if (rule !== "...") {
25
+ const _rule = rule;
26
+ if (_rule.loader === loaderName) return true;
27
+ else if (_rule.use && Array.isArray(_rule.use)) for (let i = 0; i < _rule.use.length; i++) {
28
+ const loader = _rule.use[i];
29
+ if (typeof loader !== "string" && typeof loader !== "function" && loader.loader && (loader.loader === loaderName || loader.loader.includes(`/${loaderName}/`))) return true;
30
+ else if (typeof loader === "string") {
31
+ if (loader === loaderName || loader.includes(`/${loaderName}/`)) return true;
32
+ }
33
+ }
34
+ }
35
+ return false;
52
36
  }
53
37
  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;
38
+ if (condition instanceof RegExp) return condition.test(resource.path);
39
+ else if (typeof condition === "string") return resource.path.includes(condition);
40
+ else if (typeof condition === "function") return condition(resource.path);
41
+ else if (typeof condition === "object") {
42
+ if ("test" in condition && condition.test) {
43
+ if (!(Array.isArray(condition.test) ? condition.test : [condition.test]).some((test) => matchesCondition(test, resource, currentPath))) return false;
44
+ }
45
+ if ("include" in condition && condition.include) {
46
+ if (!(Array.isArray(condition.include) ? condition.include : [condition.include]).some((include) => matchesCondition(include, resource, currentPath))) return false;
47
+ }
48
+ if ("exclude" in condition && condition.exclude) {
49
+ if ((Array.isArray(condition.exclude) ? condition.exclude : [condition.exclude]).some((exclude) => matchesCondition(exclude, resource, currentPath))) return false;
50
+ }
51
+ if ("and" in condition && condition.and) return condition.and.every((cond) => matchesCondition(cond, resource, currentPath));
52
+ if ("or" in condition && condition.or) return condition.or.some((cond) => matchesCondition(cond, resource, currentPath));
53
+ if ("not" in condition && condition.not) return !matchesCondition(condition.not, resource, currentPath);
54
+ if ("layer" in condition && condition.layer) {
55
+ if (!resource.layer || !matchesCondition(condition.layer, { path: resource.layer }, currentPath)) return false;
56
+ }
57
+ if ("issuerLayer" in condition && condition.issuerLayer) {
58
+ if (!resource.issuerLayer || !matchesCondition(condition.issuerLayer, { path: resource.issuerLayer }, currentPath)) return false;
59
+ }
60
+ }
61
+ return true;
111
62
  }
112
63
  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;
64
+ let lastMatchedRule = null;
65
+ for (let i = 0; i < rules.length; i++) {
66
+ const rule = rules[i];
67
+ const currentPath = [...path, `rules[${i}]`];
68
+ if (rule.oneOf) for (let j = 0; j < rule.oneOf.length; j++) {
69
+ const subRule = rule.oneOf[j];
70
+ const subPath = [...currentPath, `oneOf[${j}]`];
71
+ if (subRule && matchesCondition(subRule, resource, subPath.join("->"))) return subRule;
72
+ }
73
+ else if (rule && matchesCondition(rule, resource, currentPath.join(" -> "))) lastMatchedRule = rule;
74
+ }
75
+ return lastMatchedRule;
133
76
  }
77
+
78
+ //#endregion
79
+ exports.findLoaderForResource = findLoaderForResource;
80
+ exports.hasLoader = hasLoader;
81
+ exports.injectRuleLoader = injectRuleLoader;
134
82
  //# sourceMappingURL=helpers.js.map
@@ -1 +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,CAAC,MAAM,EAAE,CAAC;YACjB,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC,MAAM,CAAC;YACpB,OAAO,KAAK,CAAC,OAAO,CAAC;QACvB,CAAC;aAAM,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YACrB,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,GAAI,KAAK,CAAC,GAAa,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,IAAiB,EAAE,UAAkB;IAC7D,YAAY;IACZ,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,IAIb,CAAC;QACF,IAAI,KAAK,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACjD,KA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AEnB,IAAI,eAAe,GAAuB,IAAI,CAAC;IAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,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"}
1
+ {"version":3,"file":"helpers.js","names":[],"sources":["../../../src/loaders/helpers.ts"],"sourcesContent":["import type {\n RuleSetRule,\n RuleSetCondition,\n RuleSetConditionAbsolute,\n RuleSetUseItem,\n} from 'webpack';\n\nexport function injectRuleLoader(rule: any, loader: RuleSetUseItem = {}) {\n if (rule !== '...') {\n const _rule = rule as {\n loader?: string;\n use?: (RuleSetUseItem | string)[];\n options?: any;\n };\n if (_rule.loader) {\n _rule.use = [loader, { loader: _rule.loader, options: _rule.options }];\n delete _rule.loader;\n delete _rule.options;\n } else if (_rule.use) {\n _rule.use = [loader, ...(_rule.use as any[])];\n }\n }\n}\n\n/**\n * This function checks if the current module rule has a loader with the provided name.\n *\n * @param {RuleSetRule} rule - The current module rule.\n * @param {string} loaderName - The name of the loader to check.\n * @returns {boolean} Returns true if the current module rule has a loader with the provided name, otherwise false.\n */\nexport function hasLoader(rule: RuleSetRule, loaderName: string) {\n //@ts-ignore\n if (rule !== '...') {\n const _rule = rule as {\n loader?: string;\n use?: (RuleSetUseItem | string)[];\n options?: any;\n };\n if (_rule.loader === loaderName) {\n return true;\n } else if (_rule.use && Array.isArray(_rule.use)) {\n for (let i = 0; i < _rule.use.length; i++) {\n const loader = _rule.use[i];\n if (\n typeof loader !== 'string' &&\n typeof loader !== 'function' &&\n loader.loader &&\n (loader.loader === loaderName ||\n loader.loader.includes(`/${loaderName}/`))\n ) {\n return true;\n } else if (typeof loader === 'string') {\n if (loader === loaderName || loader.includes(`/${loaderName}/`)) {\n return true;\n }\n }\n }\n }\n }\n return false;\n}\n\ninterface Resource {\n path: string;\n layer?: string;\n issuerLayer?: string;\n}\n\nfunction matchesCondition(\n condition:\n | RuleSetCondition\n | RuleSetConditionAbsolute\n | RuleSetRule\n | undefined,\n resource: Resource,\n currentPath: string,\n): boolean {\n if (condition instanceof RegExp) {\n return condition.test(resource.path);\n } else if (typeof condition === 'string') {\n return resource.path.includes(condition);\n } else if (typeof condition === 'function') {\n return condition(resource.path);\n } else if (typeof condition === 'object') {\n if ('test' in condition && condition.test) {\n const tests = Array.isArray(condition.test)\n ? condition.test\n : [condition.test];\n if (\n !tests.some((test: RuleSetCondition) =>\n matchesCondition(test, resource, currentPath),\n )\n ) {\n return false;\n }\n }\n if ('include' in condition && condition.include) {\n const includes = Array.isArray(condition.include)\n ? condition.include\n : [condition.include];\n if (\n !includes.some((include: RuleSetCondition) =>\n matchesCondition(include, resource, currentPath),\n )\n ) {\n return false;\n }\n }\n if ('exclude' in condition && condition.exclude) {\n const excludes = Array.isArray(condition.exclude)\n ? condition.exclude\n : [condition.exclude];\n if (\n excludes.some((exclude: RuleSetCondition) =>\n matchesCondition(exclude, resource, currentPath),\n )\n ) {\n return false;\n }\n }\n if ('and' in condition && condition.and) {\n return condition.and.every((cond: RuleSetCondition) =>\n matchesCondition(cond, resource, currentPath),\n );\n }\n if ('or' in condition && condition.or) {\n return condition.or.some((cond: RuleSetCondition) =>\n matchesCondition(cond, resource, currentPath),\n );\n }\n if ('not' in condition && condition.not) {\n return !matchesCondition(condition.not, resource, currentPath);\n }\n if ('layer' in condition && condition.layer) {\n if (\n !resource.layer ||\n !matchesCondition(\n condition.layer,\n { path: resource.layer },\n currentPath,\n )\n ) {\n return false;\n }\n }\n if ('issuerLayer' in condition && condition.issuerLayer) {\n if (\n !resource.issuerLayer ||\n !matchesCondition(\n condition.issuerLayer,\n { path: resource.issuerLayer },\n currentPath,\n )\n ) {\n return false;\n }\n }\n }\n return true;\n}\n\nexport function findLoaderForResource(\n rules: RuleSetRule[],\n resource: Resource,\n path: string[] = [],\n): RuleSetRule | null {\n let lastMatchedRule: RuleSetRule | null = null;\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i];\n const currentPath = [...path, `rules[${i}]`];\n if (rule.oneOf) {\n for (let j = 0; j < rule.oneOf.length; j++) {\n const subRule = rule.oneOf[j];\n const subPath = [...currentPath, `oneOf[${j}]`];\n\n if (\n subRule &&\n matchesCondition(subRule, resource, subPath.join('->'))\n ) {\n return subRule;\n }\n }\n } else if (\n rule &&\n matchesCondition(rule, resource, currentPath.join(' -> '))\n ) {\n lastMatchedRule = rule;\n }\n }\n return lastMatchedRule;\n}\n"],"mappings":";;AAOA,SAAgB,iBAAiB,MAAW,SAAyB,EAAE,EAAE;AACvE,KAAI,SAAS,OAAO;EAClB,MAAM,QAAQ;AAKd,MAAI,MAAM,QAAQ;AAChB,SAAM,MAAM,CAAC,QAAQ;IAAE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,79 @@
1
+ //#region src/loaders/helpers.ts
2
+ function injectRuleLoader(rule, loader = {}) {
3
+ if (rule !== "...") {
4
+ const _rule = rule;
5
+ if (_rule.loader) {
6
+ _rule.use = [loader, {
7
+ loader: _rule.loader,
8
+ options: _rule.options
9
+ }];
10
+ delete _rule.loader;
11
+ delete _rule.options;
12
+ } else if (_rule.use) _rule.use = [loader, ..._rule.use];
13
+ }
14
+ }
15
+ /**
16
+ * This function checks if the current module rule has a loader with the provided name.
17
+ *
18
+ * @param {RuleSetRule} rule - The current module rule.
19
+ * @param {string} loaderName - The name of the loader to check.
20
+ * @returns {boolean} Returns true if the current module rule has a loader with the provided name, otherwise false.
21
+ */
22
+ function hasLoader(rule, loaderName) {
23
+ if (rule !== "...") {
24
+ const _rule = rule;
25
+ if (_rule.loader === loaderName) return true;
26
+ else if (_rule.use && Array.isArray(_rule.use)) for (let i = 0; i < _rule.use.length; i++) {
27
+ const loader = _rule.use[i];
28
+ if (typeof loader !== "string" && typeof loader !== "function" && loader.loader && (loader.loader === loaderName || loader.loader.includes(`/${loaderName}/`))) return true;
29
+ else if (typeof loader === "string") {
30
+ if (loader === loaderName || loader.includes(`/${loaderName}/`)) return true;
31
+ }
32
+ }
33
+ }
34
+ return false;
35
+ }
36
+ function matchesCondition(condition, resource, currentPath) {
37
+ if (condition instanceof RegExp) return condition.test(resource.path);
38
+ else if (typeof condition === "string") return resource.path.includes(condition);
39
+ else if (typeof condition === "function") return condition(resource.path);
40
+ else if (typeof condition === "object") {
41
+ if ("test" in condition && condition.test) {
42
+ if (!(Array.isArray(condition.test) ? condition.test : [condition.test]).some((test) => matchesCondition(test, resource, currentPath))) return false;
43
+ }
44
+ if ("include" in condition && condition.include) {
45
+ if (!(Array.isArray(condition.include) ? condition.include : [condition.include]).some((include) => matchesCondition(include, resource, currentPath))) return false;
46
+ }
47
+ if ("exclude" in condition && condition.exclude) {
48
+ if ((Array.isArray(condition.exclude) ? condition.exclude : [condition.exclude]).some((exclude) => matchesCondition(exclude, resource, currentPath))) return false;
49
+ }
50
+ if ("and" in condition && condition.and) return condition.and.every((cond) => matchesCondition(cond, resource, currentPath));
51
+ if ("or" in condition && condition.or) return condition.or.some((cond) => matchesCondition(cond, resource, currentPath));
52
+ if ("not" in condition && condition.not) return !matchesCondition(condition.not, resource, currentPath);
53
+ if ("layer" in condition && condition.layer) {
54
+ if (!resource.layer || !matchesCondition(condition.layer, { path: resource.layer }, currentPath)) return false;
55
+ }
56
+ if ("issuerLayer" in condition && condition.issuerLayer) {
57
+ if (!resource.issuerLayer || !matchesCondition(condition.issuerLayer, { path: resource.issuerLayer }, currentPath)) return false;
58
+ }
59
+ }
60
+ return true;
61
+ }
62
+ function findLoaderForResource(rules, resource, path = []) {
63
+ let lastMatchedRule = null;
64
+ for (let i = 0; i < rules.length; i++) {
65
+ const rule = rules[i];
66
+ const currentPath = [...path, `rules[${i}]`];
67
+ if (rule.oneOf) for (let j = 0; j < rule.oneOf.length; j++) {
68
+ const subRule = rule.oneOf[j];
69
+ const subPath = [...currentPath, `oneOf[${j}]`];
70
+ if (subRule && matchesCondition(subRule, resource, subPath.join("->"))) return subRule;
71
+ }
72
+ else if (rule && matchesCondition(rule, resource, currentPath.join(" -> "))) lastMatchedRule = rule;
73
+ }
74
+ return lastMatchedRule;
75
+ }
76
+
77
+ //#endregion
78
+ export { findLoaderForResource, hasLoader, injectRuleLoader };
79
+ //# sourceMappingURL=helpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../../../src/loaders/helpers.ts"],"sourcesContent":["import type {\n RuleSetRule,\n RuleSetCondition,\n RuleSetConditionAbsolute,\n RuleSetUseItem,\n} from 'webpack';\n\nexport function injectRuleLoader(rule: any, loader: RuleSetUseItem = {}) {\n if (rule !== '...') {\n const _rule = rule as {\n loader?: string;\n use?: (RuleSetUseItem | string)[];\n options?: any;\n };\n if (_rule.loader) {\n _rule.use = [loader, { loader: _rule.loader, options: _rule.options }];\n delete _rule.loader;\n delete _rule.options;\n } else if (_rule.use) {\n _rule.use = [loader, ...(_rule.use as any[])];\n }\n }\n}\n\n/**\n * This function checks if the current module rule has a loader with the provided name.\n *\n * @param {RuleSetRule} rule - The current module rule.\n * @param {string} loaderName - The name of the loader to check.\n * @returns {boolean} Returns true if the current module rule has a loader with the provided name, otherwise false.\n */\nexport function hasLoader(rule: RuleSetRule, loaderName: string) {\n //@ts-ignore\n if (rule !== '...') {\n const _rule = rule as {\n loader?: string;\n use?: (RuleSetUseItem | string)[];\n options?: any;\n };\n if (_rule.loader === loaderName) {\n return true;\n } else if (_rule.use && Array.isArray(_rule.use)) {\n for (let i = 0; i < _rule.use.length; i++) {\n const loader = _rule.use[i];\n if (\n typeof loader !== 'string' &&\n typeof loader !== 'function' &&\n loader.loader &&\n (loader.loader === loaderName ||\n loader.loader.includes(`/${loaderName}/`))\n ) {\n return true;\n } else if (typeof loader === 'string') {\n if (loader === loaderName || loader.includes(`/${loaderName}/`)) {\n return true;\n }\n }\n }\n }\n }\n return false;\n}\n\ninterface Resource {\n path: string;\n layer?: string;\n issuerLayer?: string;\n}\n\nfunction matchesCondition(\n condition:\n | RuleSetCondition\n | RuleSetConditionAbsolute\n | RuleSetRule\n | undefined,\n resource: Resource,\n currentPath: string,\n): boolean {\n if (condition instanceof RegExp) {\n return condition.test(resource.path);\n } else if (typeof condition === 'string') {\n return resource.path.includes(condition);\n } else if (typeof condition === 'function') {\n return condition(resource.path);\n } else if (typeof condition === 'object') {\n if ('test' in condition && condition.test) {\n const tests = Array.isArray(condition.test)\n ? condition.test\n : [condition.test];\n if (\n !tests.some((test: RuleSetCondition) =>\n matchesCondition(test, resource, currentPath),\n )\n ) {\n return false;\n }\n }\n if ('include' in condition && condition.include) {\n const includes = Array.isArray(condition.include)\n ? condition.include\n : [condition.include];\n if (\n !includes.some((include: RuleSetCondition) =>\n matchesCondition(include, resource, currentPath),\n )\n ) {\n return false;\n }\n }\n if ('exclude' in condition && condition.exclude) {\n const excludes = Array.isArray(condition.exclude)\n ? condition.exclude\n : [condition.exclude];\n if (\n excludes.some((exclude: RuleSetCondition) =>\n matchesCondition(exclude, resource, currentPath),\n )\n ) {\n return false;\n }\n }\n if ('and' in condition && condition.and) {\n return condition.and.every((cond: RuleSetCondition) =>\n matchesCondition(cond, resource, currentPath),\n );\n }\n if ('or' in condition && condition.or) {\n return condition.or.some((cond: RuleSetCondition) =>\n matchesCondition(cond, resource, currentPath),\n );\n }\n if ('not' in condition && condition.not) {\n return !matchesCondition(condition.not, resource, currentPath);\n }\n if ('layer' in condition && condition.layer) {\n if (\n !resource.layer ||\n !matchesCondition(\n condition.layer,\n { path: resource.layer },\n currentPath,\n )\n ) {\n return false;\n }\n }\n if ('issuerLayer' in condition && condition.issuerLayer) {\n if (\n !resource.issuerLayer ||\n !matchesCondition(\n condition.issuerLayer,\n { path: resource.issuerLayer },\n currentPath,\n )\n ) {\n return false;\n }\n }\n }\n return true;\n}\n\nexport function findLoaderForResource(\n rules: RuleSetRule[],\n resource: Resource,\n path: string[] = [],\n): RuleSetRule | null {\n let lastMatchedRule: RuleSetRule | null = null;\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i];\n const currentPath = [...path, `rules[${i}]`];\n if (rule.oneOf) {\n for (let j = 0; j < rule.oneOf.length; j++) {\n const subRule = rule.oneOf[j];\n const subPath = [...currentPath, `oneOf[${j}]`];\n\n if (\n subRule &&\n matchesCondition(subRule, resource, subPath.join('->'))\n ) {\n return subRule;\n }\n }\n } else if (\n rule &&\n matchesCondition(rule, resource, currentPath.join(' -> '))\n ) {\n lastMatchedRule = rule;\n }\n }\n return lastMatchedRule;\n}\n"],"mappings":";AAOA,SAAgB,iBAAiB,MAAW,SAAyB,EAAE,EAAE;AACvE,KAAI,SAAS,OAAO;EAClB,MAAM,QAAQ;AAKd,MAAI,MAAM,QAAQ;AAChB,SAAM,MAAM,CAAC,QAAQ;IAAE,QAAQ,MAAM;IAAQ,SAAS,MAAM;IAAS,CAAC;AACtE,UAAO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MapLoader.d.ts
4
+ /**
5
+ * Webpack loader which prepares MF map for NextJS pages.
6
+ * This function is the main entry point for the loader.
7
+ * It gets the options passed to the loader and prepares the pages map.
8
+ * If the 'v2' option is passed, it prepares the pages map using the 'preparePageMapV2' function.
9
+ * Otherwise, it uses the 'preparePageMap' function.
10
+ * Finally, it calls the loader's callback function with the prepared pages map.
11
+ *
12
+ * @param {LoaderContext<Record<string, unknown>>} this - The loader context.
13
+ */
14
+ declare function nextPageMapLoader(this: LoaderContext<Record<string, unknown>>): void;
15
+ /**
16
+ * Webpack config generator for `exposes` option.
17
+ * This function generates the webpack config for the 'exposes' option.
18
+ * It creates a map of pages to modules and returns an object with the pages map and the pages map v2.
19
+ *
20
+ * @param {string} cwd - The current working directory.
21
+ * @returns {Record<string, string>} The webpack config for the 'exposes' option.
22
+ */
23
+ declare function exposeNextjsPages(cwd: string): {
24
+ './pages-map': string;
25
+ './pages-map-v2': string;
26
+ };
27
+ //#endregion
28
+ export { nextPageMapLoader as default, exposeNextjsPages };
29
+ //# sourceMappingURL=nextPageMapLoader.d.mts.map
@@ -1,4 +1,6 @@
1
- import type { LoaderContext } from 'webpack';
1
+ import { LoaderContext } from "webpack";
2
+
3
+ //#region src/loaders/nextPageMapLoader.d.ts
2
4
  /**
3
5
  * Webpack loader which prepares MF map for NextJS pages.
4
6
  * This function is the main entry point for the loader.
@@ -9,7 +11,7 @@ import type { LoaderContext } from 'webpack';
9
11
  *
10
12
  * @param {LoaderContext<Record<string, unknown>>} this - The loader context.
11
13
  */
12
- export default function nextPageMapLoader(this: LoaderContext<Record<string, unknown>>): void;
14
+ declare function nextPageMapLoader(this: LoaderContext<Record<string, unknown>>): void;
13
15
  /**
14
16
  * Webpack config generator for `exposes` option.
15
17
  * This function generates the webpack config for the 'exposes' option.
@@ -18,7 +20,10 @@ export default function nextPageMapLoader(this: LoaderContext<Record<string, unk
18
20
  * @param {string} cwd - The current working directory.
19
21
  * @returns {Record<string, string>} The webpack config for the 'exposes' option.
20
22
  */
21
- export declare function exposeNextjsPages(cwd: string): {
22
- './pages-map': string;
23
- './pages-map-v2': string;
23
+ declare function exposeNextjsPages(cwd: string): {
24
+ './pages-map': string;
25
+ './pages-map-v2': string;
24
26
  };
27
+ //#endregion
28
+ export { nextPageMapLoader as default, exposeNextjsPages };
29
+ //# sourceMappingURL=nextPageMapLoader.d.ts.map