@module-federation/data-prefetch 0.0.0-fix-lazy-comile-20250925082726

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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/LICENSE +21 -0
  4. package/dist/babel.cjs.cjs +46 -0
  5. package/dist/babel.cjs.cjs.map +1 -0
  6. package/dist/babel.cjs.d.ts +2 -0
  7. package/dist/babel.d.ts +2 -0
  8. package/dist/babel.esm.js +44 -0
  9. package/dist/babel.esm.js.map +1 -0
  10. package/dist/cli.cjs.cjs +154 -0
  11. package/dist/cli.cjs.cjs.map +1 -0
  12. package/dist/cli.cjs.d.ts +1 -0
  13. package/dist/cli.d.ts +1 -0
  14. package/dist/cli.esm.js +151 -0
  15. package/dist/cli.esm.js.map +1 -0
  16. package/dist/constant.cjs.cjs +6 -0
  17. package/dist/constant.cjs.cjs.map +1 -0
  18. package/dist/constant.esm.js +4 -0
  19. package/dist/constant.esm.js.map +1 -0
  20. package/dist/index.cjs.cjs +10 -0
  21. package/dist/index.cjs.cjs.map +1 -0
  22. package/dist/index.cjs.d.ts +1 -0
  23. package/dist/index.cjs2.cjs +8 -0
  24. package/dist/index.cjs2.cjs.map +1 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.esm.js +3 -0
  27. package/dist/index.esm.js.map +1 -0
  28. package/dist/index.esm2.js +6 -0
  29. package/dist/index.esm2.js.map +1 -0
  30. package/dist/plugin.cjs.cjs +155 -0
  31. package/dist/plugin.cjs.cjs.map +1 -0
  32. package/dist/plugin.cjs.d.ts +2 -0
  33. package/dist/plugin.d.ts +2 -0
  34. package/dist/plugin.esm.js +150 -0
  35. package/dist/plugin.esm.js.map +1 -0
  36. package/dist/prefetch.cjs.cjs +194 -0
  37. package/dist/prefetch.cjs.cjs.map +1 -0
  38. package/dist/prefetch.esm.js +191 -0
  39. package/dist/prefetch.esm.js.map +1 -0
  40. package/dist/react.cjs.cjs +75 -0
  41. package/dist/react.cjs.cjs.map +1 -0
  42. package/dist/react.cjs.d.ts +1 -0
  43. package/dist/react.d.ts +1 -0
  44. package/dist/react.esm.js +73 -0
  45. package/dist/react.esm.js.map +1 -0
  46. package/dist/runtime-utils.cjs.cjs +28 -0
  47. package/dist/runtime-utils.cjs.cjs.map +1 -0
  48. package/dist/runtime-utils.esm.js +23 -0
  49. package/dist/runtime-utils.esm.js.map +1 -0
  50. package/dist/src/cli/babel.d.ts +37 -0
  51. package/dist/src/cli/index.d.ts +16 -0
  52. package/dist/src/common/constant.d.ts +1 -0
  53. package/dist/src/common/index.d.ts +1 -0
  54. package/dist/src/common/node-utils.d.ts +2 -0
  55. package/dist/src/common/runtime-utils.d.ts +5 -0
  56. package/dist/src/constant.d.ts +1 -0
  57. package/dist/src/index.d.ts +2 -0
  58. package/dist/src/logger/index.d.ts +2 -0
  59. package/dist/src/plugin.d.ts +3 -0
  60. package/dist/src/prefetch.d.ts +42 -0
  61. package/dist/src/react/hooks.d.ts +11 -0
  62. package/dist/src/react/index.d.ts +1 -0
  63. package/dist/src/react/utils.d.ts +1 -0
  64. package/dist/src/universal/index.d.ts +2 -0
  65. package/dist/universal.cjs.cjs +28 -0
  66. package/dist/universal.cjs.cjs.map +1 -0
  67. package/dist/universal.cjs.d.ts +1 -0
  68. package/dist/universal.d.ts +1 -0
  69. package/dist/universal.esm.js +26 -0
  70. package/dist/universal.esm.js.map +1 -0
  71. package/package.json +98 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present nieyan(nyqykk)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @module-federation/data-prefetch
