@module-federation/nextjs-mf 5.5.1 → 5.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -27
- package/{lib/client → client}/CombinedPages.d.ts +27 -28
- package/client/CombinedPages.js +38 -0
- package/client/CombinedPages.js.map +1 -0
- package/{lib/client → client}/MFClient.d.ts +72 -73
- package/client/MFClient.js +159 -0
- package/client/MFClient.js.map +1 -0
- package/{lib/client → client}/RemoteContainer.d.ts +46 -58
- package/client/RemoteContainer.js +121 -0
- package/client/RemoteContainer.js.map +1 -0
- package/{lib/client → client}/RemotePages.d.ts +49 -49
- package/client/RemotePages.js +138 -0
- package/client/RemotePages.js.map +1 -0
- package/{lib/client → client}/UrlNode.d.ts +17 -18
- package/{lib/client → client}/UrlNode.js +157 -161
- package/client/UrlNode.js.map +1 -0
- package/{lib/client → client}/helpers.d.ts +16 -17
- package/{lib/client → client}/helpers.js +90 -104
- package/client/helpers.js.map +1 -0
- package/client/index.d.ts +2 -0
- package/client/index.js +6 -0
- package/client/index.js.map +1 -0
- package/{lib/client → client}/useMFClient.d.ts +24 -25
- package/client/useMFClient.js +55 -0
- package/client/useMFClient.js.map +1 -0
- package/{lib/client → client}/useMFRemote.d.ts +16 -17
- package/client/useMFRemote.js +50 -0
- package/client/useMFRemote.js.map +1 -0
- package/jest.config.d.ts +13 -0
- package/jest.config.js +18 -0
- package/jest.config.js.map +1 -0
- package/package.json +19 -42
- package/src/include-defaults.d.ts +0 -0
- package/{lib → src}/include-defaults.js +4 -3
- package/src/include-defaults.js.map +1 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +9 -0
- package/src/index.js.map +1 -0
- package/src/internal.d.ts +12 -0
- package/src/internal.js +260 -0
- package/src/internal.js.map +1 -0
- package/src/loaders/fixImageLoader.d.ts +16 -0
- package/src/loaders/fixImageLoader.js +53 -0
- package/src/loaders/fixImageLoader.js.map +1 -0
- package/src/loaders/fixUrlLoader.d.ts +13 -0
- package/src/loaders/fixUrlLoader.js +25 -0
- package/src/loaders/fixUrlLoader.js.map +1 -0
- package/src/loaders/helpers.d.ts +10 -0
- package/src/loaders/helpers.js +46 -0
- package/src/loaders/helpers.js.map +1 -0
- package/src/loaders/nextPageMapLoader.d.ts +15 -0
- package/src/loaders/nextPageMapLoader.js +151 -0
- package/src/loaders/nextPageMapLoader.js.map +1 -0
- package/src/loaders/patchNextClientPageLoader.d.ts +7 -0
- package/src/loaders/patchNextClientPageLoader.js +43 -0
- package/src/loaders/patchNextClientPageLoader.js.map +1 -0
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +19 -0
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
- package/src/plugins/ChildFederationPlugin.d.ts +9 -0
- package/src/plugins/ChildFederationPlugin.js +281 -0
- package/src/plugins/ChildFederationPlugin.js.map +1 -0
- package/src/plugins/DevHmrFixInvalidPongPlugin.d.ts +11 -0
- package/src/plugins/DevHmrFixInvalidPongPlugin.js +55 -0
- package/src/plugins/DevHmrFixInvalidPongPlugin.js.map +1 -0
- package/src/plugins/ModuleFederationPlugin.d.ts +7 -0
- package/src/plugins/ModuleFederationPlugin.js +50 -0
- package/src/plugins/ModuleFederationPlugin.js.map +1 -0
- package/src/plugins/NextFederationPlugin.d.ts +9 -0
- package/src/plugins/NextFederationPlugin.js +111 -0
- package/src/plugins/NextFederationPlugin.js.map +1 -0
- package/src/plugins/RemoveRRRuntimePlugin.d.ts +5 -0
- package/src/plugins/RemoveRRRuntimePlugin.js +39 -0
- package/src/plugins/RemoveRRRuntimePlugin.js.map +1 -0
- package/utils/Template.d.ts +148 -0
- package/utils/Template.js +381 -0
- package/utils/Template.js.map +1 -0
- package/utils/build-utils.d.ts +3 -0
- package/utils/build-utils.js +175 -0
- package/utils/build-utils.js.map +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +7 -0
- package/utils/index.js.map +1 -0
- package/.prettierignore +0 -2
- package/.prettierrc +0 -7
- package/LICENSE +0 -21
- package/lib/ModuleFederationPlugin.js +0 -84
- package/lib/NextFederationPlugin.js +0 -513
- package/lib/_virtual/Template.js +0 -7
- package/lib/_virtual/UrlNode.js +0 -9
- package/lib/_virtual/_commonjsHelpers.js +0 -44
- package/lib/_virtual/_fast-glob.js +0 -16
- package/lib/_virtual/_fs.js +0 -16
- package/lib/_virtual/_path.js +0 -16
- package/lib/_virtual/_tslib.js +0 -277
- package/lib/_virtual/_webpack-sources.js +0 -16
- package/lib/_virtual/fs.js +0 -4
- package/lib/_virtual/fs2.js +0 -7
- package/lib/_virtual/helpers.js +0 -7
- package/lib/_virtual/nextPageMapLoader.js +0 -7
- package/lib/_virtual/options.js +0 -7
- package/lib/_virtual/utils.js +0 -7
- package/lib/build-utils.js +0 -176
- package/lib/client/CombinedPages.d.ts.map +0 -1
- package/lib/client/CombinedPages.js +0 -60
- package/lib/client/MFClient.d.ts.map +0 -1
- package/lib/client/MFClient.js +0 -213
- package/lib/client/RemoteContainer.d.ts.map +0 -1
- package/lib/client/RemoteContainer.js +0 -162
- package/lib/client/RemotePages.d.ts.map +0 -1
- package/lib/client/RemotePages.js +0 -194
- package/lib/client/UrlNode.d.ts.map +0 -1
- package/lib/client/helpers.d.ts.map +0 -1
- package/lib/client/useMFClient.d.ts.map +0 -1
- package/lib/client/useMFClient.js +0 -79
- package/lib/client/useMFRemote.d.ts.map +0 -1
- package/lib/client/useMFRemote.js +0 -72
- package/lib/dependencies/webpack/lib/Template.js +0 -437
- package/lib/dependencies/webpack/lib/container/options.js +0 -102
- package/lib/dependencies/webpack/lib/sharing/utils.js +0 -104
- package/lib/dependencies/webpack/lib/util/fs.js +0 -359
- package/lib/index.js +0 -3
- package/lib/internal.js +0 -271
- package/lib/loaders/UrlNode.js +0 -219
- package/lib/loaders/fixImageLoader.js +0 -65
- package/lib/loaders/fixUrlLoader.js +0 -25
- package/lib/loaders/helpers.js +0 -60
- package/lib/loaders/nextPageMapLoader.js +0 -200
- package/lib/loaders/patchNextClientPageLoader.js +0 -53
- package/lib/node-plugin/streaming/CommonJsChunkLoadingPlugin.js +0 -94
- package/lib/node-plugin/streaming/LoadFileChunkLoadingRuntimeModule.js +0 -414
- package/lib/node-plugin/streaming/index.js +0 -46
- package/lib/node-plugin/streaming/loadScript.js +0 -59
- package/lib/plugins/DevHmrFixInvalidPongPlugin.js +0 -82
- package/lib/utils.js +0 -125
- package/node-plugin/README.md +0 -27
- package/node-plugin/package.json +0 -4
- package/node-plugin/streaming/CommonJsChunkLoadingPlugin.js +0 -89
- package/node-plugin/streaming/LoadFileChunkLoadingRuntimeModule.js +0 -410
- package/node-plugin/streaming/NodeRuntime.js +0 -245
- package/node-plugin/streaming/index.js +0 -42
- package/node-plugin/streaming/loadScript.js +0 -51
- package/tsconfig.json +0 -33
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import type { MFClient } from './MFClient';
|
|
2
|
-
import type { RemoteContainer } from './RemoteContainer';
|
|
3
|
-
export declare type MFClientHookOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* This callback will be called when user switches to federated page
|
|
6
|
-
* - as a first arg you will receive RemoteContainer
|
|
7
|
-
* If user return back to the host application page
|
|
8
|
-
* - then the first argument became `undefined`
|
|
9
|
-
*
|
|
10
|
-
* This callback is called only if changed remote from which served current visible page
|
|
11
|
-
* and does not called on internal nextjs route changes.
|
|
12
|
-
*
|
|
13
|
-
* This callback helps in very convenient way in _app.tsx (or any other React component)
|
|
14
|
-
* load additional data from RemoteContainer and pass it to your application. Eg.:
|
|
15
|
-
* - application menu
|
|
16
|
-
* - apollo configs
|
|
17
|
-
* - translation strings
|
|
18
|
-
*/
|
|
19
|
-
onChangeRemote?: (remote: RemoteContainer | undefined, MFClient: MFClient) => void;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* React hook which provides convenient way for working with ModuleFederation runtime changes in runtime;
|
|
23
|
-
*/
|
|
24
|
-
export declare function useMFClient(opts: MFClientHookOptions): MFClient;
|
|
25
|
-
//# sourceMappingURL=useMFClient.d.ts.map
|
|
1
|
+
import type { MFClient } from './MFClient';
|
|
2
|
+
import type { RemoteContainer } from './RemoteContainer';
|
|
3
|
+
export declare type MFClientHookOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* This callback will be called when user switches to federated page
|
|
6
|
+
* - as a first arg you will receive RemoteContainer
|
|
7
|
+
* If user return back to the host application page
|
|
8
|
+
* - then the first argument became `undefined`
|
|
9
|
+
*
|
|
10
|
+
* This callback is called only if changed remote from which served current visible page
|
|
11
|
+
* and does not called on internal nextjs route changes.
|
|
12
|
+
*
|
|
13
|
+
* This callback helps in very convenient way in _app.tsx (or any other React component)
|
|
14
|
+
* load additional data from RemoteContainer and pass it to your application. Eg.:
|
|
15
|
+
* - application menu
|
|
16
|
+
* - apollo configs
|
|
17
|
+
* - translation strings
|
|
18
|
+
*/
|
|
19
|
+
onChangeRemote?: (remote: RemoteContainer | undefined, MFClient: MFClient) => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* React hook which provides convenient way for working with ModuleFederation runtime changes in runtime;
|
|
23
|
+
*/
|
|
24
|
+
export declare function useMFClient(opts: MFClientHookOptions): MFClient;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMFClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const React = tslib_1.__importStar(require("react"));
|
|
6
|
+
const router_1 = tslib_1.__importDefault(require("next/dist/client/router"));
|
|
7
|
+
const isBrowser = typeof window !== 'undefined';
|
|
8
|
+
/**
|
|
9
|
+
* React hook which provides convenient way for working with ModuleFederation runtime changes in runtime;
|
|
10
|
+
*/
|
|
11
|
+
function useMFClient(opts) {
|
|
12
|
+
const MFClient = isBrowser
|
|
13
|
+
? window.mf_client
|
|
14
|
+
: /* TODO: inject here SSR version of MFClient if it will be needed in future */ {};
|
|
15
|
+
const innerState = React.useRef({
|
|
16
|
+
remote: undefined,
|
|
17
|
+
});
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
// Step 1: Define handlers and helpers
|
|
20
|
+
const processRemoteChange = (remote) => {
|
|
21
|
+
if (innerState.current.remote !== remote) {
|
|
22
|
+
innerState.current.remote = remote;
|
|
23
|
+
if (opts?.onChangeRemote) {
|
|
24
|
+
opts.onChangeRemote(remote, MFClient);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const handleRouterChange = (pathname) => {
|
|
29
|
+
if (MFClient.isFederatedPathname(pathname)) {
|
|
30
|
+
const remote = MFClient.remotePages.routeToRemote(pathname);
|
|
31
|
+
processRemoteChange(remote);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
processRemoteChange(undefined);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
// Step 2: run bootstrap logic
|
|
38
|
+
const initialRemote = MFClient.isFederatedPathname(window.location.pathname)
|
|
39
|
+
? MFClient.remotePages.routeToRemote(window.location.pathname)
|
|
40
|
+
: undefined;
|
|
41
|
+
if (initialRemote) {
|
|
42
|
+
// important for first load to fire `onChangeRemote` with different remote
|
|
43
|
+
// because in innerState by default we assume that used local application
|
|
44
|
+
processRemoteChange(initialRemote);
|
|
45
|
+
}
|
|
46
|
+
// Step 3: Subscribe on events
|
|
47
|
+
router_1.default.events.on('routeChangeStart', handleRouterChange);
|
|
48
|
+
return () => {
|
|
49
|
+
router_1.default.events.off('routeChangeStart', handleRouterChange);
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
return MFClient;
|
|
53
|
+
}
|
|
54
|
+
exports.useMFClient = useMFClient;
|
|
55
|
+
//# sourceMappingURL=useMFClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMFClient.js","sourceRoot":"","sources":["../../../../packages/nextjs-mf/client/useM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C9D,CAAC,CAAC,SAAS,CAAC;QAEd,IAAI,aAAa,EAAE;YACjB,0EAA0E;YAC1E,yEAAyE;YACzE,mBAAmB,CAAC,aAAa,CAAC,CAAC;SACpC;QAED,8BAA8B;QAC9B,gBAAe,CAAC,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;QAClE,OAAO,GAAG,EAAE;YACV,gBAAe,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;QACrE,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,QAAQ,CAAC;AAClB,CAAC;AAhDD,kCAgDC"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { RemoteContainer } from './RemoteContainer';
|
|
2
|
-
declare type UseMFRemoteResult = {
|
|
3
|
-
/** is container loaded or not */
|
|
4
|
-
loaded: boolean;
|
|
5
|
-
/** remote is Lazy, so it will be loaded if getModule(), getContainer() were called */
|
|
6
|
-
remote: RemoteContainer;
|
|
7
|
-
/** Present if error occurs during remote container loading */
|
|
8
|
-
error: Error | undefined;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* React hook which provides an access to RemoteContainer in Module Federation
|
|
12
|
-
*
|
|
13
|
-
* @param global - can be a global variable name OR connection string "global@url"
|
|
14
|
-
*/
|
|
15
|
-
export declare function useMFRemote(global: string): UseMFRemoteResult;
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=useMFRemote.d.ts.map
|
|
1
|
+
import { RemoteContainer } from './RemoteContainer';
|
|
2
|
+
declare type UseMFRemoteResult = {
|
|
3
|
+
/** is container loaded or not */
|
|
4
|
+
loaded: boolean;
|
|
5
|
+
/** remote is Lazy, so it will be loaded if getModule(), getContainer() were called */
|
|
6
|
+
remote: RemoteContainer;
|
|
7
|
+
/** Present if error occurs during remote container loading */
|
|
8
|
+
error: Error | undefined;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* React hook which provides an access to RemoteContainer in Module Federation
|
|
12
|
+
*
|
|
13
|
+
* @param global - can be a global variable name OR connection string "global@url"
|
|
14
|
+
*/
|
|
15
|
+
export declare function useMFRemote(global: string): UseMFRemoteResult;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMFRemote = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const React = tslib_1.__importStar(require("react"));
|
|
6
|
+
const RemoteContainer_1 = require("./RemoteContainer");
|
|
7
|
+
const isBrowser = typeof window !== 'undefined';
|
|
8
|
+
/**
|
|
9
|
+
* React hook which provides an access to RemoteContainer in Module Federation
|
|
10
|
+
*
|
|
11
|
+
* @param global - can be a global variable name OR connection string "global@url"
|
|
12
|
+
*/
|
|
13
|
+
function useMFRemote(global) {
|
|
14
|
+
let remote;
|
|
15
|
+
if (isBrowser) {
|
|
16
|
+
// on client (we get instances from global variable because webpack breaks Singletons)
|
|
17
|
+
const MFClient = window.mf_client;
|
|
18
|
+
remote = MFClient.remotes[global] || MFClient.registerRemote(global);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
// on server side
|
|
22
|
+
remote = RemoteContainer_1.RemoteContainer.createSingleton(global);
|
|
23
|
+
}
|
|
24
|
+
const [loaded, setLoaded] = React.useState(remote.isLoaded());
|
|
25
|
+
const [error, setError] = React.useState(remote.error);
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
const handleLoadComplete = () => {
|
|
28
|
+
setLoaded(true);
|
|
29
|
+
};
|
|
30
|
+
const handleLoadError = (e) => {
|
|
31
|
+
setError(e);
|
|
32
|
+
};
|
|
33
|
+
if (!loaded && remote.isLoaded()) {
|
|
34
|
+
handleLoadComplete();
|
|
35
|
+
}
|
|
36
|
+
remote.events.on('loadComplete', handleLoadComplete);
|
|
37
|
+
remote.events.on('loadError', handleLoadError);
|
|
38
|
+
return () => {
|
|
39
|
+
remote.events.off('loadComplete', handleLoadComplete);
|
|
40
|
+
remote.events.off('loadError', handleLoadError);
|
|
41
|
+
};
|
|
42
|
+
}, [remote]);
|
|
43
|
+
return {
|
|
44
|
+
remote,
|
|
45
|
+
loaded,
|
|
46
|
+
error,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
exports.useMFRemote = useMFRemote;
|
|
50
|
+
//# sourceMappingURL=useMFRemote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMFRemote.js","sourceRoot":"","sources":["../../../../packages/nextjs-mf/client/useMFRemote.ts"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAE/B,uDAAoD;AAWpD,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD;;;;GAIG;AACH,SAAgB,WAAW,CAAC,MAAc;IACxC,IAAI,MAAuB,CAAC;IAE5B,IAAI,SAAS,EAAE;QACb,sFAAsF;QACtF,MAAM,QAAQ,GAAc,MAAc,CAAC,SAAS,CAAC;QACrD,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;KACtE;SAAM;QACL,iBAAiB;QACjB,MAAM,GAAG,iCAAe,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;KAClD;IAED,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEvD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,kBAAkB,GAAG,GAAG,EAAE;YAC9B,SAAS,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC;QACF,MAAM,eAAe,GAAG,CAAC,CAAQ,EAAE,EAAE;YACnC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACd,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE;YAChC,kBAAkB,EAAE,CAAC;SACtB;QAED,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QACrD,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QAC/C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;YACtD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO;QACL,MAAM;QACN,MAAM;QACN,KAAK;KACN,CAAC;AACJ,CAAC;AAxCD,kCAwCC"}
|
package/jest.config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const displayName: string;
|
|
2
|
+
export const preset: string;
|
|
3
|
+
export const globals: {
|
|
4
|
+
'ts-jest': {
|
|
5
|
+
tsconfig: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export const testEnvironment: string;
|
|
9
|
+
export const transform: {
|
|
10
|
+
'^.+\\.[tj]s$': string;
|
|
11
|
+
};
|
|
12
|
+
export const moduleFileExtensions: string[];
|
|
13
|
+
export const coverageDirectory: string;
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
module.exports = {
|
|
4
|
+
displayName: 'nextjs-mf-js',
|
|
5
|
+
preset: '../../jest.preset.js',
|
|
6
|
+
globals: {
|
|
7
|
+
'ts-jest': {
|
|
8
|
+
tsconfig: '<rootDir>/tsconfig.spec.json',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
testEnvironment: 'node',
|
|
12
|
+
transform: {
|
|
13
|
+
'^.+\\.[tj]s$': 'ts-jest',
|
|
14
|
+
},
|
|
15
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
16
|
+
coverageDirectory: '../../coverage/packages/nextjs-mf-js',
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=jest.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.config.js","sourceRoot":"","sources":["../../../packages/nextjs-mf/jest.config.js"],"names":[],"mappings":";AAAA,oBAAoB;AACpB,MAAM,CAAC,OAAO,GAAG;IACf,WAAW,EAAE,cAAc;IAC3B,MAAM,EAAE,sBAAsB;IAC9B,OAAO,EAAE;QACP,SAAS,EAAE;YACT,QAAQ,EAAE,8BAA8B;SACzC;KACF;IACD,eAAe,EAAE,MAAM;IACvB,SAAS,EAAE;QACT,cAAc,EAAE,SAAS;KAC1B;IACD,oBAAoB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC;IAC1C,iBAAiB,EAAE,sCAAsC;CAC1D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,53 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
+
"version": "5.6.1",
|
|
3
|
+
"main": "src/index.js",
|
|
4
|
+
"types": "src/index.d.ts",
|
|
5
|
+
"contributors": [
|
|
6
|
+
"Pavel Chertorogov, nodkz <pavel.chertorogov@gmail.com> (www.ps.kz)"
|
|
7
|
+
],
|
|
2
8
|
"public": true,
|
|
3
9
|
"name": "@module-federation/nextjs-mf",
|
|
4
|
-
"
|
|
10
|
+
"type": "commonjs",
|
|
5
11
|
"description": "Module Federation helper for NextJS",
|
|
6
|
-
"
|
|
7
|
-
"types": "lib/index.d.ts",
|
|
8
|
-
"repository": "https://github.com/module-federation/nextjs-mf",
|
|
12
|
+
"repository": "https://github.com/module-federation/nextjs-mf/tree/main/packages/nextjs-mf",
|
|
9
13
|
"author": "Zack Jackson <zackary.l.jackson@gmail.com>",
|
|
10
|
-
"contributors": [
|
|
11
|
-
"Pavel Chertorogov, nodkz <pavel.chertorogov@gmail.com> (www.ps.kz)"
|
|
12
|
-
],
|
|
13
14
|
"license": "MIT",
|
|
14
|
-
"scripts": {
|
|
15
|
-
"demo": "sleep 3 && cd demo && yarn install && yarn dev",
|
|
16
|
-
"dev": "rm -rf lib && concurrently \"yarn sync-files --watch\" \"yarn compile --watch\" \"yarn demo\"",
|
|
17
|
-
"prettier": "prettier --write \"**/*.{js,json,md,ts,tsx}\"",
|
|
18
|
-
"sync-files": "cpx \"src/**/*.js\" lib/",
|
|
19
|
-
"compile": "rollup -c",
|
|
20
|
-
"build": "rm -rf lib && yarn sync-files && yarn compile",
|
|
21
|
-
"prepublishOnly": "yarn build"
|
|
22
|
-
},
|
|
23
15
|
"dependencies": {
|
|
24
|
-
"@swc/core": "^1.3.2",
|
|
25
|
-
"chalk": "^4.0.0",
|
|
26
|
-
"eventemitter3": "^4.0.7",
|
|
27
16
|
"fast-glob": "^3.2.11",
|
|
28
|
-
"webpack-sources": "^3.2.3"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
34
|
-
"@types/react": "^18.0.19",
|
|
35
|
-
"concurrently": "^7.3.0",
|
|
36
|
-
"cpx": "^1.5.0",
|
|
37
|
-
"next": "12.3.0",
|
|
38
|
-
"prettier": "2.3.2",
|
|
39
|
-
"react": "^18.2.0",
|
|
40
|
-
"rollup": "^2.78.1",
|
|
41
|
-
"rollup-obfuscator": "^3.0.1",
|
|
42
|
-
"rollup-plugin-node-builtins": "^2.1.2",
|
|
43
|
-
"rollup-plugin-node-globals": "^1.4.0",
|
|
44
|
-
"rollup-plugin-rename-node-modules": "^1.3.1",
|
|
45
|
-
"rollup-plugin-typescript2": "0.34.0",
|
|
46
|
-
"tslib": "^2.4.0",
|
|
47
|
-
"typescript": "^4.8.2",
|
|
48
|
-
"webpack": "5.64.4"
|
|
17
|
+
"webpack-sources": "^3.2.3",
|
|
18
|
+
"@module-federation/node": "0.2.1",
|
|
19
|
+
"@module-federation/utilities": "0.0.1",
|
|
20
|
+
"@swc/core": "^1.3.3",
|
|
21
|
+
"tslib": "^2.3.0"
|
|
49
22
|
},
|
|
50
23
|
"peerDependencies": {
|
|
51
|
-
"
|
|
52
|
-
|
|
24
|
+
"webpack": "5.45.1",
|
|
25
|
+
"next": "12.2.0",
|
|
26
|
+
"react": "^17 || ^18",
|
|
27
|
+
"react-dom": "^17 || ^18"
|
|
28
|
+
},
|
|
29
|
+
"typings": "./src/index.d.ts"
|
|
53
30
|
}
|
|
File without changes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// this is needed to ensure webpack does not attempt to tree shake unused modules. Since these should always come from host
|
|
2
3
|
require('react');
|
|
3
4
|
require('react-dom');
|
|
@@ -7,8 +8,8 @@ require('next/head');
|
|
|
7
8
|
require('next/script');
|
|
8
9
|
require('next/dynamic');
|
|
9
10
|
require('styled-jsx');
|
|
10
|
-
if (process.env
|
|
11
|
-
|
|
11
|
+
if (process.env['NODE_ENV'] === 'development') {
|
|
12
|
+
require('react/jsx-dev-runtime');
|
|
12
13
|
}
|
|
13
|
-
|
|
14
14
|
module.exports = {};
|
|
15
|
+
//# sourceMappingURL=include-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"include-defaults.js","sourceRoot":"","sources":["../../../../packages/nextjs-mf/src/include-defaults.ts"],"names":[],"mappings":";AAAA,2HAA2H;AAC3H,OAAO,CAAC,OAAO,CAAC,CAAC;AACjB,OAAO,CAAC,WAAW,CAAC,CAAC;AACrB,OAAO,CAAC,WAAW,CAAC,CAAC;AACrB,OAAO,CAAC,aAAa,CAAC,CAAC;AACvB,OAAO,CAAC,WAAW,CAAC,CAAC;AACrB,OAAO,CAAC,aAAa,CAAC,CAAC;AACvB,OAAO,CAAC,cAAc,CAAC,CAAC;AACxB,OAAO,CAAC,YAAY,CAAC,CAAC;AAEtB,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,aAAa,EAAE;IAC7C,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAClC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC"}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NextFederationPlugin = void 0;
|
|
4
|
+
const NextFederationPlugin_1 = require("./plugins/NextFederationPlugin");
|
|
5
|
+
Object.defineProperty(exports, "NextFederationPlugin", { enumerable: true, get: function () { return NextFederationPlugin_1.NextFederationPlugin; } });
|
|
6
|
+
exports.default = NextFederationPlugin_1.NextFederationPlugin;
|
|
7
|
+
module.exports = NextFederationPlugin_1.NextFederationPlugin;
|
|
8
|
+
module.exports.NextFederationPlugin = NextFederationPlugin_1.NextFederationPlugin;
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nextjs-mf/src/index.ts"],"names":[],"mappings":";;;AAAA,yEAAsE;AAE7D,qGAFA,2CAAoB,OAEA;AAC7B,kBAAe,2CAAoB,CAAC;AAEpC,MAAM,CAAC,OAAO,GAAG,2CAAoB,CAAC;AACtC,MAAM,CAAC,OAAO,CAAC,oBAAoB,GAAG,2CAAoB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
import type { ModuleFederationPluginOptions, Shared, SharedConfig, SharedObject } from '@module-federation/utilities';
|
|
3
|
+
export declare const DEFAULT_SHARE_SCOPE: SharedObject;
|
|
4
|
+
export declare const reKeyHostShared: (options?: Shared) => Record<string, SharedConfig>;
|
|
5
|
+
export declare const generateRemoteTemplate: (url: string, global: any) => string;
|
|
6
|
+
export declare const internalizeSharedPackages: (options: ModuleFederationPluginOptions, compiler: Compiler) => void;
|
|
7
|
+
export declare const externalizedShares: SharedObject;
|
|
8
|
+
export declare const getOutputPath: (compiler: Compiler) => string;
|
|
9
|
+
export declare const removePlugins: string[];
|
|
10
|
+
export declare const parseRemoteSyntax: (remote: string) => string;
|
|
11
|
+
export declare const parseRemotes: (remotes: Record<string, any>) => Record<string, string>;
|
|
12
|
+
export declare const toDisplayErrors: (err: Error[]) => string;
|
package/src/internal.js
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toDisplayErrors = exports.parseRemotes = exports.parseRemoteSyntax = exports.removePlugins = exports.getOutputPath = exports.externalizedShares = exports.internalizeSharedPackages = exports.generateRemoteTemplate = exports.reKeyHostShared = exports.DEFAULT_SHARE_SCOPE = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const options_1 = require("webpack/lib/container/options");
|
|
7
|
+
const utils_1 = require("webpack/lib/sharing/utils");
|
|
8
|
+
const utilities_1 = require("@module-federation/utilities");
|
|
9
|
+
// the share scope we attach by default
|
|
10
|
+
// in hosts we re-key them to prevent webpack moving the modules into their own chunks (cause eager error)
|
|
11
|
+
// in remote these are marked as import:false as we always expect the host to prove them
|
|
12
|
+
exports.DEFAULT_SHARE_SCOPE = {
|
|
13
|
+
react: {
|
|
14
|
+
singleton: true,
|
|
15
|
+
requiredVersion: false,
|
|
16
|
+
},
|
|
17
|
+
'react/jsx-runtime': {
|
|
18
|
+
singleton: true,
|
|
19
|
+
requiredVersion: false,
|
|
20
|
+
},
|
|
21
|
+
'react-dom': {
|
|
22
|
+
singleton: true,
|
|
23
|
+
requiredVersion: false,
|
|
24
|
+
},
|
|
25
|
+
'next/dynamic': {
|
|
26
|
+
requiredVersion: false,
|
|
27
|
+
singleton: true,
|
|
28
|
+
},
|
|
29
|
+
'styled-jsx': {
|
|
30
|
+
requiredVersion: false,
|
|
31
|
+
singleton: true,
|
|
32
|
+
},
|
|
33
|
+
'next/link': {
|
|
34
|
+
requiredVersion: false,
|
|
35
|
+
singleton: true,
|
|
36
|
+
},
|
|
37
|
+
'next/router': {
|
|
38
|
+
requiredVersion: false,
|
|
39
|
+
singleton: true,
|
|
40
|
+
},
|
|
41
|
+
'next/script': {
|
|
42
|
+
requiredVersion: false,
|
|
43
|
+
singleton: true,
|
|
44
|
+
},
|
|
45
|
+
'next/head': {
|
|
46
|
+
requiredVersion: false,
|
|
47
|
+
singleton: true,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
// put host in-front of any shared module key, so "hostreact"
|
|
51
|
+
const reKeyHostShared = (options = {}) => {
|
|
52
|
+
const shared = {
|
|
53
|
+
...options,
|
|
54
|
+
...exports.DEFAULT_SHARE_SCOPE,
|
|
55
|
+
};
|
|
56
|
+
return Object.entries(shared).reduce((acc, item) => {
|
|
57
|
+
const [itemKey, shareOptions] = item;
|
|
58
|
+
const shareKey = 'host' + (item.shareKey || itemKey);
|
|
59
|
+
acc[shareKey] = shareOptions;
|
|
60
|
+
if (!shareOptions.import) {
|
|
61
|
+
acc[shareKey].import = itemKey;
|
|
62
|
+
}
|
|
63
|
+
if (!shareOptions.shareKey) {
|
|
64
|
+
acc[shareKey].shareKey = itemKey;
|
|
65
|
+
}
|
|
66
|
+
if (exports.DEFAULT_SHARE_SCOPE[itemKey]) {
|
|
67
|
+
acc[shareKey].packageName = itemKey;
|
|
68
|
+
}
|
|
69
|
+
return acc;
|
|
70
|
+
}, {});
|
|
71
|
+
};
|
|
72
|
+
exports.reKeyHostShared = reKeyHostShared;
|
|
73
|
+
// browser template to convert remote into promise new promise and use require.loadChunk to load the chunk
|
|
74
|
+
const generateRemoteTemplate = (url, global) => {
|
|
75
|
+
return `new Promise(function (resolve, reject) {
|
|
76
|
+
var __webpack_error__ = new Error();
|
|
77
|
+
if (typeof ${global} !== 'undefined') return resolve();
|
|
78
|
+
__webpack_require__.l(
|
|
79
|
+
${JSON.stringify(url)},
|
|
80
|
+
function (event) {
|
|
81
|
+
if (typeof ${global} !== 'undefined') return resolve();
|
|
82
|
+
var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
83
|
+
var realSrc = event && event.target && event.target.src;
|
|
84
|
+
__webpack_error__.message =
|
|
85
|
+
'Loading script failed.\\n(' + errorType + ': ' + realSrc + ')';
|
|
86
|
+
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
87
|
+
__webpack_error__.type = errorType;
|
|
88
|
+
__webpack_error__.request = realSrc;
|
|
89
|
+
reject(__webpack_error__);
|
|
90
|
+
},
|
|
91
|
+
${JSON.stringify(global)},
|
|
92
|
+
);
|
|
93
|
+
}).then(function () {
|
|
94
|
+
const proxy = {
|
|
95
|
+
get: ${global}.get,
|
|
96
|
+
init: function(shareScope) {
|
|
97
|
+
const handler = {
|
|
98
|
+
get(target, prop) {
|
|
99
|
+
if (target[prop]) {
|
|
100
|
+
Object.values(target[prop]).forEach(function(o) {
|
|
101
|
+
if(o.from === '_N_E') {
|
|
102
|
+
o.loaded = 1
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
return target[prop]
|
|
107
|
+
},
|
|
108
|
+
set(target, property, value, receiver) {
|
|
109
|
+
if (target[property]) {
|
|
110
|
+
return target[property]
|
|
111
|
+
}
|
|
112
|
+
target[property] = value
|
|
113
|
+
return true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
${global}.init(new Proxy(shareScope, handler))
|
|
118
|
+
} catch (e) {
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
${global}.__initialized = true
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (!${global}.__initialized) {
|
|
125
|
+
proxy.init()
|
|
126
|
+
}
|
|
127
|
+
return proxy
|
|
128
|
+
})`;
|
|
129
|
+
};
|
|
130
|
+
exports.generateRemoteTemplate = generateRemoteTemplate;
|
|
131
|
+
// shared packages must be compiled into webpack bundle, not require() pass through
|
|
132
|
+
const internalizeSharedPackages = (options, compiler) => {
|
|
133
|
+
//TODO: should use this util for other areas where we read MF options from userland
|
|
134
|
+
if (!options.shared) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const sharedOptions = parseShareOptions(options);
|
|
138
|
+
// get share keys from user, filter out ones that need to be external
|
|
139
|
+
const internalizableKeys = Object.keys(sharedOptions).filter((key) => {
|
|
140
|
+
if (!exports.DEFAULT_SHARE_SCOPE[key]) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
const index = sharedOptions[key].import;
|
|
144
|
+
if (index && !exports.DEFAULT_SHARE_SCOPE[index]) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
return false;
|
|
148
|
+
});
|
|
149
|
+
if (Array.isArray(compiler.options.externals)) {
|
|
150
|
+
// take original externals regex
|
|
151
|
+
const backupExternals = compiler.options.externals[0];
|
|
152
|
+
// if externals is a function (like when you're not running in serverless mode or creating a single build)
|
|
153
|
+
if (typeof backupExternals === 'function') {
|
|
154
|
+
// replace externals function with short-circuit, or fall back to original algo
|
|
155
|
+
compiler.options.externals[0] = (mod, callback) => {
|
|
156
|
+
if (!internalizableKeys.some((v) => mod.request?.includes(v))) {
|
|
157
|
+
return backupExternals(mod, callback);
|
|
158
|
+
}
|
|
159
|
+
// bundle it
|
|
160
|
+
return Promise.resolve();
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
exports.internalizeSharedPackages = internalizeSharedPackages;
|
|
166
|
+
exports.externalizedShares = Object.entries(exports.DEFAULT_SHARE_SCOPE).reduce((acc, item) => {
|
|
167
|
+
const [key, value] = item;
|
|
168
|
+
acc[key] = { ...value, import: false };
|
|
169
|
+
if (key === 'react/jsx-runtime') {
|
|
170
|
+
delete acc[key].import;
|
|
171
|
+
}
|
|
172
|
+
return acc;
|
|
173
|
+
}, {});
|
|
174
|
+
// determine output base path, derives .next folder location
|
|
175
|
+
const getOutputPath = (compiler) => {
|
|
176
|
+
const isServer = compiler.options.target !== 'client';
|
|
177
|
+
let outputPath = compiler.options.output.path?.split(path_1.default.sep);
|
|
178
|
+
const foundIndex = outputPath?.findIndex((i) => {
|
|
179
|
+
return i === (isServer ? 'server' : 'static');
|
|
180
|
+
});
|
|
181
|
+
outputPath = outputPath
|
|
182
|
+
?.slice(0, foundIndex && foundIndex > 0 ? foundIndex : outputPath.length)
|
|
183
|
+
.join(path_1.default.sep);
|
|
184
|
+
return outputPath;
|
|
185
|
+
};
|
|
186
|
+
exports.getOutputPath = getOutputPath;
|
|
187
|
+
exports.removePlugins = [
|
|
188
|
+
'NextJsRequireCacheHotReloader',
|
|
189
|
+
'BuildManifestPlugin',
|
|
190
|
+
'WellKnownErrorsPlugin',
|
|
191
|
+
'WebpackBuildEventsPlugin',
|
|
192
|
+
'HotModuleReplacementPlugin',
|
|
193
|
+
'NextMiniCssExtractPlugin',
|
|
194
|
+
'NextFederationPlugin',
|
|
195
|
+
'CopyFilePlugin',
|
|
196
|
+
'ProfilingPlugin',
|
|
197
|
+
'DropClientPage',
|
|
198
|
+
'ReactFreshWebpackPlugin',
|
|
199
|
+
];
|
|
200
|
+
const parseRemoteSyntax = (remote) => {
|
|
201
|
+
if (typeof remote === 'string' && remote.includes('@')) {
|
|
202
|
+
const [url, global] = (0, utilities_1.extractUrlAndGlobal)(remote);
|
|
203
|
+
return (0, exports.generateRemoteTemplate)(url, global);
|
|
204
|
+
}
|
|
205
|
+
return remote;
|
|
206
|
+
};
|
|
207
|
+
exports.parseRemoteSyntax = parseRemoteSyntax;
|
|
208
|
+
const parseRemotes = (remotes) => {
|
|
209
|
+
return Object.entries(remotes).reduce((acc, remote) => {
|
|
210
|
+
if (!remote[1].startsWith('promise ') && remote[1].includes('@')) {
|
|
211
|
+
acc[remote[0]] = 'promise ' + (0, exports.parseRemoteSyntax)(remote[1]);
|
|
212
|
+
return acc;
|
|
213
|
+
}
|
|
214
|
+
acc[remote[0]] = remote[1];
|
|
215
|
+
return acc;
|
|
216
|
+
}, {});
|
|
217
|
+
};
|
|
218
|
+
exports.parseRemotes = parseRemotes;
|
|
219
|
+
const parseShareOptions = (options) => {
|
|
220
|
+
const sharedOptions = (0, options_1.parseOptions)(options.shared, (item, key) => {
|
|
221
|
+
if (typeof item !== 'string')
|
|
222
|
+
throw new Error('Unexpected array in shared');
|
|
223
|
+
/** @type {SharedConfig} */
|
|
224
|
+
const config = item === key || !(0, utils_1.isRequiredVersion)(item)
|
|
225
|
+
? {
|
|
226
|
+
import: item,
|
|
227
|
+
}
|
|
228
|
+
: {
|
|
229
|
+
import: key,
|
|
230
|
+
requiredVersion: item,
|
|
231
|
+
};
|
|
232
|
+
return config;
|
|
233
|
+
}, (item) => item);
|
|
234
|
+
return sharedOptions.reduce((acc, [key, options]) => {
|
|
235
|
+
acc[key] = {
|
|
236
|
+
import: options.import,
|
|
237
|
+
shareKey: options.shareKey || key,
|
|
238
|
+
shareScope: options.shareScope,
|
|
239
|
+
requiredVersion: options.requiredVersion,
|
|
240
|
+
strictVersion: options.strictVersion,
|
|
241
|
+
singleton: options.singleton,
|
|
242
|
+
packageName: options.packageName,
|
|
243
|
+
eager: options.eager,
|
|
244
|
+
};
|
|
245
|
+
return acc;
|
|
246
|
+
}, {});
|
|
247
|
+
};
|
|
248
|
+
const toDisplayErrors = (err) => {
|
|
249
|
+
return err
|
|
250
|
+
.map((error) => {
|
|
251
|
+
let message = error.message;
|
|
252
|
+
if (error.stack) {
|
|
253
|
+
message += '\n' + error.stack;
|
|
254
|
+
}
|
|
255
|
+
return message;
|
|
256
|
+
})
|
|
257
|
+
.join('\n');
|
|
258
|
+
};
|
|
259
|
+
exports.toDisplayErrors = toDisplayErrors;
|
|
260
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../../packages/nextjs-mf/src/internal.ts"],"names":[],"mappings":";;;;AAQA,wDAAwB;AACxB,2DAA6D;AAC7D,qDAA8D;AAE9D,4DAAmE;AAEnE,uCAAuC;AACvC,0GAA0G;AAC1G,wFAAwF;AAC3E,QAAA,mBAAmB,GAAiB;IAC/C,KAAK,EAAE;QACL,SAAS,EAAE,IAAI;QACf,eAAe,EAAE,KAAK;KACvB;IACD,mBAAmB,EAAE;QACnB,SAAS,EAAE,IAAI;QACf,eAAe,EAAE,KAAK;KACvB;IACD,WAAW,EAAE;QACX,SAAS,EAAE,IAAI;QACf,eAAe,EAAE,KAAK;KACvB;IACD,cAAc,EAAE;QACd,eAAe,EAAE,KAAK;QACtB,SAAS,EAAE,IAAI;KAChB;IACD,YAAY,EAAE;QACZ,eAAe,EAAE,KAAK;QACtB,SAAS,EAAE,IAAI;KAChB;IACD,WAAW,EAAE;QACX,eAAe,EAAE,KAAK;QACtB,SAAS,EAAE,IAAI;KAChB;IACD,aAAa,EAAE;QACb,eAAe,EAAE,KAAK;QACtB,SAAS,EAAE,IAAI;KAChB;IACD,aAAa,EAAE;QACb,eAAe,EAAE,KAAK;QACtB,SAAS,EAAE,IAAI;KAChB;IACD,WAAW,EAAE;QACX,eAAe,EAAE,KAAK;QACtB,SAAS,EAAE,IAAI;KAChB;CACF,CAAC;AAEF,6DAA6D;AACtD,MAAM,eAAe,GAAG,CAC7B,UAAkB,EAAE,EACU,EAAE;IAChC,MAAM,MAAM,GAAG;QACb,GAAG,OAAO;QACV,GAAG,2BAAmB;KACS,CAAC;IAElC,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACjD,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,GAA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