2
+
3
+ See [documentation](https://module-federation.io/zh/guide/performance/prefetch.html) for more details .
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present nieyan(nyqykk)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+
5
+ const attribute = 'id';
6
+ const hookId = 'usePrefetch';
7
+ const importPackage = '@module-federation/data-prefetch/react';
8
+ var babel = ((babel, options)=>{
9
+ const t = babel.types;
10
+ let shouldHandle = false;
11
+ let scope = '';
12
+ const { name, exposes } = options;
13
+ if (!exposes) {
14
+ return {};
15
+ }
16
+ const exposesKey = Object.keys(exposes);
17
+ const processedExposes = exposesKey.map((expose)=>({
18
+ key: expose.replace('.', ''),
19
+ value: path.resolve(typeof exposes[expose] === 'string' ? exposes[expose] : exposes[expose].import)
20
+ }));
21
+ return {
22
+ visitor: {
23
+ ImportDeclaration (nodePath, state) {
24
+ const source = nodePath.node.source.value;
25
+ const { specifiers } = nodePath.node;
26
+ const { filename } = state.file.opts;
27
+ if (source === importPackage) {
28
+ shouldHandle = specifiers.some((specifier)=>specifier.imported && specifier.imported.name === hookId && processedExposes.find((expose)=>expose.value === filename && (scope = expose.key)));
29
+ }
30
+ },
31
+ CallExpression (nodePath) {
32
+ if (shouldHandle && t.isIdentifier(nodePath.node.callee, {
33
+ name: hookId
34
+ }) && nodePath.node.arguments.length > 0) {
35
+ const objectExpression = nodePath.node.arguments[0];
36
+ if (objectExpression && t.isObjectExpression(objectExpression) && !objectExpression.properties.find((p)=>p.key.name === attribute)) {
37
+ objectExpression.properties.push(t.objectProperty(t.identifier(attribute), t.stringLiteral(name + scope)));
38
+ }
39
+ }
40
+ }
41
+ }
42
+ };
43
+ });
44
+
45
+ module.exports = babel;
46
+ //# sourceMappingURL=babel.cjs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel.cjs.cjs","sources":["../src/cli/babel.ts"],"sourcesContent":["import path from 'path';\nconst attribute = 'id';\nconst hookId = 'usePrefetch';\nconst importPackage = '@module-federation/data-prefetch/react';\nexport default (babel, options) => {\n const t = babel.types;\n let shouldHandle = false;\n let scope = '';\n const { name, exposes } = options;\n if (!exposes) {\n return {};\n }\n const exposesKey = Object.keys(exposes);\n const processedExposes = exposesKey.map((expose) => ({\n key: expose.replace('.', ''),\n value: path.resolve(typeof exposes[expose] === 'string'\n ?\n exposes[expose]\n :\n exposes[expose].import),\n }));\n return {\n visitor: {\n ImportDeclaration(nodePath, state) {\n const source = nodePath.node.source.value;\n const { specifiers } = nodePath.node;\n const { filename } = state.file.opts;\n if (source === importPackage) {\n shouldHandle = specifiers.some((specifier) => specifier.imported &&\n specifier.imported.name === hookId &&\n processedExposes.find((expose) => expose.value === filename && (scope = expose.key)));\n }\n },\n CallExpression(nodePath) {\n if (shouldHandle &&\n t.isIdentifier(nodePath.node.callee, { name: hookId }) &&\n nodePath.node.arguments.length > 0) {\n const objectExpression = nodePath.node.arguments[0];\n if (objectExpression &&\n t.isObjectExpression(objectExpression) &&\n !objectExpression.properties.find((p) => p.key.name === attribute)) {\n objectExpression.properties.push(t.objectProperty(t.identifier(attribute), t.stringLiteral(name + scope)));\n }\n }\n },\n },\n };\n};\n"],"names":["attribute","hookId","importPackage","babel","options","t","types","shouldHandle","scope","name","exposes","exposesKey","Object","keys","processedExposes","map","expose","key","replace","value","path","resolve","import","visitor","ImportDeclaration","nodePath","state","source","node","specifiers","filename","file","opts","some","specifier","imported","find","CallExpression","isIdentifier","callee","arguments","length","objectExpression","isObjectExpression","properties","p","push","objectProperty","identifier","stringLiteral"],"mappings":";;;;AACA,MAAMA,SAAY,GAAA,IAAA;AAClB,MAAMC,MAAS,GAAA,aAAA;AACf,MAAMC,aAAgB,GAAA,wCAAA;AACtB,YAAe,CAAA,CAACC,KAAOC,EAAAA,OAAAA,GAAAA;IACnB,MAAMC,CAAAA,GAAIF,MAAMG,KAAK;AACrB,IAAA,IAAIC,YAAe,GAAA,KAAA;AACnB,IAAA,IAAIC,KAAQ,GAAA,EAAA;AACZ,IAAA,MAAM,EAAEC,IAAI,EAAEC,OAAO,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C,YAAY,CAACb,SAASG,IAAI,CAACW,MAAM,EAAE;oBAAE9B,IAAMR,EAAAA;AAAO,iBAAA,CAAA,IACpDwB,SAASG,IAAI,CAACY,SAAS,CAACC,MAAM,GAAG,CAAG,EAAA;AACpC,oBAAA,MAAMC,mBAAmBjB,QAASG,CAAAA,IAAI,CAACY,SAAS,CAAC,CAAE,CAAA;AACnD,oBAAA,IAAIE,oBACArC,CAAEsC,CAAAA,kBAAkB,CAACD,gBACrB,CAAA,IAAA,CAACA,iBAAiBE,UAAU,CAACR,IAAI,CAAC,CAACS,CAAMA,GAAAA,CAAAA,CAAE5B,GAAG,CAACR,IAAI,KAAKT,SAAY,CAAA,EAAA;AACpE0C,wBAAAA,gBAAAA,CAAiBE,UAAU,CAACE,IAAI,CAACzC,EAAE0C,cAAc,CAAC1C,CAAE2C,CAAAA,UAAU,CAAChD,SAAAA,CAAAA,EAAYK,CAAE4C,CAAAA,aAAa,CAACxC,IAAOD,GAAAA,KAAAA,CAAAA,CAAAA,CAAAA;AACtG;AACJ;AACJ;AACJ;AACJ,KAAA;AACJ,CAAA;;;;"}
@@ -0,0 +1,2 @@
1
+ export * from "./src/cli/babel";
2
+ export { default } from "./src/cli/babel";
@@ -0,0 +1,2 @@
1
+ export * from "./src/cli/babel";
2
+ export { default } from "./src/cli/babel";
@@ -0,0 +1,44 @@
1
+ import path from 'path';
2
+
3
+ const attribute = 'id';
4
+ const hookId = 'usePrefetch';
5
+ const importPackage = '@module-federation/data-prefetch/react';
6
+ var babel = ((babel, options)=>{
7
+ const t = babel.types;
8
+ let shouldHandle = false;
9
+ let scope = '';
10
+ const { name, exposes } = options;
11
+ if (!exposes) {
12
+ return {};
13
+ }
14
+ const exposesKey = Object.keys(exposes);
15
+ const processedExposes = exposesKey.map((expose)=>({
16
+ key: expose.replace('.', ''),
17
+ value: path.resolve(typeof exposes[expose] === 'string' ? exposes[expose] : exposes[expose].import)
18
+ }));
19
+ return {
20
+ visitor: {
21
+ ImportDeclaration (nodePath, state) {
22
+ const source = nodePath.node.source.value;
23
+ const { specifiers } = nodePath.node;
24
+ const { filename } = state.file.opts;
25
+ if (source === importPackage) {
26
+ shouldHandle = specifiers.some((specifier)=>specifier.imported && specifier.imported.name === hookId && processedExposes.find((expose)=>expose.value === filename && (scope = expose.key)));
27
+ }
28
+ },
29
+ CallExpression (nodePath) {
30
+ if (shouldHandle && t.isIdentifier(nodePath.node.callee, {
31
+ name: hookId
32
+ }) && nodePath.node.arguments.length > 0) {
33
+ const objectExpression = nodePath.node.arguments[0];
34
+ if (objectExpression && t.isObjectExpression(objectExpression) && !objectExpression.properties.find((p)=>p.key.name === attribute)) {
35
+ objectExpression.properties.push(t.objectProperty(t.identifier(attribute), t.stringLiteral(name + scope)));
36
+ }
37
+ }
38
+ }
39
+ }
40
+ };
41
+ });
42
+
43
+ export { babel as default };
44
+ //# sourceMappingURL=babel.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel.esm.js","sources":["../src/cli/babel.ts"],"sourcesContent":["import path from 'path';\nconst attribute = 'id';\nconst hookId = 'usePrefetch';\nconst importPackage = '@module-federation/data-prefetch/react';\nexport default (babel, options) => {\n const t = babel.types;\n let shouldHandle = false;\n let scope = '';\n const { name, exposes } = options;\n if (!exposes) {\n return {};\n }\n const exposesKey = Object.keys(exposes);\n const processedExposes = exposesKey.map((expose) => ({\n key: expose.replace('.', ''),\n value: path.resolve(typeof exposes[expose] === 'string'\n ?\n exposes[expose]\n :\n exposes[expose].import),\n }));\n return {\n visitor: {\n ImportDeclaration(nodePath, state) {\n const source = nodePath.node.source.value;\n const { specifiers } = nodePath.node;\n const { filename } = state.file.opts;\n if (source === importPackage) {\n shouldHandle = specifiers.some((specifier) => specifier.imported &&\n specifier.imported.name === hookId &&\n processedExposes.find((expose) => expose.value === filename && (scope = expose.key)));\n }\n },\n CallExpression(nodePath) {\n if (shouldHandle &&\n t.isIdentifier(nodePath.node.callee, { name: hookId }) &&\n nodePath.node.arguments.length > 0) {\n const objectExpression = nodePath.node.arguments[0];\n if (objectExpression &&\n t.isObjectExpression(objectExpression) &&\n !objectExpression.properties.find((p) => p.key.name === attribute)) {\n objectExpression.properties.push(t.objectProperty(t.identifier(attribute), t.stringLiteral(name + scope)));\n }\n }\n },\n },\n };\n};\n"],"names":["attribute","hookId","importPackage","babel","options","t","types","shouldHandle","scope","name","exposes","exposesKey","Object","keys","processedExposes","map","expose","key","replace","value","path","resolve","import","visitor","ImportDeclaration","nodePath","state","source","node","specifiers","filename","file","opts","some","specifier","imported","find","CallExpression","isIdentifier","callee","arguments","length","objectExpression","isObjectExpression","properties","p","push","objectProperty","identifier","stringLiteral"],"mappings":";;AACA,MAAMA,SAAY,GAAA,IAAA;AAClB,MAAMC,MAAS,GAAA,aAAA;AACf,MAAMC,aAAgB,GAAA,wCAAA;AACtB,YAAe,CAAA,CAACC,KAAOC,EAAAA,OAAAA,GAAAA;IACnB,MAAMC,CAAAA,GAAIF,MAAMG,KAAK;AACrB,IAAA,IAAIC,YAAe,GAAA,KAAA;AACnB,IAAA,IAAIC,KAAQ,GAAA,EAAA;AACZ,IAAA,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGN,OAAAA;AAC1B,IAAA,IAAI,CAACM,OAAS,EAAA;AACV,QAAA,OAAO,EAAC;AACZ;IACA,MAAMC,UAAAA,GAAaC,MAAOC,CAAAA,IAAI,CAACH,OAAAA,CAAAA;AAC/B,IAAA,MAAMI,mBAAmBH,UAAWI,CAAAA,GAAG,CAAC,CAACC,UAAY;YACjDC,GAAKD,EAAAA,MAAAA,CAAOE,OAAO,CAAC,GAAK,EAAA,EAAA,CAAA;AACzBC,YAAAA,KAAAA,EAAOC,KAAKC,OAAO,CAAC,OAAOX,OAAO,CAACM,MAAO,CAAA,KAAK,QAEvCN,GAAAA,OAAO,CAACM,MAAO,CAAA,GAEfN,OAAO,CAACM,MAAAA,CAAO,CAACM,MAAM;SAClC,CAAA,CAAA;IACA,OAAO;QACHC,OAAS,EAAA;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AE2C,CAAAA,UAAU,CAAChD,SAAAA,CAAAA,EAAYK,CAAE4C,CAAAA,aAAa,CAACxC,IAAOD,GAAAA,KAAAA,CAAAA,CAAAA,CAAAA;AACtG;AACJ;AACJ;AACJ;AACJ,KAAA;AACJ,CAAA;;;;"}
@@ -0,0 +1,154 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+ var fs = require('fs-extra');
5
+ var sdk = require('@module-federation/sdk');
6
+ var normalizeWebpackPath = require('@module-federation/sdk/normalize-webpack-path');
7
+ var runtimeUtils = require('./runtime-utils.cjs.cjs');
8
+ var constant = require('./constant.cjs.cjs');
9
+
10
+ const TEMP_DIR = '.mf';
11
+
12
+ const fileExistsWithCaseSync = (filepath)=>{
13
+ const dir = path.dirname(filepath);
14
+ if (filepath === '/' || filepath === '.') {
15
+ return true;
16
+ }
17
+ const filenames = fs.readdirSync(dir);
18
+ if (filenames.indexOf(path.basename(filepath)) === -1) {
19
+ return false;
20
+ }
21
+ return fileExistsWithCaseSync(dir);
22
+ };
23
+ const fixPrefetchPath = (exposePath)=>{
24
+ const pathExt = [
25
+ '.js',
26
+ '.ts'
27
+ ];
28
+ const extReg = /\.(ts|js|tsx|jsx)$/;
29
+ if (extReg.test(exposePath)) {
30
+ return pathExt.map((ext)=>exposePath.replace(extReg, `.prefetch${ext}`));
31
+ } else {
32
+ return pathExt.map((ext)=>exposePath + `.prefetch${ext}`);
33
+ }
34
+ };
35
+
36
+ const { RuntimeGlobals, Template } = require(normalizeWebpackPath.normalizeWebpackPath('webpack'));
37
+ function getFederationGlobalScope(runtimeGlobals) {
38
+ return `${runtimeGlobals.require || '__webpack_require__'}.federation`;
39
+ }
40
+ class PrefetchPlugin {
41
+ apply(compiler) {
42
+ var _a;
43
+ const { name, exposes } = this.options;
44
+ if (!exposes) {
45
+ return;
46
+ }
47
+ if (!compiler.options.context) {
48
+ throw new Error('compiler.options.context is not defined');
49
+ }
50
+ const { runtimePlugins } = this.options;
51
+ if (!Array.isArray(runtimePlugins)) {
52
+ this.options.runtimePlugins = [];
53
+ }
54
+ const runtimePath = path.resolve(__dirname, './plugin.esm.js');
55
+ if (!((_a = this.options.runtimePlugins) === null || _a === void 0 ? void 0 : _a.includes(runtimePath))) {
56
+ this.options.runtimePlugins.push(runtimePath);
57
+ }
58
+ if (this.options.shareStrategy !== constant.SHARED_STRATEGY) {
59
+ this.options.shareStrategy = constant.SHARED_STRATEGY;
60
+ console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to '${constant.SHARED_STRATEGY}', this is a necessary condition for data prefetch`);
61
+ }
62
+ const encodedName = sdk.encodeName(name);
63
+ const asyncEntryPath = path.resolve(compiler.options.context, `node_modules/${TEMP_DIR}/${encodedName}/bootstrap.js`);
64
+ if (fs.existsSync(asyncEntryPath)) {
65
+ fs.unlinkSync(asyncEntryPath);
66
+ }
67
+ if (!this.options.dataPrefetch) {
68
+ return;
69
+ }
70
+ const exposeAlias = Object.keys(exposes);
71
+ exposeAlias.forEach((alias)=>{
72
+ let exposePath;
73
+ const exposeValue = exposes[alias];
74
+ if (typeof exposeValue === 'string') {
75
+ exposePath = exposeValue;
76
+ } else {
77
+ exposePath = exposeValue.import[0];
78
+ }
79
+ const targetPaths = fixPrefetchPath(exposePath);
80
+ for (const pathItem of targetPaths){
81
+ const absolutePath = path.resolve(compiler.options.context, pathItem);
82
+ if (fileExistsWithCaseSync(absolutePath)) {
83
+ const absoluteAlias = alias.replace('.', '');
84
+ this._reWriteExports += `export * as ${runtimeUtils.getPrefetchId(`${name}${absoluteAlias}`)} from '${absolutePath}';\n`;
85
+ break;
86
+ }
87
+ }
88
+ });
89
+ if (!this._reWriteExports) {
90
+ return;
91
+ }
92
+ const tempDirRealPath = path.resolve(compiler.options.context, 'node_modules', TEMP_DIR);
93
+ if (!fs.existsSync(tempDirRealPath)) {
94
+ fs.mkdirSync(tempDirRealPath);
95
+ }
96
+ if (!fs.existsSync(`${tempDirRealPath}/${encodedName}`)) {
97
+ fs.mkdirSync(`${tempDirRealPath}/${encodedName}`);
98
+ }
99
+ fs.writeFileSync(asyncEntryPath, this._reWriteExports);
100
+ new compiler.webpack.DefinePlugin({
101
+ FederationDataPrefetch: JSON.stringify(asyncEntryPath)
102
+ }).apply(compiler);
103
+ }
104
+ static addRuntime(compiler, options) {
105
+ const encodedName = sdk.encodeName(options.name);
106
+ if (!compiler.options.context) {
107
+ throw new Error('compiler.options.context is not defined');
108
+ }
109
+ const prefetchEntry = path.resolve(compiler.options.context, `node_modules/.mf/${encodedName}/bootstrap.js`);
110
+ const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
111
+ return Template.asString([
112
+ fs.existsSync(prefetchEntry) ? Template.indent([
113
+ 'function injectPrefetch() {',
114
+ Template.indent([
115
+ `globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
116
+ `globalThis.__FEDERATION__['${sdk.MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${sdk.MFPrefetchCommon.globalKey}'] || {`,
117
+ `entryLoading: {},`,
118
+ `instance: new Map(),`,
119
+ `__PREFETCH_EXPORTS__: {},`,
120
+ `};`,
121
+ `globalThis.__FEDERATION__['${sdk.MFPrefetchCommon.globalKey}']['${sdk.MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${sdk.MFPrefetchCommon.globalKey}']['${sdk.MFPrefetchCommon.exportsKey}'] || {};`,
122
+ `globalThis.__FEDERATION__['${sdk.MFPrefetchCommon.globalKey}']['${sdk.MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`
123
+ ]),
124
+ '}',
125
+ `${federationGlobal}.prefetch = injectPrefetch`
126
+ ]) : '',
127
+ Template.indent([
128
+ `if(!${federationGlobal}.isMFRemote && ${federationGlobal}.prefetch){`,
129
+ `${federationGlobal}.prefetch()`,
130
+ '}'
131
+ ])
132
+ ]);
133
+ }
134
+ static setRemoteIdentifier() {
135
+ const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
136
+ return Template.indent([
137
+ `${federationGlobal}.isMFRemote = true;`
138
+ ]);
139
+ }
140
+ static removeRemoteIdentifier() {
141
+ const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
142
+ return Template.indent([
143
+ `${federationGlobal}.isMFRemote = false;`
144
+ ]);
145
+ }
146
+ constructor(options){
147
+ this.options = options;
148
+ this._reWriteExports = '';
149
+ }
150
+ }
151
+
152
+ exports.PrefetchPlugin = PrefetchPlugin;
153
+ exports.getFederationGlobalScope = getFederationGlobalScope;
154
+ //# sourceMappingURL=cli.cjs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.cjs.cjs","sources":["../src/common/constant.ts","../src/common/node-utils.ts","../src/cli/index.ts"],"sourcesContent":["export const TEMP_DIR = '.mf';\n","import path from 'path';\nimport fs from 'fs-extra';\nexport const fileExistsWithCaseSync = (filepath) => {\n const dir = path.dirname(filepath);\n if (filepath === '/' || filepath === '.') {\n return true;\n }\n const filenames = fs.readdirSync(dir);\n if (filenames.indexOf(path.basename(filepath)) === -1) {\n return false;\n }\n return fileExistsWithCaseSync(dir);\n};\nexport const fixPrefetchPath = (exposePath) => {\n const pathExt = ['.js', '.ts'];\n const extReg = /\\.(ts|js|tsx|jsx)$/;\n if (extReg.test(exposePath)) {\n return pathExt.map((ext) => exposePath.replace(extReg, `.prefetch${ext}`));\n }\n else {\n return pathExt.map((ext) => exposePath + `.prefetch${ext}`);\n }\n};\n","import path from 'path';\nimport fs from 'fs-extra';\nimport { encodeName, MFPrefetchCommon, } from '@module-federation/sdk';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport { TEMP_DIR } from '../common/constant';\nimport { fileExistsWithCaseSync, fixPrefetchPath } from '../common/node-utils';\nimport { getPrefetchId } from '../common/runtime-utils';\nimport { SHARED_STRATEGY } from '../constant';\nconst { RuntimeGlobals, Template } = require(normalizeWebpackPath('webpack'));\nexport function getFederationGlobalScope(runtimeGlobals) {\n return `${runtimeGlobals.require || '__webpack_require__'}.federation`;\n}\nexport class PrefetchPlugin {\n constructor(options) {\n this.options = options;\n this._reWriteExports = '';\n }\n apply(compiler) {\n var _a;\n const { name, exposes } = this.options;\n if (!exposes) {\n return;\n }\n if (!compiler.options.context) {\n throw new Error('compiler.options.context is not defined');\n }\n const { runtimePlugins } = this.options;\n if (!Array.isArray(runtimePlugins)) {\n this.options.runtimePlugins = [];\n }\n const runtimePath = path.resolve(__dirname, './plugin.esm.js');\n if (!((_a = this.options.runtimePlugins) === null || _a === void 0 ? void 0 : _a.includes(runtimePath))) {\n this.options.runtimePlugins.push(runtimePath);\n }\n if (this.options.shareStrategy !== SHARED_STRATEGY) {\n this.options.shareStrategy = SHARED_STRATEGY;\n console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to '${SHARED_STRATEGY}', this is a necessary condition for data prefetch`);\n }\n const encodedName = encodeName(name);\n const asyncEntryPath = path.resolve(compiler.options.context, `node_modules/${TEMP_DIR}/${encodedName}/bootstrap.js`);\n if (fs.existsSync(asyncEntryPath)) {\n fs.unlinkSync(asyncEntryPath);\n }\n if (!this.options.dataPrefetch) {\n return;\n }\n const prefetchs = [];\n const exposeAlias = Object.keys(exposes);\n exposeAlias.forEach((alias) => {\n let exposePath;\n const exposeValue = exposes[alias];\n if (typeof exposeValue === 'string') {\n exposePath = exposeValue;\n }\n else {\n exposePath = exposeValue.import[0];\n }\n const targetPaths = fixPrefetchPath(exposePath);\n for (const pathItem of targetPaths) {\n const absolutePath = path.resolve(compiler.options.context, pathItem);\n if (fileExistsWithCaseSync(absolutePath)) {\n prefetchs.push(pathItem);\n const absoluteAlias = alias.replace('.', '');\n this._reWriteExports += `export * as ${getPrefetchId(`${name}${absoluteAlias}`)} from '${absolutePath}';\\n`;\n break;\n }\n }\n });\n if (!this._reWriteExports) {\n return;\n }\n const tempDirRealPath = path.resolve(compiler.options.context, 'node_modules', TEMP_DIR);\n if (!fs.existsSync(tempDirRealPath)) {\n fs.mkdirSync(tempDirRealPath);\n }\n if (!fs.existsSync(`${tempDirRealPath}/${encodedName}`)) {\n fs.mkdirSync(`${tempDirRealPath}/${encodedName}`);\n }\n fs.writeFileSync(asyncEntryPath, this._reWriteExports);\n new compiler.webpack.DefinePlugin({\n FederationDataPrefetch: JSON.stringify(asyncEntryPath),\n }).apply(compiler);\n }\n static addRuntime(compiler, options) {\n const encodedName = encodeName(options.name);\n if (!compiler.options.context) {\n throw new Error('compiler.options.context is not defined');\n }\n const prefetchEntry = path.resolve(compiler.options.context, `node_modules/.mf/${encodedName}/bootstrap.js`);\n const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});\n return Template.asString([\n fs.existsSync(prefetchEntry)\n ? Template.indent([\n 'function injectPrefetch() {',\n Template.indent([\n `globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,\n `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,\n `entryLoading: {},`,\n `instance: new Map(),`,\n `__PREFETCH_EXPORTS__: {},`,\n `};`,\n `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,\n `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`,\n ]),\n '}',\n `${federationGlobal}.prefetch = injectPrefetch`,\n ])\n : '',\n Template.indent([\n `if(!${federationGlobal}.isMFRemote && ${federationGlobal}.prefetch){`,\n `${federationGlobal}.prefetch()`,\n '}',\n ]),\n ]);\n }\n static setRemoteIdentifier() {\n const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});\n return Template.indent([`${federationGlobal}.isMFRemote = true;`]);\n }\n static removeRemoteIdentifier() {\n const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});\n return Template.indent([`${federationGlobal}.isMFRemote = false;`]);\n }\n}\n"],"names":["TEMP_DIR","fileExistsWithCaseSync","filepath","dir","path","dirname","filenames","fs","readdirSync","indexOf","basename","fixPrefetchPath","exposePath","pathExt","extReg","test","map","ext","replace","RuntimeGlobals","Template","require","normalizeWebpackPath","getFederationGlobalScope","runtimeGlobals","PrefetchPlugin","apply","compiler","_a","name","exposes","options","context","Error","runtimePlugins","Array","isArray","runtimePath","resolve","__dirname","includes","push","shareStrategy","SHARED_STRATEGY","console","warn","encodedName","encodeName","asyncEntryPath","existsSync","unlinkSync","dataPrefetch","exposeAlias","Object","keys","forEach","alias","exposeValue","import","targetPaths","pathItem","absolutePath","absoluteAlias","_reWriteExports","getPrefetchId","tempDirRealPath","mkdirSync","writeFileSync","webpack","DefinePlugin","FederationDataPrefetch","JSON","stringify","addRuntime","prefetchEntry","federationGlobal","asString","indent","MFPrefetchCommon","globalKey","exportsKey","setRemoteIdentifier","removeRemoteIdentifier","constructor"],"mappings":";;;;;;;;;AAAO,MAAMA,WAAW,KAAM;;ACEvB,MAAMC,yBAAyB,CAACC,QAAAA,GAAAA;IACnC,MAAMC,GAAAA,GAAMC,IAAKC,CAAAA,OAAO,CAACH,QAAAA,CAAAA;IACzB,IAAIA,QAAAA,KAAa,GAAOA,IAAAA,QAAAA,KAAa,GAAK,EAAA;QACtC,OAAO,IAAA;AACX;IACA,MAAMI,SAAAA,GAAYC,EAAGC,CAAAA,WAAW,CAACL,GAAAA,CAAAA;IACjC,IAAIG,SAAAA,CAAUG,OAAO,CAACL,IAAAA,CAAKM,QAAQ,CAACR,QAAAA,CAAAA,CAAAA,KAAe,EAAI,EAAA;QACnD,OAAO,KAAA;AACX;AACA,IAAA,OAAOD,sBAAuBE,CAAAA,GAAAA,CAAAA;AAClC,CAAE;AACK,MAAMQ,kBAAkB,CAACC,UAAAA,GAAAA;AAC5B,IAAA,MAAMC,OAAU,GAAA;AAAC,QAAA,KAAA;AAAO,QAAA;AAAM,KAAA;AAC9B,IAAA,MAAMC,MAAS,GAAA,oB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M,oBAAA,CAAC,2BAA2B,EAAEF,oBAAAA,CAAiBC,SAAS,CAAC,IAAI,EAAED,oBAAiBE,CAAAA,UAAU,CAAC,IAAI,EAAEjD,QAAQF,IAAI,CAAC,gCAAgC,EAAE6C,aAAAA,CAAc,IAAI;AACrK,iBAAA,CAAA;AACD,gBAAA,GAAA;gBACA,CAAC,EAAEC,gBAAiB,CAAA,0BAA0B;aACjD,CACC,GAAA,EAAA;AACNvD,YAAAA,QAAAA,CAASyD,MAAM,CAAC;AACZ,gBAAA,CAAC,IAAI,EAAEF,gBAAAA,CAAiB,eAAe,EAAEA,gBAAAA,CAAiB,WAAW,CAAC;gBACtE,CAAC,EAAEA,gBAAiB,CAAA,WAAW,CAAC;AAChC,gBAAA;AACH,aAAA;AACJ,SAAA,CAAA;AACL;AACA,IAAA,OAAOM,mBAAsB,GAAA;QACzB,MAAMN,gBAAAA,GAAmBpD,wBAAyBJ,CAAAA,cAAAA,IAAkB,EAAC,CAAA;QACrE,OAAOC,QAAAA,CAASyD,MAAM,CAAC;YAAC,CAAC,EAAEF,gBAAiB,CAAA,mBAAmB;AAAE,SAAA,CAAA;AACrE;AACA,IAAA,OAAOO,sBAAyB,GAAA;QAC5B,MAAMP,gBAAAA,GAAmBpD,wBAAyBJ,CAAAA,cAAAA,IAAkB,EAAC,CAAA;QACrE,OAAOC,QAAAA,CAASyD,MAAM,CAAC;YAAC,CAAC,EAAEF,gBAAiB,CAAA,oBAAoB;AAAE,SAAA,CAAA;AACtE;AA7GAQ,IAAAA,WAAAA,CAAYpD,OAAO,CAAE;QACjB,IAAI,CAACA,OAAO,GAAGA,OAAAA;QACf,IAAI,CAACgC,eAAe,GAAG,EAAA;AAC3B;AA2GJ;;;;;"}
@@ -0,0 +1 @@
1
+ export * from "./src/cli/index";
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/cli/index";
@@ -0,0 +1,151 @@
1
+ import path from 'path';
2
+ import fs from 'fs-extra';
3
+ import { encodeName, MFPrefetchCommon } from '@module-federation/sdk';
4
+ import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';
5
+ import { b as getPrefetchId } from './runtime-utils.esm.js';
6
+ import { S as SHARED_STRATEGY } from './constant.esm.js';
7
+
8
+ const TEMP_DIR = '.mf';
9
+
10
+ const fileExistsWithCaseSync = (filepath)=>{
11
+ const dir = path.dirname(filepath);
12
+ if (filepath === '/' || filepath === '.') {
13
+ return true;
14
+ }
15
+ const filenames = fs.readdirSync(dir);
16
+ if (filenames.indexOf(path.basename(filepath)) === -1) {
17
+ return false;
18
+ }
19
+ return fileExistsWithCaseSync(dir);
20
+ };
21
+ const fixPrefetchPath = (exposePath)=>{
22
+ const pathExt = [
23
+ '.js',
24
+ '.ts'
25
+ ];
26
+ const extReg = /\.(ts|js|tsx|jsx)$/;
27
+ if (extReg.test(exposePath)) {
28
+ return pathExt.map((ext)=>exposePath.replace(extReg, `.prefetch${ext}`));
29
+ } else {
30
+ return pathExt.map((ext)=>exposePath + `.prefetch${ext}`);
31
+ }
32
+ };
33
+
34
+ const { RuntimeGlobals, Template } = require(normalizeWebpackPath('webpack'));
35
+ function getFederationGlobalScope(runtimeGlobals) {
36
+ return `${runtimeGlobals.require || '__webpack_require__'}.federation`;
37
+ }
38
+ class PrefetchPlugin {
39
+ apply(compiler) {
40
+ var _a;
41
+ const { name, exposes } = this.options;
42
+ if (!exposes) {
43
+ return;
44
+ }
45
+ if (!compiler.options.context) {
46
+ throw new Error('compiler.options.context is not defined');
47
+ }
48
+ const { runtimePlugins } = this.options;
49
+ if (!Array.isArray(runtimePlugins)) {
50
+ this.options.runtimePlugins = [];
51
+ }
52
+ const runtimePath = path.resolve(__dirname, './plugin.esm.js');
53
+ if (!((_a = this.options.runtimePlugins) === null || _a === void 0 ? void 0 : _a.includes(runtimePath))) {
54
+ this.options.runtimePlugins.push(runtimePath);
55
+ }
56
+ if (this.options.shareStrategy !== SHARED_STRATEGY) {
57
+ this.options.shareStrategy = SHARED_STRATEGY;
58
+ console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to '${SHARED_STRATEGY}', this is a necessary condition for data prefetch`);
59
+ }
60
+ const encodedName = encodeName(name);
61
+ const asyncEntryPath = path.resolve(compiler.options.context, `node_modules/${TEMP_DIR}/${encodedName}/bootstrap.js`);
62
+ if (fs.existsSync(asyncEntryPath)) {
63
+ fs.unlinkSync(asyncEntryPath);
64
+ }
65
+ if (!this.options.dataPrefetch) {
66
+ return;
67
+ }
68
+ const exposeAlias = Object.keys(exposes);
69
+ exposeAlias.forEach((alias)=>{
70
+ let exposePath;
71
+ const exposeValue = exposes[alias];
72
+ if (typeof exposeValue === 'string') {
73
+ exposePath = exposeValue;
74
+ } else {
75
+ exposePath = exposeValue.import[0];
76
+ }
77
+ const targetPaths = fixPrefetchPath(exposePath);
78
+ for (const pathItem of targetPaths){
79
+ const absolutePath = path.resolve(compiler.options.context, pathItem);
80
+ if (fileExistsWithCaseSync(absolutePath)) {
81
+ const absoluteAlias = alias.replace('.', '');
82
+ this._reWriteExports += `export * as ${getPrefetchId(`${name}${absoluteAlias}`)} from '${absolutePath}';\n`;
83
+ break;
84
+ }
85
+ }
86
+ });
87
+ if (!this._reWriteExports) {
88
+ return;
89
+ }
90
+ const tempDirRealPath = path.resolve(compiler.options.context, 'node_modules', TEMP_DIR);
91
+ if (!fs.existsSync(tempDirRealPath)) {
92
+ fs.mkdirSync(tempDirRealPath);
93
+ }
94
+ if (!fs.existsSync(`${tempDirRealPath}/${encodedName}`)) {
95
+ fs.mkdirSync(`${tempDirRealPath}/${encodedName}`);
96
+ }
97
+ fs.writeFileSync(asyncEntryPath, this._reWriteExports);
98
+ new compiler.webpack.DefinePlugin({
99
+ FederationDataPrefetch: JSON.stringify(asyncEntryPath)
100
+ }).apply(compiler);
101
+ }
102
+ static addRuntime(compiler, options) {
103
+ const encodedName = encodeName(options.name);
104
+ if (!compiler.options.context) {
105
+ throw new Error('compiler.options.context is not defined');
106
+ }
107
+ const prefetchEntry = path.resolve(compiler.options.context, `node_modules/.mf/${encodedName}/bootstrap.js`);
108
+ const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
109
+ return Template.asString([
110
+ fs.existsSync(prefetchEntry) ? Template.indent([
111
+ 'function injectPrefetch() {',
112
+ Template.indent([
113
+ `globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
114
+ `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,
115
+ `entryLoading: {},`,
116
+ `instance: new Map(),`,
117
+ `__PREFETCH_EXPORTS__: {},`,
118
+ `};`,
119
+ `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,
120
+ `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`
121
+ ]),
122
+ '}',
123
+ `${federationGlobal}.prefetch = injectPrefetch`
124
+ ]) : '',
125
+ Template.indent([
126
+ `if(!${federationGlobal}.isMFRemote && ${federationGlobal}.prefetch){`,
127
+ `${federationGlobal}.prefetch()`,
128
+ '}'
129
+ ])
130
+ ]);
131
+ }
132
+ static setRemoteIdentifier() {
133
+ const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
134
+ return Template.indent([
135
+ `${federationGlobal}.isMFRemote = true;`
136
+ ]);
137
+ }
138
+ static removeRemoteIdentifier() {
139
+ const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
140
+ return Template.indent([
141
+ `${federationGlobal}.isMFRemote = false;`
142
+ ]);
143
+ }
144
+ constructor(options){
145
+ this.options = options;
146
+ this._reWriteExports = '';
147
+ }
148
+ }
149
+
150
+ export { PrefetchPlugin, getFederationGlobalScope };
151
+ //# sourceMappingURL=cli.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.esm.js","sources":["../src/common/constant.ts","../src/common/node-utils.ts","../src/cli/index.ts"],"sourcesContent":["export const TEMP_DIR = '.mf';\n","import path from 'path';\nimport fs from 'fs-extra';\nexport const fileExistsWithCaseSync = (filepath) => {\n const dir = path.dirname(filepath);\n if (filepath === '/' || filepath === '.') {\n return true;\n }\n const filenames = fs.readdirSync(dir);\n if (filenames.indexOf(path.basename(filepath)) === -1) {\n return false;\n }\n return fileExistsWithCaseSync(dir);\n};\nexport const fixPrefetchPath = (exposePath) => {\n const pathExt = ['.js', '.ts'];\n const extReg = /\\.(ts|js|tsx|jsx)$/;\n if (extReg.test(exposePath)) {\n return pathExt.map((ext) => exposePath.replace(extReg, `.prefetch${ext}`));\n }\n else {\n return pathExt.map((ext) => exposePath + `.prefetch${ext}`);\n }\n};\n","import path from 'path';\nimport fs from 'fs-extra';\nimport { encodeName, MFPrefetchCommon, } from '@module-federation/sdk';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport { TEMP_DIR } from '../common/constant';\nimport { fileExistsWithCaseSync, fixPrefetchPath } from '../common/node-utils';\nimport { getPrefetchId } from '../common/runtime-utils';\nimport { SHARED_STRATEGY } from '../constant';\nconst { RuntimeGlobals, Template } = require(normalizeWebpackPath('webpack'));\nexport function getFederationGlobalScope(runtimeGlobals) {\n return `${runtimeGlobals.require || '__webpack_require__'}.federation`;\n}\nexport class PrefetchPlugin {\n constructor(options) {\n this.options = options;\n this._reWriteExports = '';\n }\n apply(compiler) {\n var _a;\n const { name, exposes } = this.options;\n if (!exposes) {\n return;\n }\n if (!compiler.options.context) {\n throw new Error('compiler.options.context is not defined');\n }\n const { runtimePlugins } = this.options;\n if (!Array.isArray(runtimePlugins)) {\n this.options.runtimePlugins = [];\n }\n const runtimePath = path.resolve(__dirname, './plugin.esm.js');\n if (!((_a = this.options.runtimePlugins) === null || _a === void 0 ? void 0 : _a.includes(runtimePath))) {\n this.options.runtimePlugins.push(runtimePath);\n }\n if (this.options.shareStrategy !== SHARED_STRATEGY) {\n this.options.shareStrategy = SHARED_STRATEGY;\n console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to '${SHARED_STRATEGY}', this is a necessary condition for data prefetch`);\n }\n const encodedName = encodeName(name);\n const asyncEntryPath = path.resolve(compiler.options.context, `node_modules/${TEMP_DIR}/${encodedName}/bootstrap.js`);\n if (fs.existsSync(asyncEntryPath)) {\n fs.unlinkSync(asyncEntryPath);\n }\n if (!this.options.dataPrefetch) {\n return;\n }\n const prefetchs = [];\n const exposeAlias = Object.keys(exposes);\n exposeAlias.forEach((alias) => {\n let exposePath;\n const exposeValue = exposes[alias];\n if (typeof exposeValue === 'string') {\n exposePath = exposeValue;\n }\n else {\n exposePath = exposeValue.import[0];\n }\n const targetPaths = fixPrefetchPath(exposePath);\n for (const pathItem of targetPaths) {\n const absolutePath = path.resolve(compiler.options.context, pathItem);\n if (fileExistsWithCaseSync(absolutePath)) {\n prefetchs.push(pathItem);\n const absoluteAlias = alias.replace('.', '');\n this._reWriteExports += `export * as ${getPrefetchId(`${name}${absoluteAlias}`)} from '${absolutePath}';\\n`;\n break;\n }\n }\n });\n if (!this._reWriteExports) {\n return;\n }\n const tempDirRealPath = path.resolve(compiler.options.context, 'node_modules', TEMP_DIR);\n if (!fs.existsSync(tempDirRealPath)) {\n fs.mkdirSync(tempDirRealPath);\n }\n if (!fs.existsSync(`${tempDirRealPath}/${encodedName}`)) {\n fs.mkdirSync(`${tempDirRealPath}/${encodedName}`);\n }\n fs.writeFileSync(asyncEntryPath, this._reWriteExports);\n new compiler.webpack.DefinePlugin({\n FederationDataPrefetch: JSON.stringify(asyncEntryPath),\n }).apply(compiler);\n }\n static addRuntime(compiler, options) {\n const encodedName = encodeName(options.name);\n if (!compiler.options.context) {\n throw new Error('compiler.options.context is not defined');\n }\n const prefetchEntry = path.resolve(compiler.options.context, `node_modules/.mf/${encodedName}/bootstrap.js`);\n const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});\n return Template.asString([\n fs.existsSync(prefetchEntry)\n ? Template.indent([\n 'function injectPrefetch() {',\n Template.indent([\n `globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,\n `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,\n `entryLoading: {},`,\n `instance: new Map(),`,\n `__PREFETCH_EXPORTS__: {},`,\n `};`,\n `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,\n `globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`,\n ]),\n '}',\n `${federationGlobal}.prefetch = injectPrefetch`,\n ])\n : '',\n Template.indent([\n `if(!${federationGlobal}.isMFRemote && ${federationGlobal}.prefetch){`,\n `${federationGlobal}.prefetch()`,\n '}',\n ]),\n ]);\n }\n static setRemoteIdentifier() {\n const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});\n return Template.indent([`${federationGlobal}.isMFRemote = true;`]);\n }\n static removeRemoteIdentifier() {\n const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});\n return Template.indent([`${federationGlobal}.isMFRemote = false;`]);\n }\n}\n"],"names":["TEMP_DIR","fileExistsWithCaseSync","filepath","dir","path","dirname","filenames","fs","readdirSync","indexOf","basename","fixPrefetchPath","exposePath","pathExt","extReg","test","map","ext","replace","RuntimeGlobals","Template","require","normalizeWebpackPath","getFederationGlobalScope","runtimeGlobals","PrefetchPlugin","apply","compiler","_a","name","exposes","options","context","Error","runtimePlugins","Array","isArray","runtimePath","resolve","__dirname","includes","push","shareStrategy","SHARED_STRATEGY","console","warn","encodedName","encodeName","asyncEntryPath","existsSync","unlinkSync","dataPrefetch","exposeAlias","Object","keys","forEach","alias","exposeValue","import","targetPaths","pathItem","absolutePath","absoluteAlias","_reWriteExports","getPrefetchId","tempDirRealPath","mkdirSync","writeFileSync","webpack","DefinePlugin","FederationDataPrefetch","JSON","stringify","addRuntime","prefetchEntry","federationGlobal","asString","indent","MFPrefetchCommon","globalKey","exportsKey","setRemoteIdentifier","removeRemoteIdentifier","constructor"],"mappings":";;;;;;;AAAO,MAAMA,WAAW,KAAM;;ACEvB,MAAMC,yBAAyB,CAACC,QAAAA,GAAAA;IACnC,MAAMC,GAAAA,GAAMC,IAAKC,CAAAA,OAAO,CAACH,QAAAA,CAAAA;IACzB,IAAIA,QAAAA,KAAa,GAAOA,IAAAA,QAAAA,KAAa,GAAK,EAAA;QACtC,OAAO,IAAA;AACX;IACA,MAAMI,SAAAA,GAAYC,EAAGC,CAAAA,WAAW,CAACL,GAAAA,CAAAA;IACjC,IAAIG,SAAAA,CAAUG,OAAO,CAACL,IAAAA,CAAKM,QAAQ,CAACR,QAAAA,CAAAA,CAAAA,KAAe,EAAI,EAAA;QACnD,OAAO,KAAA;AACX;AACA,IAAA,OAAOD,sBAAuBE,CAAAA,GAAAA,CAAAA;AAClC,CAAE;AACK,MAAMQ,kBAAkB,CAACC,UAAAA,GAAAA;AAC5B,IAAA,MAAMC,OAAU,GAAA;AAAC,QAAA,KAAA;AAAO,QAAA;AAAM,KAAA;AAC9B,IAAA,MAAMC,MAAS,GAAA,oBAAA;IACf,IAAIA,MAAAA,CAAOC,IAAI,CAACH,UAAa,CAAA,EAAA;AACzB,QAAA,OAAOC,OAAQG,CAAAA,GAAG,CAAC,CAACC,GAAQL,GAAAA,UAAAA,CAAWM,OAAO,CAACJ,MAAQ,EAAA,CAAC,SAAS,EAAEG,IAAI,CAAC,CAAA,CAAA;KAEvE,MAAA;QACD,OAAOJ,OAAAA,CAAQG,GAAG,CAAC,CAACC,GAAAA,GAAQL,aAAa,CAAC,SAAS,EAAEK,GAAAA,CAAI,CAAC,CAAA;AAC9D;AACJ,CAAE;;ACdF,M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EAAEA,gBAAAA,CAAiB,WAAW,CAAC;gBACtE,CAAC,EAAEA,gBAAiB,CAAA,WAAW,CAAC;AAChC,gBAAA;AACH,aAAA;AACJ,SAAA,CAAA;AACL;AACA,IAAA,OAAOM,mBAAsB,GAAA;QACzB,MAAMN,gBAAAA,GAAmBpD,wBAAyBJ,CAAAA,cAAAA,IAAkB,EAAC,CAAA;QACrE,OAAOC,QAAAA,CAASyD,MAAM,CAAC;YAAC,CAAC,EAAEF,gBAAiB,CAAA,mBAAmB;AAAE,SAAA,CAAA;AACrE;AACA,IAAA,OAAOO,sBAAyB,GAAA;QAC5B,MAAMP,gBAAAA,GAAmBpD,wBAAyBJ,CAAAA,cAAAA,IAAkB,EAAC,CAAA;QACrE,OAAOC,QAAAA,CAASyD,MAAM,CAAC;YAAC,CAAC,EAAEF,gBAAiB,CAAA,oBAAoB;AAAE,SAAA,CAAA;AACtE;AA7GAQ,IAAAA,WAAAA,CAAYpD,OAAO,CAAE;QACjB,IAAI,CAACA,OAAO,GAAGA,OAAAA;QACf,IAAI,CAACgC,eAAe,GAAG,EAAA;AAC3B;AA2GJ;;;;"}
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ const SHARED_STRATEGY = 'loaded-first';
4
+
5
+ exports.SHARED_STRATEGY = SHARED_STRATEGY;
6
+ //# sourceMappingURL=constant.cjs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.cjs.cjs","sources":["../src/constant.ts"],"sourcesContent":["export const SHARED_STRATEGY = 'loaded-first';\n"],"names":["SHARED_STRATEGY"],"mappings":";;AAAO,MAAMA,kBAAkB;;;;"}
@@ -0,0 +1,4 @@
1
+ const SHARED_STRATEGY = 'loaded-first';
2
+
3
+ export { SHARED_STRATEGY as S };
4
+ //# sourceMappingURL=constant.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.esm.js","sources":["../src/constant.ts"],"sourcesContent":["export const SHARED_STRATEGY = 'loaded-first';\n"],"names":["SHARED_STRATEGY"],"mappings":"AAAO,MAAMA,kBAAkB;;;;"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var prefetch = require('./prefetch.cjs.cjs');
4
+ var plugin = require('./plugin.cjs.cjs');
5
+
6
+
7
+
8
+ exports.MFDataPrefetch = prefetch.MFDataPrefetch;
9
+ exports.prefetchPlugin = plugin.prefetchPlugin;
10
+ //# sourceMappingURL=index.cjs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1 @@
1
+ export * from "./src/index";
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var sdk = require('@module-federation/sdk');
4
+
5
+ const logger = sdk.createLogger('[ Module Federation Data Prefetch ]');
6
+
7
+ exports.logger = logger;
8
+ //# sourceMappingURL=index.cjs2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs2.cjs","sources":["../src/logger/index.ts"],"sourcesContent":["import { createLogger } from '@module-federation/sdk';\nconst logger = createLogger('[ Module Federation Data Prefetch ]');\nexport default logger;\n"],"names":["logger","createLogger"],"mappings":";;;;AACA,MAAMA,SAASC,gBAAa,CAAA,qCAAA;;;;"}
@@ -0,0 +1 @@
1
+ export * from "./src/index";
@@ -0,0 +1,3 @@
1
+ export { M as MFDataPrefetch } from './prefetch.esm.js';
2
+ export { prefetchPlugin } from './plugin.esm.js';
3
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,6 @@
1
+ import { createLogger } from '@module-federation/sdk';
2
+
3
+ const logger = createLogger('[ Module Federation Data Prefetch ]');
4
+
5
+ export { logger as l };
6
+ //# sourceMappingURL=index.esm2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm2.js","sources":["../src/logger/index.ts"],"sourcesContent":["import { createLogger } from '@module-federation/sdk';\nconst logger = createLogger('[ Module Federation Data Prefetch ]');\nexport default logger;\n"],"names":["logger","createLogger"],"mappings":";;AACA,MAAMA,SAASC,YAAa,CAAA,qCAAA;;;;"}