diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000000..8ddbc0c64a7 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v18.16.0 diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 6a302fe5368..00000000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "recommendations": [ - "nrwl.angular-console", - "esbenp.prettier-vscode", - "dbaeumer.vscode-eslint", - "firsttris.vscode-jest-runner" - ] -} diff --git a/apps/3000-home/components/SharedNav.tsx b/apps/3000-home/components/SharedNav.tsx index 3f4544f0d97..1960644a9c0 100644 --- a/apps/3000-home/components/SharedNav.tsx +++ b/apps/3000-home/components/SharedNav.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { Menu, Layout } from 'antd'; import { useRouter } from 'next/router'; +import './menu'; const SharedNav = () => { const { asPath, push } = useRouter(); diff --git a/apps/3000-home/next.config.js b/apps/3000-home/next.config.js index c2932217e25..8ee86bd40f0 100644 --- a/apps/3000-home/next.config.js +++ b/apps/3000-home/next.config.js @@ -1,12 +1,12 @@ const { registerPluginTSTranspiler } = require('nx/src/utils/nx-plugin.js'); registerPluginTSTranspiler(); -const { withNx } = require('@nx/next/plugins/with-nx'); -const { createDelegatedModule } = require('@module-federation/utilities'); +const { withNx } = require('@nrwl/next/plugins/with-nx'); const NextFederationPlugin = require('@module-federation/nextjs-mf'); +const { createDelegatedModule } = require('@module-federation/utilities'); /** - * @type {import('@nx/next/plugins/with-nx').WithNxOptions} + * @type {import('@nrwl/next/plugins/with-nx').WithNxOptions} **/ const nextConfig = { nx: { @@ -16,6 +16,7 @@ const nextConfig = { }, webpack(config, options) { const { isServer } = options; + // used for testing build output snapshots const remotes = { shop: createDelegatedModule(require.resolve('./remote-delegate.js'), { @@ -26,6 +27,7 @@ const nextConfig = { // checkout: createDelegatedModule(require.resolve('./remote-delegate.js'), { // remote: `checkout@http://localhost:3002/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`, // }), + // shop: `shop@http://localhost:3001/_next/static/${ // isServer ? 'ssr' : 'chunks' // }/remoteEntry.js`, @@ -51,7 +53,6 @@ const nextConfig = { antd: {}, }, extraOptions: { - automaticAsyncBoundary: true, exposePages: true, enableImageLoaderFix: true, enableUrlLoaderFix: true, diff --git a/apps/3000-home/package.json b/apps/3000-home/package.json index 06239d259d7..ed0af9f5aaf 100644 --- a/apps/3000-home/package.json +++ b/apps/3000-home/package.json @@ -5,7 +5,7 @@ "dependencies": { "antd": "^4.22.3", "lodash": "4.17.21", - "next": "13.3.1", + "next": "13.4.2", "react": "18.2.0", "react-dom": "18.2.0", "js-cookie": "^3.0.1" diff --git a/apps/3000-home/pages/_app.tsx b/apps/3000-home/pages/_app.tsx index 97b6c4f8adc..285248875dd 100644 --- a/apps/3000-home/pages/_app.tsx +++ b/apps/3000-home/pages/_app.tsx @@ -7,7 +7,7 @@ import Router, { useRouter } from 'next/router'; import SharedNav from '../components/SharedNav'; import HostAppMenu from '../components/menu'; import 'antd/dist/antd.css'; - +console.log(__webpack_share_scopes__); function MyApp(props) { const { Component, pageProps } = props; const { asPath } = useRouter(); @@ -26,7 +26,7 @@ function MyApp(props) { } }; // handle first route hit. - React.useMemo(() => handleRouteChange(asPath), []); + React.useMemo(() => handleRouteChange(asPath), [asPath]); //handle route change React.useEffect(() => { diff --git a/apps/3000-home/pages/api/test.js b/apps/3000-home/pages/api/test.js new file mode 100644 index 00000000000..eacc7a20000 --- /dev/null +++ b/apps/3000-home/pages/api/test.js @@ -0,0 +1,3 @@ +export default function handler(req, res) { + res.status(200).json({ name: 'John Doe' }); +} diff --git a/apps/3000-home/pages/checkout/index.tsx b/apps/3000-home/pages/checkout/index.tsx index 5e0926dca82..bfc14922a6a 100644 --- a/apps/3000-home/pages/checkout/index.tsx +++ b/apps/3000-home/pages/checkout/index.tsx @@ -1,7 +1,7 @@ -// @ts-ignore +//@ts-ignore import Page from 'checkout/pages/checkout/index'; - const Checkout = Page; +// the data loading method needs to be here so next can static analyze it properly. +// eslint-disable-next-line no-self-assign Checkout.getInitialProps = Page.getInitialProps; - export default Checkout; diff --git a/apps/3000-home/pages/dynamic-remote.js b/apps/3000-home/pages/dynamic-remote.js new file mode 100644 index 00000000000..f13784149a9 --- /dev/null +++ b/apps/3000-home/pages/dynamic-remote.js @@ -0,0 +1,47 @@ +import React from 'react'; +//eslint-disable-next-line +import { injectScript } from '@module-federation/utilities'; +// example of dynamic remote import on server and client +const isServer = typeof window === 'undefined'; +//could also use +// getModule({ +// remoteContainer: { +// global: 'app2', +// url: 'http://localhost:3002/remoteEntry.js', +// }, +// modulePath: './sample' +// }).then((sample) => { +// console.log(sample) +// }); +const dynamicContainer = injectScript({ + global: 'checkout', + url: `http://localhost:3002/_next/static/${ + isServer ? 'ssr' : 'chunks' + }/remoteEntry.js`, +}).then((container) => { + return container.get('./CheckoutTitle').then((factory) => { + return factory(); + }); +}); +const DynamicComponent = React.lazy(() => dynamicContainer); + +// eslint-disable-next-line react/display-name +export default (props) => { + return ( + <> + + + +

Code from GSSP:

+
{props.code}
+ + ); +}; + +export async function getServerSideProps() { + return { + props: { + code: (await dynamicContainer).default.toString(), + }, + }; +} diff --git a/apps/3000-home/pages/index.tsx b/apps/3000-home/pages/index.tsx index 53016df512f..de8dc3815e7 100644 --- a/apps/3000-home/pages/index.tsx +++ b/apps/3000-home/pages/index.tsx @@ -1,19 +1,18 @@ -import React, { Suspense } from 'react'; +import React, { Suspense, lazy } from 'react'; import Head from 'next/head'; -import dynamic from 'next/dynamic'; - -const CheckoutTitle = dynamic(() => import('checkout/CheckoutTitle'), { - ssr: true, -}); -const ButtonOldAnt = dynamic(() => import('checkout/ButtonOldAnt'), { - ssr: true, -}); -const WebpackSvgRemote = dynamic(() => import('shop/WebpackSvg'), { - ssr: true, -}); -const WebpackPngRemote = dynamic(() => import('shop/WebpackPng'), { - ssr: true, -}); +import CheckoutTitle from 'checkout/CheckoutTitle'; +import ButtonOldAnt from 'checkout/ButtonOldAnt'; +console.log(ButtonOldAnt); +// console.log('cc', cc); +// const CheckoutTitle = lazy(() => import('checkout/CheckoutTitle')); +// const ButtonOldAnt = lazy(() => import('checkout/ButtonOldAnt')); +const WebpackSvgRemote = lazy(() => + import('shop/WebpackSvg').then((m) => { + console.log(m); + return m; + }) +); +const WebpackPngRemote = lazy(() => import('shop/WebpackPng')); const Home = () => { return ( @@ -63,7 +62,6 @@ const Home = () => { checkout -

Federation test cases

diff --git a/apps/3000-home/project.json b/apps/3000-home/project.json index f3e65a28e1b..2801b9f7ae5 100644 --- a/apps/3000-home/project.json +++ b/apps/3000-home/project.json @@ -17,7 +17,13 @@ "outputPath": "dist/apps/3000-home" }, "production": {} - } + }, + "dependsOn": [ + { + "target": "build", + "dependencies": true + } + ] }, "serve": { "executor": "@nx/next:server", @@ -50,10 +56,11 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["apps/3000-home/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": [ + "apps/3000-home/**/*.{ts,tsx,js,jsx}" + ] } } }, - "tags": [], - "implicitDependencies": ["nextjs-mf"] + "tags": [] } diff --git a/apps/3000-home/remote-delegate.js b/apps/3000-home/remote-delegate.js index 73cca88f2b9..bf9a185c28a 100644 --- a/apps/3000-home/remote-delegate.js +++ b/apps/3000-home/remote-delegate.js @@ -1,14 +1,13 @@ /* eslint-disable no-undef */ -const { importDelegatedModule } = require('@module-federation/utilities'); - -// Delegates are currently not used in this example, but are left here for testing. -module.exports = new Promise((resolve, reject) => { - //eslint-disable-next-line - console.log('Delegate being called for', __resourceQuery); +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { //eslint-disable-next-line const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); const [global, url] = currentRequest.split('@'); + const { importDelegatedModule } = await import( + '@module-federation/utilities/src/utils/importDelegatedModule' + ); importDelegatedModule({ global, diff --git a/apps/3001-shop/next.config.js b/apps/3001-shop/next.config.js index d24adfab8c4..148a8678a2a 100644 --- a/apps/3001-shop/next.config.js +++ b/apps/3001-shop/next.config.js @@ -23,33 +23,33 @@ const nextConfig = { name: 'shop', filename: 'static/chunks/remoteEntry.js', remotes: { - home: createDelegatedModule(require.resolve('./remote-delegate.js'), { - remote: `home_app@http://localhost:3000/_next/static/${ - isServer ? 'ssr' : 'chunks' - }/remoteEntry.js`, - }), - shop: createDelegatedModule(require.resolve('./remote-delegate.js'), { - remote: `shop@http://localhost:3001/_next/static/${ - isServer ? 'ssr' : 'chunks' - }/remoteEntry.js`, - }), - checkout: createDelegatedModule( - require.resolve('./remote-delegate.js'), - { - remote: `checkout@http://localhost:3002/_next/static/${ - isServer ? 'ssr' : 'chunks' - }/remoteEntry.js`, - } - ), - // home: `home_app@http://localhost:3000/_next/static/${ - // isServer ? 'ssr' : 'chunks' - // }/remoteEntry.js`, - // shop: `shop@http://localhost:3001/_next/static/${ - // isServer ? 'ssr' : 'chunks' - // }/remoteEntry.js`, - // checkout: `checkout@http://localhost:3002/_next/static/${ - // isServer ? 'ssr' : 'chunks' - // }/remoteEntry.js`, + // home: createDelegatedModule(require.resolve('./remote-delegate.js'), { + // remote: `home_app@http://localhost:3000/_next/static/${ + // isServer ? 'ssr' : 'chunks' + // }/remoteEntry.js`, + // }), + // shop: createDelegatedModule(require.resolve('./remote-delegate.js'), { + // remote: `shop@http://localhost:3001/_next/static/${ + // isServer ? 'ssr' : 'chunks' + // }/remoteEntry.js`, + // }), + // checkout: createDelegatedModule( + // require.resolve('./remote-delegate.js'), + // { + // remote: `checkout@http://localhost:3002/_next/static/${ + // isServer ? 'ssr' : 'chunks' + // }/remoteEntry.js`, + // } + // ), + home: `home_app@http://localhost:3000/_next/static/${ + isServer ? 'ssr' : 'chunks' + }/remoteEntry.js`, + shop: `shop@http://localhost:3001/_next/static/${ + isServer ? 'ssr' : 'chunks' + }/remoteEntry.js`, + checkout: `checkout@http://localhost:3002/_next/static/${ + isServer ? 'ssr' : 'chunks' + }/remoteEntry.js`, }, exposes: { './useCustomRemoteHook': './components/useCustomRemoteHook', @@ -59,10 +59,10 @@ const nextConfig = { }, shared: { lodash: {}, + antd: {}, }, extraOptions: { exposePages: true, - automaticAsyncBoundary: true, enableImageLoaderFix: true, enableUrlLoaderFix: true, automaticPageStitching: false, diff --git a/apps/3001-shop/package.json b/apps/3001-shop/package.json index 5ead4eb723c..cfdadbf934b 100644 --- a/apps/3001-shop/package.json +++ b/apps/3001-shop/package.json @@ -5,7 +5,7 @@ "dependencies": { "antd": "^4.22.3", "lodash": "4.17.21", - "next": "13.3.1", + "next": "13.4.2", "react": "18.2.0", "react-dom": "18.2.0" }, diff --git a/apps/3001-shop/pages/_app.tsx b/apps/3001-shop/pages/_app.tsx index 5457174cab1..bd36735741a 100644 --- a/apps/3001-shop/pages/_app.tsx +++ b/apps/3001-shop/pages/_app.tsx @@ -27,7 +27,7 @@ function MyApp({ Component, pageProps }) { } }; // handle first route hit. - React.useMemo(() => handleRouteChange(asPath), []); + React.useMemo(() => handleRouteChange(asPath), [asPath]); //handle route change React.useEffect(() => { diff --git a/apps/3001-shop/pages/shop/exposed-pages.tsx b/apps/3001-shop/pages/shop/exposed-pages.tsx index 86dd61c3fcb..7e951e3037d 100644 --- a/apps/3001-shop/pages/shop/exposed-pages.tsx +++ b/apps/3001-shop/pages/shop/exposed-pages.tsx @@ -1,5 +1,6 @@ import { useState, useEffect } from 'react'; +// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries import { injectScript } from '@module-federation/nextjs-mf/utils'; export default function ExposedPages() { diff --git a/apps/3001-shop/pages/shop/index.tsx b/apps/3001-shop/pages/shop/index.tsx index c4decaf1dbb..af8197811e8 100644 --- a/apps/3001-shop/pages/shop/index.tsx +++ b/apps/3001-shop/pages/shop/index.tsx @@ -3,51 +3,60 @@ import Head from 'next/head'; import WebpackPng from '../../components/WebpackPng'; -const Shop = () => ( -
- - Shop - - +const Shop = (props) => { + return ( +
+ + Shop + + -
-

Shop Page

-

- This is a federated page owned by localhost:3001 -

-

- This application manually exposes page-map and its modules - (see next.config.js file). -
-
- -

+
+

Shop Page

+

+ This is a federated page owned by localhost:3001 +

+

+ This application manually exposes page-map and its + modules (see next.config.js file). +
+
+ +

+
{JSON.stringify(props)}
+
+
- -
-); + ); +}; Shop.getInitialProps = async () => { - const swapi = await fetch('https://swapi.dev/api/people/1').then((res) => - res.json() - ); - return swapi; + try { + const swapi = await fetch('https://swapi.dev/api/people/1').then((res) => + res.json() + ); + return swapi; + } catch (e) { + return { + apiFail: true, + }; + } }; export default Shop; diff --git a/apps/3001-shop/project.json b/apps/3001-shop/project.json index 39c9177c09e..969c3bb7f8c 100644 --- a/apps/3001-shop/project.json +++ b/apps/3001-shop/project.json @@ -17,7 +17,13 @@ "outputPath": "dist/apps/3001-shop" }, "production": {} - } + }, + "dependsOn": [ + { + "target": "build", + "dependencies": true + } + ] }, "serve": { "executor": "@nx/next:server", @@ -50,7 +56,9 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["apps/3001-shop/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": [ + "apps/3001-shop/**/*.{ts,tsx,js,jsx}" + ] } } }, diff --git a/apps/3001-shop/remote-delegate.js b/apps/3001-shop/remote-delegate.js index fae5d14daa3..789450d7d47 100644 --- a/apps/3001-shop/remote-delegate.js +++ b/apps/3001-shop/remote-delegate.js @@ -1,11 +1,14 @@ /* eslint-disable no-undef */ -import { importDelegatedModule } from '@module-federation/utilities'; - // Delegates are currently not used in this example, but are left here for testing. -module.exports = new Promise((resolve, reject) => { +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { + const { importDelegatedModule } = await import( + '@module-federation/utilities' + ); + //eslint-disable-next-line - console.log('Delegate being called for', __resourceQuery); + // console.log('Delegate being called for', __resourceQuery, __webpack_runtime_id__); //eslint-disable-next-line const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); @@ -16,11 +19,11 @@ module.exports = new Promise((resolve, reject) => { url: url + '?' + Date.now(), }) .then(async (remote) => { - console.log( - __resourceQuery, - 'resolved remote from', - __webpack_runtime_id__ - ); + // console.log( + // __resourceQuery, + // 'resolved remote from', + // __webpack_runtime_id__ + // ); resolve(remote); }) diff --git a/apps/3002-checkout/components/ButtonOldAnt.tsx b/apps/3002-checkout/components/ButtonOldAnt.tsx index 67ec0486a89..1a815bade92 100644 --- a/apps/3002-checkout/components/ButtonOldAnt.tsx +++ b/apps/3002-checkout/components/ButtonOldAnt.tsx @@ -1,6 +1,6 @@ import Button from 'antd/lib/button'; import { version } from 'antd/package.json'; - +import stuff from './stuff.module.css'; export default function ButtonOldAnt() { - return ; + return ; } diff --git a/apps/3002-checkout/components/CheckoutTitle.tsx b/apps/3002-checkout/components/CheckoutTitle.tsx index 21e494e2f35..c464de57161 100644 --- a/apps/3002-checkout/components/CheckoutTitle.tsx +++ b/apps/3002-checkout/components/CheckoutTitle.tsx @@ -1,5 +1,4 @@ import React, { useEffect, useState } from 'react'; - const CheckoutTitle = () => { const [hookData, setHookData] = useState(''); diff --git a/apps/3002-checkout/components/stuff.module.css b/apps/3002-checkout/components/stuff.module.css new file mode 100644 index 00000000000..5a853caf0db --- /dev/null +++ b/apps/3002-checkout/components/stuff.module.css @@ -0,0 +1,3 @@ +.test { + background: red; +} diff --git a/apps/3002-checkout/next.config.js b/apps/3002-checkout/next.config.js index 53eccd6946e..2af673ea21a 100644 --- a/apps/3002-checkout/next.config.js +++ b/apps/3002-checkout/next.config.js @@ -23,33 +23,24 @@ const nextConfig = { name: 'checkout', filename: 'static/chunks/remoteEntry.js', remotes: { - home: createDelegatedModule(require.resolve('./remote-delegate.js'), { - remote: `home_app@http://localhost:3000/_next/static/${ - isServer ? 'ssr' : 'chunks' - }/remoteEntry.js`, - }), - shop: createDelegatedModule(require.resolve('./remote-delegate.js'), { - remote: `shop@http://localhost:3001/_next/static/${ - isServer ? 'ssr' : 'chunks' - }/remoteEntry.js`, - }), - checkout: createDelegatedModule( - require.resolve('./remote-delegate.js'), - { - remote: `checkout@http://localhost:3002/_next/static/${ - isServer ? 'ssr' : 'chunks' - }/remoteEntry.js`, - } - ), - // home: `home_app@http://localhost:3000/_next/static/${ - // isServer ? 'ssr' : 'chunks' - // }/remoteEntry.js`, - // shop: `shop@http://localhost:3001/_next/static/${ - // isServer ? 'ssr' : 'chunks' - // }/remoteEntry.js`, - // checkout: `checkout@http://localhost:3002/_next/static/${ - // isServer ? 'ssr' : 'chunks' - // }/remoteEntry.js`, + // home: createDelegatedModule(require.resolve('./remote-delegate.js'), { + // remote: `home_app@http://localhost:3000/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`, + // }), + // shop: createDelegatedModule(require.resolve('./remote-delegate.js'), { + // remote: `shop@http://localhost:3001/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`, + // }), + // checkout: createDelegatedModule(require.resolve('./remote-delegate.js'), { + // remote: `checkout@http://localhost:3002/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`, + // }), + home: `home_app@http://localhost:3000/_next/static/${ + isServer ? 'ssr' : 'chunks' + }/remoteEntry.js`, + shop: `shop@http://localhost:3001/_next/static/${ + isServer ? 'ssr' : 'chunks' + }/remoteEntry.js`, + checkout: `checkout@http://localhost:3002/_next/static/${ + isServer ? 'ssr' : 'chunks' + }/remoteEntry.js`, }, exposes: { './CheckoutTitle': './components/CheckoutTitle', @@ -58,9 +49,9 @@ const nextConfig = { }, shared: { lodash: {}, + antd: {}, }, extraOptions: { - automaticAsyncBoundary: true, exposePages: true, enableImageLoaderFix: true, enableUrlLoaderFix: true, diff --git a/apps/3002-checkout/package.json b/apps/3002-checkout/package.json index eebfb60dd30..189fc097d64 100644 --- a/apps/3002-checkout/package.json +++ b/apps/3002-checkout/package.json @@ -5,7 +5,7 @@ "dependencies": { "antd": "4.24.12", "lodash": "4.17.21", - "next": "13.3.1", + "next": "13.4.2", "react": "18.2.0", "react-dom": "18.2.0" }, diff --git a/apps/3002-checkout/pages/_app.tsx b/apps/3002-checkout/pages/_app.tsx index 036eba235d9..998f5a143fe 100644 --- a/apps/3002-checkout/pages/_app.tsx +++ b/apps/3002-checkout/pages/_app.tsx @@ -26,7 +26,7 @@ function MyApp({ Component, pageProps }) { } }; // handle first route hit. - React.useMemo(() => handleRouteChange(asPath), []); + React.useMemo(() => handleRouteChange(asPath), [asPath]); //handle route change React.useEffect(() => { diff --git a/apps/3002-checkout/pages/checkout/exposed-pages.tsx b/apps/3002-checkout/pages/checkout/exposed-pages.tsx index 98e234689af..93157ea85ff 100644 --- a/apps/3002-checkout/pages/checkout/exposed-pages.tsx +++ b/apps/3002-checkout/pages/checkout/exposed-pages.tsx @@ -1,5 +1,6 @@ import { useState, useEffect } from 'react'; +// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries import { injectScript } from '@module-federation/nextjs-mf/utils'; export default function ExposedPages() { diff --git a/apps/3002-checkout/project.json b/apps/3002-checkout/project.json index 2f5ebf1b94d..fa81079722d 100644 --- a/apps/3002-checkout/project.json +++ b/apps/3002-checkout/project.json @@ -17,7 +17,13 @@ "outputPath": "dist/apps/3002-checkout" }, "production": {} - } + }, + "dependsOn": [ + { + "target": "build", + "dependencies": true + } + ] }, "serve": { "executor": "@nx/next:server", @@ -50,7 +56,9 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["apps/3002-checkout/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": [ + "apps/3002-checkout/**/*.{ts,tsx,js,jsx}" + ] } } }, diff --git a/apps/3002-checkout/remote-delegate.js b/apps/3002-checkout/remote-delegate.js index fae5d14daa3..0fad24d5356 100644 --- a/apps/3002-checkout/remote-delegate.js +++ b/apps/3002-checkout/remote-delegate.js @@ -1,13 +1,15 @@ /* eslint-disable no-undef */ -import { importDelegatedModule } from '@module-federation/utilities'; - // Delegates are currently not used in this example, but are left here for testing. -module.exports = new Promise((resolve, reject) => { +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { //eslint-disable-next-line - console.log('Delegate being called for', __resourceQuery); + // console.log('Delegate being called for', __resourceQuery); //eslint-disable-next-line const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); + const { importDelegatedModule } = await import( + '@module-federation/utilities' + ); const [global, url] = currentRequest.split('@'); @@ -16,11 +18,11 @@ module.exports = new Promise((resolve, reject) => { url: url + '?' + Date.now(), }) .then(async (remote) => { - console.log( - __resourceQuery, - 'resolved remote from', - __webpack_runtime_id__ - ); + // console.log( + // __resourceQuery, + // 'resolved remote from', + // __webpack_runtime_id__ + // ); resolve(remote); }) diff --git a/apps/react-ts-host/project.json b/apps/react-ts-host/project.json index cf0a0a5716e..1ee80b3b7a7 100644 --- a/apps/react-ts-host/project.json +++ b/apps/react-ts-host/project.json @@ -47,7 +47,13 @@ "vendorChunk": false, "webpackConfig": "apps/react-ts-host/webpack.config.prod.js" } - } + }, + "dependsOn": [ + { + "target": "build", + "dependencies": true + } + ] }, "serve": { "executor": "@nx/react:module-federation-dev-server", @@ -71,7 +77,9 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["apps/react-ts-host/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": [ + "apps/react-ts-host/**/*.{ts,tsx,js,jsx}" + ] } }, "serve-static": { @@ -92,5 +100,7 @@ } }, "tags": [], - "implicitDependencies": ["typescript"] + "implicitDependencies": [ + "typescript" + ] } diff --git a/apps/react-ts-remote/project.json b/apps/react-ts-remote/project.json index b43455986d2..a09e20f7e4a 100644 --- a/apps/react-ts-remote/project.json +++ b/apps/react-ts-remote/project.json @@ -20,7 +20,9 @@ "apps/react-ts-remote/src/favicon.ico", "apps/react-ts-remote/src/assets" ], - "styles": ["apps/react-ts-remote/src/styles.css"], + "styles": [ + "apps/react-ts-remote/src/styles.css" + ], "scripts": [], "webpackConfig": "apps/react-ts-remote/webpack.config.js", "babelUpwardRootMode": true @@ -47,7 +49,13 @@ "vendorChunk": false, "webpackConfig": "apps/react-ts-remote/webpack.config.prod.js" } - } + }, + "dependsOn": [ + { + "target": "build", + "dependencies": true + } + ] }, "serve": { "executor": "@nx/react:module-federation-dev-server", @@ -71,7 +79,9 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["apps/react-ts-remote/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": [ + "apps/react-ts-remote/**/*.{ts,tsx,js,jsx}" + ] } }, "serve-static": { diff --git a/apps/reactRemoteUI/project.json b/apps/reactRemoteUI/project.json index a3054253d4e..a2b46660f9c 100644 --- a/apps/reactRemoteUI/project.json +++ b/apps/reactRemoteUI/project.json @@ -15,8 +15,12 @@ "baseHref": "/", "main": "apps/reactRemoteUI/src/main.ts", "tsConfig": "apps/reactRemoteUI/tsconfig.app.json", - "assets": ["apps/reactRemoteUI/src/favicon.ico"], - "styles": ["apps/reactRemoteUI/src/styles.scss"], + "assets": [ + "apps/reactRemoteUI/src/favicon.ico" + ], + "styles": [ + "apps/reactRemoteUI/src/styles.scss" + ], "scripts": [], "isolatedConfig": true, "webpackConfig": "apps/reactRemoteUI/webpack.config.js" @@ -43,7 +47,13 @@ "vendorChunk": false, "webpackConfig": "apps/reactRemoteUI/webpack.config.prod.js" } - } + }, + "dependsOn": [ + { + "target": "build", + "dependencies": true + } + ] }, "serve": { "executor": "@nx/react:module-federation-dev-server", @@ -67,7 +77,9 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["apps/reactRemoteUI/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": [ + "apps/reactRemoteUI/**/*.{ts,tsx,js,jsx}" + ] } }, "test": { diff --git a/apps/reactStorybook/project.json b/apps/reactStorybook/project.json index 20a866a56c5..7acc20d540a 100644 --- a/apps/reactStorybook/project.json +++ b/apps/reactStorybook/project.json @@ -19,7 +19,9 @@ "apps/reactStorybook/src/favicon.ico", "apps/reactStorybook/src/assets" ], - "styles": ["apps/reactStorybook/src/styles.scss"], + "styles": [ + "apps/reactStorybook/src/styles.scss" + ], "scripts": [], "isolatedConfig": true, "webpackConfig": "apps/reactStorybook/webpack.config.js" @@ -46,7 +48,13 @@ "vendorChunk": false, "webpackConfig": "apps/reactStorybook/webpack.config.prod.js" } - } + }, + "dependsOn": [ + { + "target": "build", + "dependencies": true + } + ] }, "serve": { "executor": "@nx/react:module-federation-dev-server", @@ -70,7 +78,9 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["apps/reactStorybook/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": [ + "apps/reactStorybook/**/*.{ts,tsx,js,jsx}" + ] } }, "test": { diff --git a/generate-exports.js b/generate-exports.js new file mode 100644 index 00000000000..a2feca7f1a3 --- /dev/null +++ b/generate-exports.js @@ -0,0 +1,61 @@ +const fs = require('fs'); +const path = require('path'); + +// Set the root directory +const rootDir = './packages'; + +// Function to update "exports" in package.json +const updateExports = (packageDir) => { + const srcDir = path.join(packageDir, 'src'); + + // Check if "src" directory exists + if (!fs.existsSync(srcDir)) { + console.log(`No "src" directory found in ${packageDir}. Skipping...`); + return; + } + + // Read the package.json + const packageJsonPath = path.join(packageDir, 'package.json'); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath)); + + // Generate "exports" field + const exportsField = { + '.': './src/index.js', + './package.json': './package.json', + }; + + // Go through the src directory recursively and create mappings + const createMappings = (dir, prefix = '.') => { + const entries = fs.readdirSync(dir, { withFileTypes: true }); + entries.forEach((entry) => { + const fullPath = path.join(dir, entry.name); + const key = path.join(prefix, entry.name); + if (entry.isDirectory()) { + createMappings(fullPath, key); + } else if (entry.isFile() && path.basename(fullPath)) { + const keyWithoutExtension = key.substring(0, key.lastIndexOf('.')); + exportsField[ + `./${keyWithoutExtension}` + ] = `./src/${keyWithoutExtension}/index.js`; + } + }); + }; + + createMappings(srcDir); + + // Update the package.json + packageJson.exports = exportsField; + console.log(packageJson.name, packageJson.exports); + // fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); +}; + +// Get the list of packages +const packages = fs + .readdirSync(rootDir, { withFileTypes: true }) + .filter((dirent) => dirent.isDirectory()) + .map((dirent) => path.join(rootDir, dirent.name)); + +// Update each package +packages.forEach(updateExports); + +console.log('Exports field successfully updated for all packages.'); diff --git a/gpt/commit.js b/gpt/commit.js index e2d2fcf497b..adb974af0a7 100644 --- a/gpt/commit.js +++ b/gpt/commit.js @@ -17,7 +17,7 @@ const renderMarkdown = require('./markdown'); const { commandJoin } = require('command-join'); const schema = ` { - "Title": "[title]", + "Title": "[fix|feat|chore|refactor]:[title]", "Description": "[description]", "Changes": [ {{"filename": "[filename]", "description": ["[description]", "[description]"]}}, @@ -68,6 +68,33 @@ async function* getValidJsonResponse(prompt, userFeedback) { } } +function getDiff(maxCharCount = MAX_CHAR_COUNT) { + let maxUFlag = 7; + + let diff = [ + execSync('git diff --staged --stat').toString(), + execSync(`git diff -U${maxUFlag} --staged`).toString(), + ].join('\n'); + + while (diff.length > maxCharCount && maxUFlag > 2) { + maxUFlag--; + diff = [ + execSync('git diff --staged --stat').toString(), + execSync(`git diff -U${maxUFlag} --staged`).toString(), + ].join('\n'); + console.warn( + 'over max char count, reducing diff fidelity', + 'from:', + diff.length, + 'to:', + diff.length, + `(-U flag now ${maxUFlag})` + ); + } + + return diff; +} + /** * Generates a commit message using the GPT-3 model. * @@ -94,21 +121,9 @@ async function generateCommitMsg() { } console.log('tokens', diff.length, MAX_CHAR_COUNT); - const oldDiff = diff.length; if (diff.length > MAX_CHAR_COUNT) { - diff = [ - execSync('git diff --staged --stat').toString(), - execSync('git diff -U5 --staged').toString(), - ].join('\n'); - - console.warn( - 'over max char count, reducing diff fidelity', - 'from:', - oldDiff.length, - 'to:', - diff.length - ); + diff = getDiff(MAX_CHAR_COUNT); } let prompt = createPrompt(diff); @@ -127,6 +142,16 @@ In the description, provide an overall summary of the changes, and detail the ch ${schema} +Example: +{ + "Title": "fix: fix bug in commit message generation", + "Description": "This commit fixes a bug in the commit message generation process.", + "Changes": [ + {{"filename": "example.js", "description": ["created new example"]}}, + {{"filename": "src/example2.ts", "description": ["updated variable names", "added utility function to handle edge case"]}} + ] +} +\n\n Here's the git diff for your reference: ${input.slice(0, MAX_CHAR_COUNT)}`; } diff --git a/gpt/file.js b/gpt/file.js index 1e10c3b0362..82306c14824 100644 --- a/gpt/file.js +++ b/gpt/file.js @@ -34,7 +34,8 @@ For each file, start with '__BLOCK_START__', followed by the filename, then '__C `; async function promptFile(filePaths, question) { - if (!filePaths || !Array.isArray(filePaths) || filePaths.length === 0) { + if (typeof filePaths === 'string') filePaths = [filePaths]; + if (!filePaths || filePaths.length === 0) { throw new Error('Missing or invalid argument: filePaths'); } diff --git a/gpt/filev2.js b/gpt/filev2.js new file mode 100644 index 00000000000..a0ea0158b6a --- /dev/null +++ b/gpt/filev2.js @@ -0,0 +1,98 @@ +const readline = require('readline'); +const fs = require('fs'); +const path = require('path'); +const glob = require('glob'); +const { openai, completion } = require('./openai'); // Assuming openai.js is in the same directory +const { + TemplateSystem, + CodeEditPromptTemplate, + CodeEditAnswerTemplate, +} = require('./response-template/template-factory'); + +class FileProcessor { + constructor() { + this.chatHistory = []; + this.ignoredDirectories = ['node_modules', '.next', 'dist']; + this.directoryTree = {}; + this.templateSystem = new TemplateSystem(); + this.templateSystem.add('codeEditPrompt', new CodeEditPromptTemplate()); + this.templateSystem.add('codeEditAnswer', new CodeEditAnswerTemplate()); + } + + buildDirectoryTree(directoryPath, currentDirectory) { + const files = fs.readdirSync(directoryPath); + for (const file of files) { + const fullPath = path.join(directoryPath, file); + const stats = fs.statSync(fullPath); + if (stats.isDirectory() && !this.ignoredDirectories.includes(file)) { + currentDirectory[file] = {}; + this.buildDirectoryTree(fullPath, currentDirectory[file]); + } else if (stats.isFile()) { + currentDirectory[file] = null; + } + } + } + async processFiles(filePaths) { + for (const filePath of filePaths) { + const response = await this.processFile(filePath); + console.log(`Generated code for ${filePath}:\n${response}`); + if (response.toLowerCase() === 'yes') { + fs.writeFileSync(`${filePath}_suggested.js`, response); + } + } + } + async processFile(filePath) { + const content = fs.readFileSync(filePath, 'utf-8'); + const prompt = this.templateSystem.get('codeEditPrompt', { + files: [{ name: filePath, content }], + tasks: ['Edit the code'], + }); + let result = await completion({ prompt, max_tokens: 1000 }); + const parsedResult = JSON.parse(result); + const formattedResult = this.templateSystem.get('codeEditAnswer', { + files: parsedResult, + }); + fs.writeFileSync(filePath + '.suggested.js', formattedResult); + } + + isTruncated(response) { + // Define your own criteria for a truncated response + // This is just an example and may not work for all cases + const openBrackets = (response.match(/{/g) || []).length; + const closeBrackets = (response.match(/}/g) || []).length; + return openBrackets !== closeBrackets; + } + + async interactWithUser() { + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + + rl.question('Which file(s) do you want to process? ', async (input) => { + // Split the input by commas to handle a comma-separated list of paths + const paths = input.split(','); + for (const path of paths) { + // Use glob to handle glob patterns + glob(path.trim(), async (err, files) => { + if (err) { + console.error(err); + return; + } + for (const file of files) { + const response = await this.processFile(file); + console.log(`Generated code for ${file}:\n${response}`); + rl.question('Do you accept these changes? (yes/no) ', (answer) => { + if (answer.toLowerCase() === 'yes') { + fs.writeFileSync(`${file}_suggested.js`, response); + } + rl.close(); + }); + } + }); + } + }); + } +} + +module.exports = FileProcessor; diff --git a/gpt/filev2.test.js b/gpt/filev2.test.js new file mode 100644 index 00000000000..aef49391392 --- /dev/null +++ b/gpt/filev2.test.js @@ -0,0 +1,34 @@ +// FileProcessor.test.js +const fs = require('fs'); +const FileProcessor = require('./FileProcessor'); + +describe('FileProcessor', () => { + let fileProcessor; + + beforeEach(() => { + fileProcessor = new FileProcessor(); + }); + + test('processFiles with OpenAI API', async () => { + const filePaths = ['./example.js']; // replace with your actual file paths + await fileProcessor.processFiles(filePaths); + + filePaths.forEach((filePath) => { + const suggestedFilePath = `${filePath}_suggested.js`; + expect(fs.existsSync(suggestedFilePath)).toBe(true); + + const suggestedContent = fs.readFileSync(suggestedFilePath, 'utf-8'); + // Check if the suggested content is in the correct JSON format + let parsedContent; + try { + parsedContent = JSON.parse(suggestedContent); + } catch (error) { + throw new Error(`Suggested content for ${filePath} is not valid JSON`); + } + + // Check if the parsed content has the correct structure + expect(parsedContent).toHaveProperty('filename'); + expect(parsedContent).toHaveProperty('code'); + }); + }); +}); diff --git a/gpt/get-answer-from-files.js b/gpt/get-answer-from-files.js index 47d614b0a51..132c76a1604 100644 --- a/gpt/get-answer-from-files.js +++ b/gpt/get-answer-from-files.js @@ -47,7 +47,7 @@ async function getAnswer(chunkMaps, question) { } } - if (currentChunk.length > 0) { + if (fileChunks.length > 0) { let prompt = basePrompt + currentChunk + responsePrompt; chatHistory.add({ role: ChatCompletionRequestMessageRoleEnum.System, diff --git a/gpt/response-template/code.js b/gpt/response-template/code.js new file mode 100644 index 00000000000..2b02b1cc341 --- /dev/null +++ b/gpt/response-template/code.js @@ -0,0 +1,19 @@ +const { chatHistory } = require('../constants'); +const responseTemplate = ` +The response should follow this template: +\n +__BLOCK_START__ +[filename 1] +__CODE_START__ +[code changes for file 1] +__BLOCK_END__ +__BLOCK_START__ +[filename 2] +__CODE_START__ +[code changes for file 2] +__BLOCK_END__\n +__BLOCK_FINISH__ +\n +${response.end}`; + +module.exports = responseTemplate; diff --git a/gpt/response-template/template-factory.js b/gpt/response-template/template-factory.js new file mode 100644 index 00000000000..e9792d082b1 --- /dev/null +++ b/gpt/response-template/template-factory.js @@ -0,0 +1,54 @@ +class CodeEditPromptTemplate { + apply({ files, tasks }) { + return ` + Given the files provided, please perform the following tasks as needed: + ${tasks.join('\n')} + The files are as follows: + ${files + .map( + (file) => + `__BLOCK_START__\n${file.name}\n__CODE_START__\n${file.content}\n__BLOCK_END__` + ) + .join('\n\n')} + Please provide the updated code as the answer to this objective. The response should be a JSON string that contains an array of objects. Each object should have a 'filename' key and a 'code' key with the corresponding values. For example: + [ + { + "filename": "file1.js", + "code": "const updatedCodeForFile1 = 'This is the updated code for file1.js';" + }, + { + "filename": "file2.js", + "code": "const updatedCodeForFile2 = 'This is the updated code for file2.js';" + } + ] + ${response.end} + `; + } +} + +class TemplateSystem { + constructor() { + this.templates = { + fileProcessingPrompt: new Template( + ({ filePath, content }) => `File: ${filePath}\nContent:\n${content}` + ), + commandPrompt: new Template( + ({ command, args }) => + `Command: ${command}\nArguments: ${args.join(', ')}` + ), + codeEditPrompt: new CodeEditPromptTemplate(), + // Add more templates as needed + }; + } + + get(templateName, args) { + if (!this.templates[templateName]) { + throw new Error(`No template found for ${templateName}`); + } + return this.templates[templateName].apply(args); + } + + add(templateName, templateFunction) { + this.templates[templateName] = new Template(templateFunction); + } +} diff --git a/gpt/services/extractTextFromFile.js b/gpt/services/extractTextFromFile.js index 672854c1b4a..31108d1d1c5 100644 --- a/gpt/services/extractTextFromFile.js +++ b/gpt/services/extractTextFromFile.js @@ -39,6 +39,6 @@ module.exports = async function extractTextFromFile({ filepath, filetype }) { case 'application/javascript': return buffer.toString(); default: - throw new Error('Unsupported file type'); + return buffer.toString(); } }; diff --git a/gpt/services/utils.js b/gpt/services/utils.js index bd7845fe274..34b6acba6c2 100644 --- a/gpt/services/utils.js +++ b/gpt/services/utils.js @@ -70,7 +70,6 @@ function parseGptResponse(incoming) { response = response.substring( response.indexOf('__BLOCK_START__') + '__BLOCK_START__'.length ); - console.log('startswith', response); response = response.replace('__BLOCK_START__', ''); } @@ -91,9 +90,8 @@ function parseGptResponse(incoming) { return parsed; } - const cleanedCode = code.split('__BLOCK_END__')[0].trim(); // Ignore everything after the block end + const cleanedCode = body.split('__BLOCK_END__')[0].trim(); // Ignore everything after the block end - console.log('cleanedCode', cleanedCode); console.log(Object.keys(parsed).length, 'files parsed'); return parsed; diff --git a/nx.json b/nx.json index 17d12d50d48..9fa6f8f9768 100644 --- a/nx.json +++ b/nx.json @@ -30,6 +30,26 @@ "production", "^production" ] + }, + "lint": { + "inputs": [ + "default", + "{workspaceRoot}/.eslintrc.json" + ] + }, + "test": { + "inputs": [ + "default", + "^production", + "{workspaceRoot}/jest.preset.js" + ] + }, + "build-storybook": { + "inputs": [ + "default", + "^production", + "!{projectRoot}/.storybook/**/*" + ] } }, "namedInputs": { diff --git a/package-lock.json b/package-lock.json index 94ebc8debed..bc56c4c05c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "core-js": "^3.30.2", "fast-glob": "^3.2.12", "lodash.get": "^4.4.2", - "next": "13.3.1", + "next": "13.4.2", "rambda": "^7.5.0", "react": "18.2.0", "react-dom": "18.2.0", @@ -158,13 +158,13 @@ "antd": "^4.22.3", "js-cookie": "^3.0.1", "lodash": "4.17.21", - "next": "13.3.1", + "next": "13.4.2", "react": "18.2.0", "react-dom": "18.2.0" }, "devDependencies": { "@module-federation/nextjs-mf": "6.6.3", - "@module-federation/utilities": "^1.8.0" + "@module-federation/utilities": "1.9.0" } }, "apps/3001-shop": { @@ -174,7 +174,7 @@ "dependencies": { "antd": "^4.22.3", "lodash": "4.17.21", - "next": "13.3.1", + "next": "13.4.2", "react": "18.2.0", "react-dom": "18.2.0" }, @@ -187,9 +187,9 @@ "version": "1.0.0", "extraneous": true, "dependencies": { - "antd": "4.24.11", + "antd": "4.24.12", "lodash": "4.17.21", - "next": "13.3.1", + "next": "13.4.2", "react": "18.2.0", "react-dom": "18.2.0" }, @@ -202,7 +202,7 @@ "extraneous": true, "devDependencies": { "@module-federation/typescript": "2.3.0", - "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10", + "@pmmmwh/react-refresh-webpack-plugin": "0.5.10", "react-refresh": "0.14.0" } }, @@ -211,7 +211,7 @@ "extraneous": true, "devDependencies": { "@module-federation/typescript": "2.3.0", - "file-loader": "^6.2.0", + "file-loader": "6.2.0", "react-refresh": "0.14.0" } }, @@ -237,6 +237,7 @@ "extraneous": true }, "dist/packages/native-federation-tests": { + "name": "@module-federation/native-federation-tests", "version": "0.2.0", "extraneous": true, "license": "MIT", @@ -250,7 +251,8 @@ } }, "dist/packages/native-federation-typescript": { - "version": "0.2.0", + "name": "@module-federation/native-federation-typescript", + "version": "0.2.2-rc.0", "extraneous": true, "license": "MIT", "dependencies": { @@ -265,69 +267,74 @@ "vue-tsc": "^1.0.24" } }, - "dist/packages/node": { - "name": "@module-federation/node", - "version": "0.14.0", + "dist/packages/nextjs-mf": { + "name": "@module-federation/nextjs-mf", + "version": "6.6.3", "extraneous": true, "license": "MIT", "dependencies": { - "@module-federation/utilities": "1.7.0", - "encoding": "^0.1.13", - "node-fetch": "^2.6.7" + "@module-federation/node": "0.16.1", + "@module-federation/utilities": "1.9.0", + "encoding": "0.1.13", + "eventemitter3": "^5.0.0", + "fast-glob": "^3.2.11", + "node-fetch": "2.6.9", + "webpack-sources": "^3.2.3" }, "peerDependencies": { - "next": "^12||^13", - "react": "^16||^17||^18", - "react-dom": "^16||^17||^18", + "next": "^12 || ^13", + "react": "^17 || ^18", + "react-dom": "^17 || ^18", + "styled-jsx": "*", "webpack": "^5.40.0" }, "peerDependenciesMeta": { - "next": { - "optional": true - }, - "react": { - "optional": true - }, - "react-dom": { + "styled-jsx": { "optional": true } } }, "dist/packages/storybook-addon": { "name": "@module-federation/storybook-addon", - "version": "0.1.0", + "version": "0.2.0", "extraneous": true, "license": "MIT", "dependencies": { - "next": "13.3.1", + "@nx/devkit": "16.2.2", + "@nx/react": "16.2.2", + "next": "13.4.2", + "process": "0.11.10", "react": "18.2.0", "react-dom": "18.2.0" }, "devDependencies": { - "@module-federation/utilities": "1.7.0", - "@storybook/core-common": "^6.5.16", - "@storybook/node-logger": "^6.5.16", + "@module-federation/utilities": "1.8.0", + "@storybook/core-common": "^7.0.0", + "@storybook/node-logger": "^7.0.0", "webpack": "^5.75.0", "webpack-virtual-modules": "^0.5.0" }, "peerDependencies": { - "@module-federation/utilities": "1.7.0", + "@module-federation/utilities": "1.8.0", "@storybook/core-common": "^6.5.16", "@storybook/node-logger": "^6.5.16", "webpack": "^5.75.0", + "webpack-sources": "3.2.3", "webpack-virtual-modules": "^0.5.0" } }, "dist/packages/typescript": { + "name": "@module-federation/typescript", "version": "2.2.3", "extraneous": true, "license": "MIT", "dependencies": { - "@module-federation/utilities": "1.7.0", + "@module-federation/utilities": "1.8.2-rc8.2", "axios": "^1.0.0", "lodash.get": "^4.4.2", - "node-fetch": "2.6.7", - "util": "0.12.5" + "node-fetch": "2.6.9", + "util": "0.11.1", + "webpack-sources": "3.2.3" }, "peerDependencies": { "next": "*", @@ -352,33 +359,6 @@ } } }, - "dist/packages/utilities": { - "name": "@module-federation/utilities", - "version": "1.9.0", - "extraneous": true, - "license": "MIT", - "devDependencies": { - "next": "13.3.1", - "react": "18.2.0" - }, - "peerDependencies": { - "next": "^12 || ^13", - "react": "^16 || ^17 || ^18", - "react-dom": "^16 || ^17 || ^18", - "webpack": "^5.40.0" - }, - "peerDependenciesMeta": { - "next": { - "optional": true - }, - "react": { - "optional": true - }, - "react-dom": { - "optional": true - } - } - }, "node_modules/@alloc/quick-lru": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", @@ -409,6 +389,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/@ant-design/colors/-/colors-6.0.0.tgz", "integrity": "sha512-qAZRvPzfdWHtfameEGP2Qvuf838NhergR35o+EuVyB5XvSA98xod5r4utvi4TJ3ywmevm290g9nsCG5MryrdWQ==", + "license": "MIT", "dependencies": { "@ctrl/tinycolor": "^3.4.0" } @@ -417,6 +398,7 @@ "version": "4.8.0", "resolved": "https://registry.npmjs.org/@ant-design/icons/-/icons-4.8.0.tgz", "integrity": "sha512-T89P2jG2vM7OJ0IfGx2+9FC5sQjtTzRSz+mCHTXkFn/ELZc2YpfStmYHmqzq2Jx55J0F7+O6i5/ZKFSVNWCKNg==", + "license": "MIT", "dependencies": { "@ant-design/colors": "^6.0.0", "@ant-design/icons-svg": "^4.2.1", @@ -435,12 +417,14 @@ "node_modules/@ant-design/icons-svg": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/@ant-design/icons-svg/-/icons-svg-4.2.1.tgz", - "integrity": "sha512-EB0iwlKDGpG93hW8f85CTJTs4SvMX7tt5ceupvhALp1IF44SeUFOMhKUOYqpsoYWQKAOuTRDMqn75rEaKDp0Xw==" + "integrity": "sha512-EB0iwlKDGpG93hW8f85CTJTs4SvMX7tt5ceupvhALp1IF44SeUFOMhKUOYqpsoYWQKAOuTRDMqn75rEaKDp0Xw==", + "license": "MIT" }, "node_modules/@ant-design/react-slick": { "version": "0.29.2", "resolved": "https://registry.npmjs.org/@ant-design/react-slick/-/react-slick-0.29.2.tgz", "integrity": "sha512-kgjtKmkGHa19FW21lHnAfyyH9AAoh35pBdcJ53rHmQ3O+cfFHGHnUbj/HFrRNJ5vIts09FKJVAD8RpaC+RaWfA==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.4", "classnames": "^2.2.5", @@ -3732,6 +3716,7 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-3.6.0.tgz", "integrity": "sha512-/Z3l6pXthq0JvMYdUFyX9j0MaCltlIn6mfh9jLyQwg5aPKxkyNa0PTHtU1AlFXLNk55ZuAeJRcpvq+tmLfKmaQ==", + "license": "MIT", "engines": { "node": ">=10" } @@ -5051,12 +5036,6 @@ "node": "^12.20.0 || ^14.13.1 || >=16.0.0" } }, - "node_modules/@next/env": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/env/-/env-13.3.1.tgz", - "integrity": "sha512-EDtCoedIZC7JlUQ3uaQpSc4aVmyhbLHmQVALg7pFfQgOTjgSnn7mKtA0DiCMkYvvsx6aFb5octGMtWrOtGXW9A==", - "license": "MIT" - }, "node_modules/@next/eslint-plugin-next": { "version": "13.4.1", "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.1.tgz", @@ -5088,142 +5067,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@next/swc-darwin-arm64": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.3.1.tgz", - "integrity": "sha512-UXPtriEc/pBP8luSLSCZBcbzPeVv+SSjs9cH/KygTbhmACye8/OOXRZO13Z2Wq1G0gLmEAIHQAOuF+vafPd2lw==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-darwin-x64": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.3.1.tgz", - "integrity": "sha512-lT36yYxosCfLtplFzJWgo0hrPu6/do8+msgM7oQkPeohDNdhjtjFUgOOwdSnPublLR6Mo2Ym4P/wl5OANuD2bw==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-gnu": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.3.1.tgz", - "integrity": "sha512-wRb76nLWJhonH8s3kxC/1tFguEkeOPayIwe9mkaz1G/yeS3OrjeyKMJsb4+Kdg0zbTo53bNCOl59NNtDM7yyyw==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-musl": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.3.1.tgz", - "integrity": "sha512-qz3BzjJRZ16Iq/jrp+pjiYOc0jTjHlfmxQmZk9x/+5uhRP6/eWQSTAPVJ33BMo6oK5O5N4644OgTAbzXzorecg==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-gnu": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.3.1.tgz", - "integrity": "sha512-6mgkLmwlyWlomQmpl21I3hxgqE5INoW4owTlcLpNsd1V4wP+J46BlI/5zV5KWWbzjfncIqzXoeGs5Eg+1GHODA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-musl": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.3.1.tgz", - "integrity": "sha512-uqm5sielhQmKJM+qayIhgZv1KlS5pqTdQ99b+Z7hMWryXS96qE0DftTmMZowBcUL6x7s2vSXyH5wPtO1ON7LBg==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-arm64-msvc": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.3.1.tgz", - "integrity": "sha512-WomIiTj/v3LevltlibNQKmvrOymNRYL+a0dp5R73IwPWN5FvXWwSELN/kiNALig/+T3luc4qHNTyvMCp9L6U5Q==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-ia32-msvc": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.3.1.tgz", - "integrity": "sha512-M+PoH+0+q658wRUbs285RIaSTYnGBSTdweH/0CdzDgA6Q4rBM0sQs4DHmO3BPP0ltCO/vViIoyG7ks66XmCA5g==", - "cpu": [ - "ia32" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-x64-msvc": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.3.1.tgz", - "integrity": "sha512-Sl1F4Vp5Z1rNXWZYqJwMuWRRol4bqOB6+/d7KqkgQ4AcafKPN1PZmpkCoxv4UFHtFNIB7EotnuIhtXu3zScicQ==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, "node_modules/@node-rs/jieba": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@node-rs/jieba/-/jieba-1.7.0.tgz", @@ -5332,6 +5175,42 @@ "@nx/eslint-plugin": "16.2.2" } }, + "node_modules/@nrwl/jest": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/jest/-/jest-16.2.2.tgz", + "integrity": "sha512-UEd6Vgcrr/IPG+lJBCoKgPtYwbYe1qiUM5bfP96i0eX3aPqKpzTR3WmHND9AMU6agNBO7r/24rfwPaUG1yx+9A==", + "dev": true, + "dependencies": { + "@nx/jest": "16.2.2" + } + }, + "node_modules/@nrwl/js": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/js/-/js-16.2.2.tgz", + "integrity": "sha512-UBcrwd+84EkZxi5YWRlvhz2+Sg7Nsl3CopwnO5JpxU0oGySZnpvN6umI9aHuBJ4yh1dkyqvaXJuAX3slT1pjvw==", + "dev": true, + "dependencies": { + "@nx/js": "16.2.2" + } + }, + "node_modules/@nrwl/linter": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/linter/-/linter-16.2.2.tgz", + "integrity": "sha512-xTDYrWOvrp8jp5KlSXLe+jrKIxcfm/qY9DojV4kGkPgVGGL4Veu5SgpW4BIaD1wYvceKsVPDZ9mRKJcJShq8AQ==", + "dev": true, + "dependencies": { + "@nx/linter": "16.2.2" + } + }, + "node_modules/@nrwl/next": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/next/-/next-16.2.2.tgz", + "integrity": "sha512-gkBSZXb2cdUf5sPS0k/+BzSboriHEsFih6pJ5FcCLt6NcfLcOPHn+FZcpn/8hBQMyUr+mzpWzXk32ALR8MROvQ==", + "dev": true, + "dependencies": { + "@nx/next": "16.2.2" + } + }, "node_modules/@nrwl/react": { "version": "16.2.2", "resolved": "https://registry.npmjs.org/@nrwl/react/-/react-16.2.2.tgz", @@ -5341,6 +5220,15 @@ "@nx/react": "16.2.2" } }, + "node_modules/@nrwl/storybook": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/storybook/-/storybook-16.2.2.tgz", + "integrity": "sha512-JRyo/JTT8IdUsk6QbT7cxuxYjkQo1sS3lXMdiIeniYWC694DCsurRrWLMfRSx01Z4rm6L3ZgRxDjLhse5MVRhg==", + "dev": true, + "dependencies": { + "@nx/storybook": "16.2.2" + } + }, "node_modules/@nrwl/tao": { "version": "16.2.2", "resolved": "https://registry.npmjs.org/@nrwl/tao/-/tao-16.2.2.tgz", @@ -5362,6 +5250,24 @@ "@nx/vite": "16.2.2" } }, + "node_modules/@nrwl/web": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/web/-/web-16.2.2.tgz", + "integrity": "sha512-A0SlEY0jn55mUxd4zJdXNJzxiXLI9OX0/tRPCVHz4f6y81BIApsvAyG8D9fgCNNc2hAFVztrbkWR0cL5mDDQXA==", + "dev": true, + "dependencies": { + "@nx/web": "16.2.2" + } + }, + "node_modules/@nrwl/webpack": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/webpack/-/webpack-16.2.2.tgz", + "integrity": "sha512-tv3Ul843wMcuq3jGWdqVmjxktLJ/cvB1WTyMmgqTRaRYcqK+wDP+0ziQCgN/sLqKidOyelA2ZyNdx3K/RweEjw==", + "dev": true, + "dependencies": { + "@nx/webpack": "16.2.2" + } + }, "node_modules/@nrwl/workspace": { "version": "16.2.2", "resolved": "https://registry.npmjs.org/@nrwl/workspace/-/workspace-16.2.2.tgz", @@ -5547,8 +5453,8 @@ "dependencies": { "@jest/reporters": "^29.4.1", "@jest/test-result": "^29.4.1", + "@nrwl/jest": "16.2.2", "@nx/devkit": "16.2.2", - "@nx/jest": "16.2.2", "@nx/js": "16.2.2", "@phenomnomnominal/tsquery": "~5.0.1", "chalk": "^4.1.0", @@ -5574,8 +5480,8 @@ "@babel/preset-env": "^7.15.0", "@babel/preset-typescript": "^7.15.0", "@babel/runtime": "^7.14.8", + "@nrwl/js": "16.2.2", "@nx/devkit": "16.2.2", - "@nx/js": "16.2.2", "@nx/workspace": "16.2.2", "@phenomnomnominal/tsquery": "~5.0.1", "babel-plugin-const-enum": "^1.0.1", @@ -5664,9 +5570,9 @@ "integrity": "sha512-bJVxDSurtknamhhfrdntXWbWDCmzEaGEabliAK8bBeieqj3VrE69oy+yvSLHf29lJdg+rzB6os3wm/1xBHAzvg==", "dev": true, "dependencies": { + "@nrwl/linter": "16.2.2", "@nx/devkit": "16.2.2", "@nx/js": "16.2.2", - "@nx/linter": "16.2.2", "@phenomnomnominal/tsquery": "~5.0.1", "tmp": "~0.2.1", "tslib": "^2.3.0" @@ -5687,10 +5593,10 @@ "dev": true, "dependencies": { "@babel/plugin-proposal-decorators": "^7.14.5", + "@nrwl/next": "16.2.2", "@nx/devkit": "16.2.2", "@nx/js": "16.2.2", "@nx/linter": "16.2.2", - "@nx/next": "16.2.2", "@nx/react": "16.2.2", "@nx/workspace": "16.2.2", "@svgr/webpack": "^6.1.2", @@ -6395,11 +6301,11 @@ "integrity": "sha512-4MZaLW81otbvSEJpp3k9MTYFz3yo8xvfJ3BiuOYJ4UreeTwf683MqV6/FL9vS2viY4UWQu/nR0ir4tOdf5h7Rw==", "dev": true, "dependencies": { + "@nrwl/storybook": "16.2.2", "@nx/cypress": "16.2.2", "@nx/devkit": "16.2.2", "@nx/js": "16.2.2", "@nx/linter": "16.2.2", - "@nx/storybook": "16.2.2", "@nx/workspace": "16.2.2", "@phenomnomnominal/tsquery": "~5.0.1", "dotenv": "~10.0.0", @@ -6465,9 +6371,9 @@ "integrity": "sha512-pxUBSBjImaDalh9GdIRUO23t02XEaMcu1M+QBfj4YArAgdjEN3hkIuTpJkxPufNMvZNHGQe8LudNa2Skp+mW0Q==", "dev": true, "dependencies": { + "@nrwl/web": "16.2.2", "@nx/devkit": "16.2.2", "@nx/js": "16.2.2", - "@nx/web": "16.2.2", "chalk": "^4.1.0", "chokidar": "^3.5.1", "http-server": "^14.1.0", @@ -6482,9 +6388,9 @@ "dev": true, "dependencies": { "@babel/core": "^7.15.0", + "@nrwl/webpack": "16.2.2", "@nx/devkit": "16.2.2", "@nx/js": "16.2.2", - "@nx/webpack": "16.2.2", "autoprefixer": "^10.4.9", "babel-loader": "^9.1.2", "chalk": "^4.1.0", @@ -12059,7 +11965,6 @@ "version": "0.5.1", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.1.tgz", "integrity": "sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==", - "dev": true, "license": "Apache-2.0", "dependencies": { "tslib": "^2.4.0" @@ -13257,17 +13162,6 @@ "url": "https://opencollective.com/verdaccio" } }, - "node_modules/@verdaccio/core/node_modules/core-js": { - "version": "3.30.2", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.30.2.tgz", - "integrity": "sha512-uBJiDmwqsbJCWHAwjrx3cvjbMXP7xD72Dmsn5LOJpiRmE3WbBbN5rCqQ2Qh6Ek6/eOrjlWngEynBWo4VxerQhg==", - "dev": true, - "hasInstallScript": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, "node_modules/@verdaccio/core/node_modules/process-warning": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", @@ -14605,17 +14499,16 @@ "react-dom": ">=16.9.0" } }, - "node_modules/antd/node_modules/rc-field-form": { - "version": "1.34.0", - "resolved": "https://registry.npmjs.org/rc-field-form/-/rc-field-form-1.34.0.tgz", - "integrity": "sha512-soGJulqlQq5u7PY0FiG1tz6G3NgXFNGEWfJjSQAzStsbxoxnP9CRETzQ8oI9fIAuXwI8eReEZxyqqMpwL0xEfw==", + "node_modules/antd/node_modules/rc-drawer": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/rc-drawer/-/rc-drawer-6.3.0.tgz", + "integrity": "sha512-uBZVb3xTAR+dBV53d/bUhTctCw3pwcwJoM7g5aX+7vgwt2zzVzoJ6aqFjYJpBlZ9zp0dVYN8fV+hykFE7c4lig==", "dependencies": { - "@babel/runtime": "^7.18.0", - "async-validator": "^4.1.0", - "rc-util": "^5.32.2" - }, - "engines": { - "node": ">=8.x" + "@babel/runtime": "^7.10.1", + "@rc-component/portal": "^1.1.1", + "classnames": "^2.2.6", + "rc-motion": "^2.6.1", + "rc-util": "^5.21.2" }, "peerDependencies": { "react": ">=16.9.0", @@ -14841,7 +14734,8 @@ "node_modules/array-tree-filter": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-tree-filter/-/array-tree-filter-2.1.0.tgz", - "integrity": "sha512-4ROwICNlNw/Hqa9v+rk5h22KjmzB1JGTMVKP2AKJBOCgb0yL0ASf0+YvCcLNNwquOHNX48jkeZIJ3a+oOQqKcw==" + "integrity": "sha512-4ROwICNlNw/Hqa9v+rk5h22KjmzB1JGTMVKP2AKJBOCgb0yL0ASf0+YvCcLNNwquOHNX48jkeZIJ3a+oOQqKcw==", + "license": "MIT" }, "node_modules/array-union": { "version": "2.1.0", @@ -17038,7 +16932,8 @@ "node_modules/classnames": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz", - "integrity": "sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==" + "integrity": "sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==", + "license": "MIT" }, "node_modules/clean-css": { "version": "5.3.2", @@ -17714,7 +17609,8 @@ "node_modules/compute-scroll-into-view": { "version": "1.0.20", "resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-1.0.20.tgz", - "integrity": "sha512-UCB0ioiyj8CRjtrvaceBLqqhZCVP+1B8+NWQhmdsm0VXOJtobBCf1dBQmebCCo34qZmUwZfIH2MZLqNHazrfjg==" + "integrity": "sha512-UCB0ioiyj8CRjtrvaceBLqqhZCVP+1B8+NWQhmdsm0VXOJtobBCf1dBQmebCCo34qZmUwZfIH2MZLqNHazrfjg==", + "license": "MIT" }, "node_modules/concat-map": { "version": "0.0.1", @@ -18290,6 +18186,7 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.3.tgz", "integrity": "sha512-2KV8NhB5JqC3ky0r9PMCAZKbUHSwtEo4CwCs0KXgruG43gX5PMqDEBbVU4OUzw2MuAWUfsuFmWvEKG5QRfSnJA==", + "license": "MIT", "dependencies": { "toggle-selection": "^1.0.6" } @@ -18375,10 +18272,11 @@ } }, "node_modules/core-js": { - "version": "3.31.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.31.0.tgz", - "integrity": "sha512-NIp2TQSGfR6ba5aalZD+ZQ1fSxGhDo/s1w0nx3RYzf2pnJxt7YynxFlFScP6eV7+GZsKO95NSjGxyJsU3DZgeQ==", + "version": "3.30.2", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.30.2.tgz", + "integrity": "sha512-uBJiDmwqsbJCWHAwjrx3cvjbMXP7xD72Dmsn5LOJpiRmE3WbBbN5rCqQ2Qh6Ek6/eOrjlWngEynBWo4VxerQhg==", "hasInstallScript": true, + "license": "MIT", "funding": { "type": "opencollective", "url": "https://opencollective.com/core-js" @@ -19682,7 +19580,8 @@ "node_modules/dom-align": { "version": "1.12.4", "resolved": "https://registry.npmjs.org/dom-align/-/dom-align-1.12.4.tgz", - "integrity": "sha512-R8LUSEay/68zE5c8/3BDxiTEvgb4xZTF0RKmAHfiEVN3klfIpXfi2/QCoiWPccVQ0J/ZGdz9OjzL4uJEP/MRAw==" + "integrity": "sha512-R8LUSEay/68zE5c8/3BDxiTEvgb4xZTF0RKmAHfiEVN3klfIpXfi2/QCoiWPccVQ0J/ZGdz9OjzL4uJEP/MRAw==", + "license": "MIT" }, "node_modules/dom-converter": { "version": "0.2.0", @@ -21542,8 +21441,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/esutils": { "version": "2.0.3", @@ -27327,6 +27225,7 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/json2mq/-/json2mq-0.2.0.tgz", "integrity": "sha512-SzoRg7ux5DWTII9J2qkrZrqV1gt+rTaoufMxEzXbS26Uid0NwaJd123HcoB80TgubEppxxIGdNxCx50fEoEWQA==", + "license": "MIT", "dependencies": { "string-convert": "^0.2.0" } @@ -30363,6 +30262,7 @@ "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "license": "MIT", "engines": { "node": "*" } @@ -30687,33 +30587,34 @@ "license": "MIT" }, "node_modules/next": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/next/-/next-13.3.1.tgz", - "integrity": "sha512-eByWRxPzKHs2oQz1yE41LX35umhz86ZSZ+mYyXBqn2IBi2hyUqxBA88avywdr4uyH+hCJczegGsDGWbzQA5Rqw==", + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/next/-/next-13.4.2.tgz", + "integrity": "sha512-aNFqLs3a3nTGvLWlO9SUhCuMUHVPSFQC0+tDNGAsDXqx+WJDFSbvc233gOJ5H19SBc7nw36A9LwQepOJ2u/8Kg==", "dependencies": { - "@next/env": "13.3.1", - "@swc/helpers": "0.5.0", + "@next/env": "13.4.2", + "@swc/helpers": "0.5.1", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", "postcss": "8.4.14", - "styled-jsx": "5.1.1" + "styled-jsx": "5.1.1", + "zod": "3.21.4" }, "bin": { "next": "dist/bin/next" }, "engines": { - "node": ">=14.18.0" + "node": ">=16.8.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "13.3.1", - "@next/swc-darwin-x64": "13.3.1", - "@next/swc-linux-arm64-gnu": "13.3.1", - "@next/swc-linux-arm64-musl": "13.3.1", - "@next/swc-linux-x64-gnu": "13.3.1", - "@next/swc-linux-x64-musl": "13.3.1", - "@next/swc-win32-arm64-msvc": "13.3.1", - "@next/swc-win32-ia32-msvc": "13.3.1", - "@next/swc-win32-x64-msvc": "13.3.1" + "@next/swc-darwin-arm64": "13.4.2", + "@next/swc-darwin-x64": "13.4.2", + "@next/swc-linux-arm64-gnu": "13.4.2", + "@next/swc-linux-arm64-musl": "13.4.2", + "@next/swc-linux-x64-gnu": "13.4.2", + "@next/swc-linux-x64-musl": "13.4.2", + "@next/swc-win32-arm64-msvc": "13.4.2", + "@next/swc-win32-ia32-msvc": "13.4.2", + "@next/swc-win32-x64-msvc": "13.4.2" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", @@ -30738,12 +30639,144 @@ } } }, - "node_modules/next/node_modules/@swc/helpers": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.0.tgz", - "integrity": "sha512-SjY/p4MmECVVEWspzSRpQEM3sjR17sP8PbGxELWrT+YZMBfiUyt1MRUNjMV23zohwlG2HYtCQOsCwsTHguXkyg==", - "dependencies": { - "tslib": "^2.4.0" + "node_modules/next/node_modules/@next/env": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.2.tgz", + "integrity": "sha512-Wqvo7lDeS0KGwtwg9TT9wKQ8raelmUxt+TQKWvG/xKfcmDXNOtCuaszcfCF8JzlBG1q0VhpI6CKaRMbVPMDWgw==" + }, + "node_modules/next/node_modules/@next/swc-darwin-arm64": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.2.tgz", + "integrity": "sha512-6BBlqGu3ewgJflv9iLCwO1v1hqlecaIH2AotpKfVUEzUxuuDNJQZ2a4KLb4MBl8T9/vca1YuWhSqtbF6ZuUJJw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/next/node_modules/@next/swc-darwin-x64": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.2.tgz", + "integrity": "sha512-iZuYr7ZvGLPjPmfhhMl0ISm+z8EiyLBC1bLyFwGBxkWmPXqdJ60mzuTaDSr5WezDwv0fz32HB7JHmRC6JVHSZg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/next/node_modules/@next/swc-linux-arm64-gnu": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.2.tgz", + "integrity": "sha512-2xVabFtIge6BJTcJrW8YuUnYTuQjh4jEuRuS2mscyNVOj6zUZkom3CQg+egKOoS+zh2rrro66ffSKIS+ztFJTg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/next/node_modules/@next/swc-linux-arm64-musl": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.2.tgz", + "integrity": "sha512-wKRCQ27xCUJx5d6IivfjYGq8oVngqIhlhSAJntgXLt7Uo9sRT/3EppMHqUZRfyuNBTbykEre1s5166z+pvRB5A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/next/node_modules/@next/swc-linux-x64-gnu": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.2.tgz", + "integrity": "sha512-NpCa+UVhhuNeaFVUP1Bftm0uqtvLWq2JTm7+Ta48+2Uqj2mNXrDIvyn1DY/ZEfmW/1yvGBRaUAv9zkMkMRixQA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/next/node_modules/@next/swc-linux-x64-musl": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.2.tgz", + "integrity": "sha512-ZWVC72x0lW4aj44e3khvBrj2oSYj1bD0jESmyah3zG/3DplEy/FOtYkMzbMjHTdDSheso7zH8GIlW6CDQnKhmQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/next/node_modules/@next/swc-win32-arm64-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.2.tgz", + "integrity": "sha512-pLT+OWYpzJig5K4VKhLttlIfBcVZfr2+Xbjra0Tjs83NQSkFS+y7xx+YhCwvpEmXYLIvaggj2ONPyjbiigOvHQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/next/node_modules/@next/swc-win32-ia32-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.2.tgz", + "integrity": "sha512-dhpiksQCyGca4WY0fJyzK3FxMDFoqMb0Cn+uDB+9GYjpU2K5//UGPQlCwiK4JHxuhg8oLMag5Nf3/IPSJNG8jw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/next/node_modules/@next/swc-win32-x64-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.2.tgz", + "integrity": "sha512-O7bort1Vld00cu8g0jHZq3cbSTUNMohOEvYqsqE10+yfohhdPHzvzO+ziJRz4Dyyr/fYKREwS7gR4JC0soSOMw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" } }, "node_modules/next/node_modules/postcss": { @@ -34106,6 +34139,7 @@ "version": "4.0.15", "resolved": "https://registry.npmjs.org/rc-align/-/rc-align-4.0.15.tgz", "integrity": "sha512-wqJtVH60pka/nOX7/IspElA8gjPNQKIx/ZqJ6heATCkXpe1Zg4cPVrMD2vC96wjsFFL8WsmhPbx9tdMo1qqlIA==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "2.x", @@ -34119,9 +34153,8 @@ } }, "node_modules/rc-cascader": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/rc-cascader/-/rc-cascader-3.7.2.tgz", - "integrity": "sha512-5nPEM76eMyikd0NFiy1gjwiB9m+bOzjY6Lnd5bVC6Ar3XLlOpOnlCcV3oBFWLN3f7B18tAGpaAVlT2uyEDCv9w==", + "version": "3.7.0", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.12.5", "array-tree-filter": "^2.1.0", @@ -34136,9 +34169,8 @@ } }, "node_modules/rc-checkbox": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/rc-checkbox/-/rc-checkbox-3.0.1.tgz", - "integrity": "sha512-k7nxDWxYF+jDI0ZcCvuvj71xONmWRVe5+1MKcERRR9MRyP3tZ69b+yUCSXXh+sik4/Hc9P5wHr2nnUoGS2zBjA==", + "version": "3.0.0", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.3.2", @@ -34153,6 +34185,7 @@ "version": "3.4.2", "resolved": "https://registry.npmjs.org/rc-collapse/-/rc-collapse-3.4.2.tgz", "integrity": "sha512-jpTwLgJzkhAgp2Wpi3xmbTbbYExg6fkptL67Uu5LCRVEj6wqmy0DHTjjeynsjOLsppHGHu41t1ELntZ0lEvS/Q==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "2.x", @@ -34169,6 +34202,7 @@ "version": "9.0.2", "resolved": "https://registry.npmjs.org/rc-dialog/-/rc-dialog-9.0.2.tgz", "integrity": "sha512-s3U+24xWUuB6Bn2Lk/Qt6rufy+uT+QvWkiFhNBcO9APLxcFFczWamaq7x9h8SCuhfc1nHcW4y8NbMsnAjNnWyg==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "@rc-component/portal": "^1.0.0-8", @@ -34181,26 +34215,11 @@ "react-dom": ">=16.9.0" } }, - "node_modules/rc-drawer": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/rc-drawer/-/rc-drawer-6.3.0.tgz", - "integrity": "sha512-uBZVb3xTAR+dBV53d/bUhTctCw3pwcwJoM7g5aX+7vgwt2zzVzoJ6aqFjYJpBlZ9zp0dVYN8fV+hykFE7c4lig==", - "dependencies": { - "@babel/runtime": "^7.10.1", - "@rc-component/portal": "^1.1.1", - "classnames": "^2.2.6", - "rc-motion": "^2.6.1", - "rc-util": "^5.21.2" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, "node_modules/rc-dropdown": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/rc-dropdown/-/rc-dropdown-4.0.1.tgz", "integrity": "sha512-OdpXuOcme1rm45cR0Jzgfl1otzmU4vuBVb+etXM8vcaULGokAKVpKlw8p6xzspG7jGd/XxShvq+N3VNEfk/l5g==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.18.3", "classnames": "^2.2.6", @@ -34212,10 +34231,28 @@ "react-dom": ">=16.11.0" } }, + "node_modules/rc-field-form": { + "version": "1.34.0", + "resolved": "https://registry.npmjs.org/rc-field-form/-/rc-field-form-1.34.0.tgz", + "integrity": "sha512-soGJulqlQq5u7PY0FiG1tz6G3NgXFNGEWfJjSQAzStsbxoxnP9CRETzQ8oI9fIAuXwI8eReEZxyqqMpwL0xEfw==", + "dependencies": { + "@babel/runtime": "^7.18.0", + "async-validator": "^4.1.0", + "rc-util": "^5.32.2" + }, + "engines": { + "node": ">=8.x" + }, + "peerDependencies": { + "react": ">=16.9.0", + "react-dom": ">=16.9.0" + } + }, "node_modules/rc-image": { "version": "5.13.0", "resolved": "https://registry.npmjs.org/rc-image/-/rc-image-5.13.0.tgz", "integrity": "sha512-iZTOmw5eWo2+gcrJMMcnd7SsxVHl3w5xlyCgsULUdJhJbnuI8i/AL0tVOsE7aLn9VfOh1qgDT3mC2G75/c7mqg==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.11.2", "@rc-component/portal": "^1.0.2", @@ -34233,6 +34270,7 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/rc-input/-/rc-input-0.1.4.tgz", "integrity": "sha512-FqDdNz+fV2dKNgfXzcSLKvC+jEs1709t7nD+WdfjrdSaOcefpgc7BUJYadc3usaING+b7ediMTfKxuJBsEFbXA==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.11.1", "classnames": "^2.2.1", @@ -34247,6 +34285,7 @@ "version": "7.3.11", "resolved": "https://registry.npmjs.org/rc-input-number/-/rc-input-number-7.3.11.tgz", "integrity": "sha512-aMWPEjFeles6PQnMqP5eWpxzsvHm9rh1jQOWXExUEIxhX62Fyl/ptifLHOn17+waDG1T/YUb6flfJbvwRhHrbA==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.5", @@ -34261,6 +34300,7 @@ "version": "1.13.1", "resolved": "https://registry.npmjs.org/rc-mentions/-/rc-mentions-1.13.1.tgz", "integrity": "sha512-FCkaWw6JQygtOz0+Vxz/M/NWqrWHB9LwqlY2RtcuFqWJNFK9njijOOzTSsBGANliGufVUzx/xuPHmZPBV0+Hgw==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.6", @@ -34275,9 +34315,8 @@ } }, "node_modules/rc-menu": { - "version": "9.8.4", - "resolved": "https://registry.npmjs.org/rc-menu/-/rc-menu-9.8.4.tgz", - "integrity": "sha512-lmw2j8I2fhdIzHmC9ajfImfckt0WDb2KVJJBBRIsxPEw2kGkEfjLMUoB1NgiNT/Q5cC8PdjGOGQjHJIJMwyNMw==", + "version": "9.8.2", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "2.x", @@ -34292,9 +34331,8 @@ } }, "node_modules/rc-motion": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/rc-motion/-/rc-motion-2.7.3.tgz", - "integrity": "sha512-2xUvo8yGHdOHeQbdI8BtBsCIrWKchEmFEIskf0nmHtJsou+meLd/JE+vnvSX2JxcBrJtXY2LuBpxAOxrbY/wMQ==", + "version": "2.6.3", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.11.1", "classnames": "^2.2.1", @@ -34309,6 +34347,7 @@ "version": "4.6.1", "resolved": "https://registry.npmjs.org/rc-notification/-/rc-notification-4.6.1.tgz", "integrity": "sha512-NSmFYwrrdY3+un1GvDAJQw62Xi9LNMSsoQyo95tuaYrcad5Bn9gJUL8AREufRxSQAQnr64u3LtP3EUyLYT6bhw==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "2.x", @@ -34324,9 +34363,8 @@ } }, "node_modules/rc-overflow": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/rc-overflow/-/rc-overflow-1.3.1.tgz", - "integrity": "sha512-RY0nVBlfP9CkxrpgaLlGzkSoh9JhjJLu6Icqs9E7CW6Ewh9s0peF9OHIex4OhfoPsR92LR0fN6BlCY9Z4VoUtA==", + "version": "1.2.8", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.11.1", "classnames": "^2.2.1", @@ -34342,6 +34380,7 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/rc-pagination/-/rc-pagination-3.2.0.tgz", "integrity": "sha512-5tIXjB670WwwcAJzAqp2J+cOBS9W3cH/WU1EiYwXljuZ4vtZXKlY2Idq8FZrnYBz8KhN3vwPo9CoV/SJS6SL1w==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.1" @@ -34352,9 +34391,8 @@ } }, "node_modules/rc-picker": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/rc-picker/-/rc-picker-2.7.2.tgz", - "integrity": "sha512-KbUKgbzgWVN5L+V9xhZDKSmseHIyFneBlmuMtMrZ9fU7Oypw6D+owS5kuUicIEV08Y17oXt8dUqauMeC5IFBPg==", + "version": "2.7.0", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.1", @@ -34374,9 +34412,10 @@ } }, "node_modules/rc-progress": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/rc-progress/-/rc-progress-3.4.2.tgz", - "integrity": "sha512-iAGhwWU+tsayP+Jkl9T4+6rHeQTG9kDz8JAHZk4XtQOcYN5fj9H34NXNEdRdZx94VUDHMqCb1yOIvi8eJRh67w==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/rc-progress/-/rc-progress-3.4.1.tgz", + "integrity": "sha512-eAFDHXlk8aWpoXl0llrenPMt9qKHQXphxcVsnKs0FHC6eCSk1ebJtyaVjJUzKe0233ogiLDeEFK1Uihz3s67hw==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.6", @@ -34391,6 +34430,7 @@ "version": "2.9.2", "resolved": "https://registry.npmjs.org/rc-rate/-/rc-rate-2.9.2.tgz", "integrity": "sha512-SaiZFyN8pe0Fgphv8t3+kidlej+cq/EALkAJAc3A0w0XcPaH2L1aggM8bhe1u6GAGuQNAoFvTLjw4qLPGRKV5g==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.5", @@ -34408,6 +34448,7 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/rc-resize-observer/-/rc-resize-observer-1.3.1.tgz", "integrity": "sha512-iFUdt3NNhflbY3mwySv5CA1TC06zdJ+pfo0oc27xpf4PIOvfZwZGtD9Kz41wGYqC4SLio93RVAirSSpYlV/uYg==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.7", "classnames": "^2.2.1", @@ -34423,6 +34464,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/rc-segmented/-/rc-segmented-2.1.2.tgz", "integrity": "sha512-qGo1bCr83ESXpXVOCXjFe1QJlCAQXyi9KCiy8eX3rIMYlTeJr/ftySIaTnYsitL18SvWf5ZEHsfqIWoX0EMfFQ==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.11.1", "classnames": "^2.2.1", @@ -34438,6 +34480,7 @@ "version": "14.1.17", "resolved": "https://registry.npmjs.org/rc-select/-/rc-select-14.1.17.tgz", "integrity": "sha512-6qQhMqtoUkkboRqXKKFRR5Nu1mrnw2mC1uxIBIczg7aiJ94qCZBg4Ww8OLT9f4xdyCgbFSGh6r3yB9EBsjoHGA==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "2.x", @@ -34459,6 +34502,7 @@ "version": "10.0.1", "resolved": "https://registry.npmjs.org/rc-slider/-/rc-slider-10.0.1.tgz", "integrity": "sha512-igTKF3zBet7oS/3yNiIlmU8KnZ45npmrmHlUUio8PNbIhzMcsh+oE/r2UD42Y6YD2D/s+kzCQkzQrPD6RY435Q==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.5", @@ -34477,6 +34521,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/rc-steps/-/rc-steps-5.0.0.tgz", "integrity": "sha512-9TgRvnVYirdhbV0C3syJFj9EhCRqoJAsxt4i1rED5o8/ZcSv5TLIYyo4H8MCjLPvbe2R+oBAm/IYBEtC+OS1Rw==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.16.7", "classnames": "^2.2.3", @@ -34494,6 +34539,7 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/rc-switch/-/rc-switch-3.2.2.tgz", "integrity": "sha512-+gUJClsZZzvAHGy1vZfnwySxj+MjLlGRyXKXScrtCTcmiYNPzxDFOxdQ/3pK1Kt/0POvwJ/6ALOR8gwdXGhs+A==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.1", @@ -34508,6 +34554,7 @@ "version": "7.26.0", "resolved": "https://registry.npmjs.org/rc-table/-/rc-table-7.26.0.tgz", "integrity": "sha512-0cD8e6S+DTGAt5nBZQIPFYEaIukn17sfa5uFL98faHlH/whZzD8ii3dbFL4wmUDEL4BLybhYop+QUfZJ4CPvNQ==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.5", @@ -34524,9 +34571,8 @@ } }, "node_modules/rc-tabs": { - "version": "12.5.10", - "resolved": "https://registry.npmjs.org/rc-tabs/-/rc-tabs-12.5.10.tgz", - "integrity": "sha512-Ay0l0jtd4eXepFH9vWBvinBjqOpqzcsJTerBGwJy435P2S90Uu38q8U/mvc1sxUEVOXX5ZCFbxcWPnfG3dH+tQ==", + "version": "12.5.7", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.11.2", "classnames": "2.x", @@ -34548,6 +34594,7 @@ "version": "0.4.7", "resolved": "https://registry.npmjs.org/rc-textarea/-/rc-textarea-0.4.7.tgz", "integrity": "sha512-IQPd1CDI3mnMlkFyzt2O4gQ2lxUsnBAeJEoZGJnkkXgORNqyM9qovdrCj9NzcRfpHgLdzaEbU3AmobNFGUznwQ==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.1", @@ -34564,6 +34611,7 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/rc-tooltip/-/rc-tooltip-5.2.2.tgz", "integrity": "sha512-jtQzU/18S6EI3lhSGoDYhPqNpWajMtS5VV/ld1LwyfrDByQpYmw/LW6U7oFXXLukjfDHQ7Ju705A82PRNFWYhg==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.11.2", "classnames": "^2.3.1", @@ -34575,15 +34623,14 @@ } }, "node_modules/rc-tree": { - "version": "5.7.6", - "resolved": "https://registry.npmjs.org/rc-tree/-/rc-tree-5.7.6.tgz", - "integrity": "sha512-Dzam4VFcohXfcw+K4syq177RKqdqYun1XRc6etAEpRvsTruo4udhcsPrsEfOrRkrhnmkO58Q9F1/lgvm2dznVQ==", + "version": "5.7.2", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "2.x", "rc-motion": "^2.0.1", "rc-util": "^5.16.1", - "rc-virtual-list": "^3.5.1" + "rc-virtual-list": "^3.4.8" }, "engines": { "node": ">=10.x" @@ -34597,6 +34644,7 @@ "version": "5.5.5", "resolved": "https://registry.npmjs.org/rc-tree-select/-/rc-tree-select-5.5.5.tgz", "integrity": "sha512-k2av7jF6tW9bIO4mQhaVdV4kJ1c54oxV3/hHVU+oD251Gb5JN+m1RbJFTMf1o0rAFqkvto33rxMdpafaGKQRJw==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "2.x", @@ -34613,6 +34661,7 @@ "version": "5.3.4", "resolved": "https://registry.npmjs.org/rc-trigger/-/rc-trigger-5.3.4.tgz", "integrity": "sha512-mQv+vas0TwKcjAO2izNPkqR4j86OemLRmvL2nOzdP9OWNWA1ivoTt5hzFqYNW9zACwmTezRiN8bttrC7cZzYSw==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.18.3", "classnames": "^2.2.6", @@ -34632,6 +34681,7 @@ "version": "4.3.4", "resolved": "https://registry.npmjs.org/rc-upload/-/rc-upload-4.3.4.tgz", "integrity": "sha512-uVbtHFGNjHG/RyAfm9fluXB6pvArAGyAx8z7XzXXyorEgVIWj6mOlriuDm0XowDHYz4ycNK0nE0oP3cbFnzxiQ==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.18.3", "classnames": "^2.2.5", @@ -34658,12 +34708,12 @@ "node_modules/rc-util/node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "license": "MIT" }, "node_modules/rc-virtual-list": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/rc-virtual-list/-/rc-virtual-list-3.5.2.tgz", - "integrity": "sha512-sE2G9hTPjVmatQni8OP2Kx33+Oth6DMKm67OblBBmgMBJDJQOOFpSGH7KZ6Pm85rrI2IGxDRXZCr0QhYOH2pfQ==", + "version": "3.4.13", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.0", "classnames": "^2.2.6", @@ -35515,7 +35565,8 @@ "node_modules/resize-observer-polyfill": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", - "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==" + "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==", + "license": "MIT" }, "node_modules/resolve": { "version": "1.22.2", @@ -35988,6 +36039,7 @@ "version": "2.2.31", "resolved": "https://registry.npmjs.org/scroll-into-view-if-needed/-/scroll-into-view-if-needed-2.2.31.tgz", "integrity": "sha512-dGCXy99wZQivjmjIqihaBQNjryrz5rueJY7eHfTdyWEiR4ttYpsajb14rn9s5d4DY4EcY6+4+U/maARBXJedkA==", + "license": "MIT", "dependencies": { "compute-scroll-into-view": "^1.0.20" } @@ -36377,7 +36429,8 @@ "node_modules/shallowequal": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz", - "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==" + "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==", + "license": "MIT" }, "node_modules/sharp": { "version": "0.32.1", @@ -37484,7 +37537,8 @@ "node_modules/string-convert": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/string-convert/-/string-convert-0.2.1.tgz", - "integrity": "sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==" + "integrity": "sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==", + "license": "MIT" }, "node_modules/string-length": { "version": "4.0.2", @@ -38835,7 +38889,8 @@ "node_modules/toggle-selection": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", - "integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==" + "integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==", + "license": "MIT" }, "node_modules/toidentifier": { "version": "1.0.1", @@ -39339,6 +39394,7 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0-beta.0.tgz", "integrity": "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "whatwg-url": "^7.0.0" }, @@ -39351,6 +39407,7 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", "dev": true, + "license": "MIT", "dependencies": { "punycode": "^2.1.0" } @@ -39359,13 +39416,15 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", - "dev": true + "dev": true, + "license": "BSD-2-Clause" }, "node_modules/tsup/node_modules/whatwg-url": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", "dev": true, + "license": "MIT", "dependencies": { "lodash.sortby": "^4.7.0", "tr46": "^1.0.1", @@ -40566,17 +40625,6 @@ "url": "https://opencollective.com/verdaccio" } }, - "node_modules/verdaccio-htpasswd/node_modules/core-js": { - "version": "3.30.2", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.30.2.tgz", - "integrity": "sha512-uBJiDmwqsbJCWHAwjrx3cvjbMXP7xD72Dmsn5LOJpiRmE3WbBbN5rCqQ2Qh6Ek6/eOrjlWngEynBWo4VxerQhg==", - "dev": true, - "hasInstallScript": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, "node_modules/verdaccio/node_modules/body-parser": { "version": "1.20.2", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", @@ -42425,7 +42473,6 @@ "version": "3.21.4", "resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz", "integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" @@ -42441,6 +42488,141 @@ "type": "github", "url": "https://github.com/sponsors/wooorm" } + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.2.tgz", + "integrity": "sha512-6BBlqGu3ewgJflv9iLCwO1v1hqlecaIH2AotpKfVUEzUxuuDNJQZ2a4KLb4MBl8T9/vca1YuWhSqtbF6ZuUJJw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.2.tgz", + "integrity": "sha512-iZuYr7ZvGLPjPmfhhMl0ISm+z8EiyLBC1bLyFwGBxkWmPXqdJ60mzuTaDSr5WezDwv0fz32HB7JHmRC6JVHSZg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.2.tgz", + "integrity": "sha512-2xVabFtIge6BJTcJrW8YuUnYTuQjh4jEuRuS2mscyNVOj6zUZkom3CQg+egKOoS+zh2rrro66ffSKIS+ztFJTg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.2.tgz", + "integrity": "sha512-wKRCQ27xCUJx5d6IivfjYGq8oVngqIhlhSAJntgXLt7Uo9sRT/3EppMHqUZRfyuNBTbykEre1s5166z+pvRB5A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.2.tgz", + "integrity": "sha512-NpCa+UVhhuNeaFVUP1Bftm0uqtvLWq2JTm7+Ta48+2Uqj2mNXrDIvyn1DY/ZEfmW/1yvGBRaUAv9zkMkMRixQA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.2.tgz", + "integrity": "sha512-ZWVC72x0lW4aj44e3khvBrj2oSYj1bD0jESmyah3zG/3DplEy/FOtYkMzbMjHTdDSheso7zH8GIlW6CDQnKhmQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.2.tgz", + "integrity": "sha512-pLT+OWYpzJig5K4VKhLttlIfBcVZfr2+Xbjra0Tjs83NQSkFS+y7xx+YhCwvpEmXYLIvaggj2ONPyjbiigOvHQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.2.tgz", + "integrity": "sha512-dhpiksQCyGca4WY0fJyzK3FxMDFoqMb0Cn+uDB+9GYjpU2K5//UGPQlCwiK4JHxuhg8oLMag5Nf3/IPSJNG8jw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.2.tgz", + "integrity": "sha512-O7bort1Vld00cu8g0jHZq3cbSTUNMohOEvYqsqE10+yfohhdPHzvzO+ziJRz4Dyyr/fYKREwS7gR4JC0soSOMw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } }, "dependencies": { @@ -45639,11 +45821,6 @@ "os-filter-obj": "^2.0.0" } }, - "@next/env": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/env/-/env-13.3.1.tgz", - "integrity": "sha512-EDtCoedIZC7JlUQ3uaQpSc4aVmyhbLHmQVALg7pFfQgOTjgSnn7mKtA0DiCMkYvvsx6aFb5octGMtWrOtGXW9A==" - }, "@next/eslint-plugin-next": { "version": "13.4.1", "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.1.tgz", @@ -45669,60 +45846,6 @@ } } }, - "@next/swc-darwin-arm64": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.3.1.tgz", - "integrity": "sha512-UXPtriEc/pBP8luSLSCZBcbzPeVv+SSjs9cH/KygTbhmACye8/OOXRZO13Z2Wq1G0gLmEAIHQAOuF+vafPd2lw==", - "optional": true - }, - "@next/swc-darwin-x64": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.3.1.tgz", - "integrity": "sha512-lT36yYxosCfLtplFzJWgo0hrPu6/do8+msgM7oQkPeohDNdhjtjFUgOOwdSnPublLR6Mo2Ym4P/wl5OANuD2bw==", - "optional": true - }, - "@next/swc-linux-arm64-gnu": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.3.1.tgz", - "integrity": "sha512-wRb76nLWJhonH8s3kxC/1tFguEkeOPayIwe9mkaz1G/yeS3OrjeyKMJsb4+Kdg0zbTo53bNCOl59NNtDM7yyyw==", - "optional": true - }, - "@next/swc-linux-arm64-musl": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.3.1.tgz", - "integrity": "sha512-qz3BzjJRZ16Iq/jrp+pjiYOc0jTjHlfmxQmZk9x/+5uhRP6/eWQSTAPVJ33BMo6oK5O5N4644OgTAbzXzorecg==", - "optional": true - }, - "@next/swc-linux-x64-gnu": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.3.1.tgz", - "integrity": "sha512-6mgkLmwlyWlomQmpl21I3hxgqE5INoW4owTlcLpNsd1V4wP+J46BlI/5zV5KWWbzjfncIqzXoeGs5Eg+1GHODA==", - "optional": true - }, - "@next/swc-linux-x64-musl": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.3.1.tgz", - "integrity": "sha512-uqm5sielhQmKJM+qayIhgZv1KlS5pqTdQ99b+Z7hMWryXS96qE0DftTmMZowBcUL6x7s2vSXyH5wPtO1ON7LBg==", - "optional": true - }, - "@next/swc-win32-arm64-msvc": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.3.1.tgz", - "integrity": "sha512-WomIiTj/v3LevltlibNQKmvrOymNRYL+a0dp5R73IwPWN5FvXWwSELN/kiNALig/+T3luc4qHNTyvMCp9L6U5Q==", - "optional": true - }, - "@next/swc-win32-ia32-msvc": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.3.1.tgz", - "integrity": "sha512-M+PoH+0+q658wRUbs285RIaSTYnGBSTdweH/0CdzDgA6Q4rBM0sQs4DHmO3BPP0ltCO/vViIoyG7ks66XmCA5g==", - "optional": true - }, - "@next/swc-win32-x64-msvc": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.3.1.tgz", - "integrity": "sha512-Sl1F4Vp5Z1rNXWZYqJwMuWRRol4bqOB6+/d7KqkgQ4AcafKPN1PZmpkCoxv4UFHtFNIB7EotnuIhtXu3zScicQ==", - "optional": true - }, "@node-rs/jieba": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@node-rs/jieba/-/jieba-1.7.0.tgz", @@ -45801,6 +45924,42 @@ "@nx/eslint-plugin": "16.2.2" } }, + "@nrwl/jest": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/jest/-/jest-16.2.2.tgz", + "integrity": "sha512-UEd6Vgcrr/IPG+lJBCoKgPtYwbYe1qiUM5bfP96i0eX3aPqKpzTR3WmHND9AMU6agNBO7r/24rfwPaUG1yx+9A==", + "dev": true, + "requires": { + "@nx/jest": "16.2.2" + } + }, + "@nrwl/js": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/js/-/js-16.2.2.tgz", + "integrity": "sha512-UBcrwd+84EkZxi5YWRlvhz2+Sg7Nsl3CopwnO5JpxU0oGySZnpvN6umI9aHuBJ4yh1dkyqvaXJuAX3slT1pjvw==", + "dev": true, + "requires": { + "@nx/js": "16.2.2" + } + }, + "@nrwl/linter": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/linter/-/linter-16.2.2.tgz", + "integrity": "sha512-xTDYrWOvrp8jp5KlSXLe+jrKIxcfm/qY9DojV4kGkPgVGGL4Veu5SgpW4BIaD1wYvceKsVPDZ9mRKJcJShq8AQ==", + "dev": true, + "requires": { + "@nx/linter": "16.2.2" + } + }, + "@nrwl/next": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/next/-/next-16.2.2.tgz", + "integrity": "sha512-gkBSZXb2cdUf5sPS0k/+BzSboriHEsFih6pJ5FcCLt6NcfLcOPHn+FZcpn/8hBQMyUr+mzpWzXk32ALR8MROvQ==", + "dev": true, + "requires": { + "@nx/next": "16.2.2" + } + }, "@nrwl/react": { "version": "16.2.2", "resolved": "https://registry.npmjs.org/@nrwl/react/-/react-16.2.2.tgz", @@ -45810,6 +45969,15 @@ "@nx/react": "16.2.2" } }, + "@nrwl/storybook": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/storybook/-/storybook-16.2.2.tgz", + "integrity": "sha512-JRyo/JTT8IdUsk6QbT7cxuxYjkQo1sS3lXMdiIeniYWC694DCsurRrWLMfRSx01Z4rm6L3ZgRxDjLhse5MVRhg==", + "dev": true, + "requires": { + "@nx/storybook": "16.2.2" + } + }, "@nrwl/tao": { "version": "16.2.2", "resolved": "https://registry.npmjs.org/@nrwl/tao/-/tao-16.2.2.tgz", @@ -45828,6 +45996,24 @@ "@nx/vite": "16.2.2" } }, + "@nrwl/web": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/web/-/web-16.2.2.tgz", + "integrity": "sha512-A0SlEY0jn55mUxd4zJdXNJzxiXLI9OX0/tRPCVHz4f6y81BIApsvAyG8D9fgCNNc2hAFVztrbkWR0cL5mDDQXA==", + "dev": true, + "requires": { + "@nx/web": "16.2.2" + } + }, + "@nrwl/webpack": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/@nrwl/webpack/-/webpack-16.2.2.tgz", + "integrity": "sha512-tv3Ul843wMcuq3jGWdqVmjxktLJ/cvB1WTyMmgqTRaRYcqK+wDP+0ziQCgN/sLqKidOyelA2ZyNdx3K/RweEjw==", + "dev": true, + "requires": { + "@nx/webpack": "16.2.2" + } + }, "@nrwl/workspace": { "version": "16.2.2", "resolved": "https://registry.npmjs.org/@nrwl/workspace/-/workspace-16.2.2.tgz", @@ -45969,8 +46155,8 @@ "requires": { "@jest/reporters": "^29.4.1", "@jest/test-result": "^29.4.1", + "@nrwl/jest": "16.2.2", "@nx/devkit": "16.2.2", - "@nx/jest": "16.2.2", "@nx/js": "16.2.2", "@phenomnomnominal/tsquery": "~5.0.1", "chalk": "^4.1.0", @@ -45996,8 +46182,8 @@ "@babel/preset-env": "^7.15.0", "@babel/preset-typescript": "^7.15.0", "@babel/runtime": "^7.14.8", + "@nrwl/js": "16.2.2", "@nx/devkit": "16.2.2", - "@nx/js": "16.2.2", "@nx/workspace": "16.2.2", "@phenomnomnominal/tsquery": "~5.0.1", "babel-plugin-const-enum": "^1.0.1", @@ -46074,9 +46260,9 @@ "integrity": "sha512-bJVxDSurtknamhhfrdntXWbWDCmzEaGEabliAK8bBeieqj3VrE69oy+yvSLHf29lJdg+rzB6os3wm/1xBHAzvg==", "dev": true, "requires": { + "@nrwl/linter": "16.2.2", "@nx/devkit": "16.2.2", "@nx/js": "16.2.2", - "@nx/linter": "16.2.2", "@phenomnomnominal/tsquery": "~5.0.1", "tmp": "~0.2.1", "tslib": "^2.3.0" @@ -46089,10 +46275,10 @@ "dev": true, "requires": { "@babel/plugin-proposal-decorators": "^7.14.5", + "@nrwl/next": "16.2.2", "@nx/devkit": "16.2.2", "@nx/js": "16.2.2", "@nx/linter": "16.2.2", - "@nx/next": "16.2.2", "@nx/react": "16.2.2", "@nx/workspace": "16.2.2", "@svgr/webpack": "^6.1.2", @@ -46492,11 +46678,11 @@ "integrity": "sha512-4MZaLW81otbvSEJpp3k9MTYFz3yo8xvfJ3BiuOYJ4UreeTwf683MqV6/FL9vS2viY4UWQu/nR0ir4tOdf5h7Rw==", "dev": true, "requires": { + "@nrwl/storybook": "16.2.2", "@nx/cypress": "16.2.2", "@nx/devkit": "16.2.2", "@nx/js": "16.2.2", "@nx/linter": "16.2.2", - "@nx/storybook": "16.2.2", "@nx/workspace": "16.2.2", "@phenomnomnominal/tsquery": "~5.0.1", "dotenv": "~10.0.0", @@ -46551,9 +46737,9 @@ "integrity": "sha512-pxUBSBjImaDalh9GdIRUO23t02XEaMcu1M+QBfj4YArAgdjEN3hkIuTpJkxPufNMvZNHGQe8LudNa2Skp+mW0Q==", "dev": true, "requires": { + "@nrwl/web": "16.2.2", "@nx/devkit": "16.2.2", "@nx/js": "16.2.2", - "@nx/web": "16.2.2", "chalk": "^4.1.0", "chokidar": "^3.5.1", "http-server": "^14.1.0", @@ -46568,9 +46754,9 @@ "dev": true, "requires": { "@babel/core": "^7.15.0", + "@nrwl/webpack": "16.2.2", "@nx/devkit": "16.2.2", "@nx/js": "16.2.2", - "@nx/webpack": "16.2.2", "autoprefixer": "^10.4.9", "babel-loader": "^9.1.2", "chalk": "^4.1.0", @@ -50461,7 +50647,6 @@ "version": "0.5.1", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.1.tgz", "integrity": "sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==", - "dev": true, "requires": { "tslib": "^2.4.0" } @@ -51416,12 +51601,6 @@ "semver": "7.5.0" }, "dependencies": { - "core-js": { - "version": "3.30.2", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.30.2.tgz", - "integrity": "sha512-uBJiDmwqsbJCWHAwjrx3cvjbMXP7xD72Dmsn5LOJpiRmE3WbBbN5rCqQ2Qh6Ek6/eOrjlWngEynBWo4VxerQhg==", - "dev": true - }, "process-warning": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", @@ -52445,14 +52624,16 @@ "scroll-into-view-if-needed": "^2.2.25" }, "dependencies": { - "rc-field-form": { - "version": "1.34.0", - "resolved": "https://registry.npmjs.org/rc-field-form/-/rc-field-form-1.34.0.tgz", - "integrity": "sha512-soGJulqlQq5u7PY0FiG1tz6G3NgXFNGEWfJjSQAzStsbxoxnP9CRETzQ8oI9fIAuXwI8eReEZxyqqMpwL0xEfw==", + "rc-drawer": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/rc-drawer/-/rc-drawer-6.3.0.tgz", + "integrity": "sha512-uBZVb3xTAR+dBV53d/bUhTctCw3pwcwJoM7g5aX+7vgwt2zzVzoJ6aqFjYJpBlZ9zp0dVYN8fV+hykFE7c4lig==", "requires": { - "@babel/runtime": "^7.18.0", - "async-validator": "^4.1.0", - "rc-util": "^5.32.2" + "@babel/runtime": "^7.10.1", + "@rc-component/portal": "^1.1.1", + "classnames": "^2.2.6", + "rc-motion": "^2.6.1", + "rc-util": "^5.21.2" } } } @@ -55179,9 +55360,9 @@ } }, "core-js": { - "version": "3.31.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.31.0.tgz", - "integrity": "sha512-NIp2TQSGfR6ba5aalZD+ZQ1fSxGhDo/s1w0nx3RYzf2pnJxt7YynxFlFScP6eV7+GZsKO95NSjGxyJsU3DZgeQ==" + "version": "3.30.2", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.30.2.tgz", + "integrity": "sha512-uBJiDmwqsbJCWHAwjrx3cvjbMXP7xD72Dmsn5LOJpiRmE3WbBbN5rCqQ2Qh6Ek6/eOrjlWngEynBWo4VxerQhg==" }, "core-js-compat": { "version": "3.29.0", @@ -63904,34 +64085,86 @@ "dev": true }, "next": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/next/-/next-13.3.1.tgz", - "integrity": "sha512-eByWRxPzKHs2oQz1yE41LX35umhz86ZSZ+mYyXBqn2IBi2hyUqxBA88avywdr4uyH+hCJczegGsDGWbzQA5Rqw==", - "requires": { - "@next/env": "13.3.1", - "@next/swc-darwin-arm64": "13.3.1", - "@next/swc-darwin-x64": "13.3.1", - "@next/swc-linux-arm64-gnu": "13.3.1", - "@next/swc-linux-arm64-musl": "13.3.1", - "@next/swc-linux-x64-gnu": "13.3.1", - "@next/swc-linux-x64-musl": "13.3.1", - "@next/swc-win32-arm64-msvc": "13.3.1", - "@next/swc-win32-ia32-msvc": "13.3.1", - "@next/swc-win32-x64-msvc": "13.3.1", - "@swc/helpers": "0.5.0", + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/next/-/next-13.4.2.tgz", + "integrity": "sha512-aNFqLs3a3nTGvLWlO9SUhCuMUHVPSFQC0+tDNGAsDXqx+WJDFSbvc233gOJ5H19SBc7nw36A9LwQepOJ2u/8Kg==", + "requires": { + "@next/env": "13.4.2", + "@next/swc-darwin-arm64": "13.4.2", + "@next/swc-darwin-x64": "13.4.2", + "@next/swc-linux-arm64-gnu": "13.4.2", + "@next/swc-linux-arm64-musl": "13.4.2", + "@next/swc-linux-x64-gnu": "13.4.2", + "@next/swc-linux-x64-musl": "13.4.2", + "@next/swc-win32-arm64-msvc": "13.4.2", + "@next/swc-win32-ia32-msvc": "13.4.2", + "@next/swc-win32-x64-msvc": "13.4.2", + "@swc/helpers": "0.5.1", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", "postcss": "8.4.14", - "styled-jsx": "5.1.1" + "styled-jsx": "5.1.1", + "zod": "3.21.4" }, "dependencies": { - "@swc/helpers": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.0.tgz", - "integrity": "sha512-SjY/p4MmECVVEWspzSRpQEM3sjR17sP8PbGxELWrT+YZMBfiUyt1MRUNjMV23zohwlG2HYtCQOsCwsTHguXkyg==", - "requires": { - "tslib": "^2.4.0" - } + "@next/env": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.2.tgz", + "integrity": "sha512-Wqvo7lDeS0KGwtwg9TT9wKQ8raelmUxt+TQKWvG/xKfcmDXNOtCuaszcfCF8JzlBG1q0VhpI6CKaRMbVPMDWgw==" + }, + "@next/swc-darwin-arm64": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.2.tgz", + "integrity": "sha512-6BBlqGu3ewgJflv9iLCwO1v1hqlecaIH2AotpKfVUEzUxuuDNJQZ2a4KLb4MBl8T9/vca1YuWhSqtbF6ZuUJJw==", + "optional": true + }, + "@next/swc-darwin-x64": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.2.tgz", + "integrity": "sha512-iZuYr7ZvGLPjPmfhhMl0ISm+z8EiyLBC1bLyFwGBxkWmPXqdJ60mzuTaDSr5WezDwv0fz32HB7JHmRC6JVHSZg==", + "optional": true + }, + "@next/swc-linux-arm64-gnu": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.2.tgz", + "integrity": "sha512-2xVabFtIge6BJTcJrW8YuUnYTuQjh4jEuRuS2mscyNVOj6zUZkom3CQg+egKOoS+zh2rrro66ffSKIS+ztFJTg==", + "optional": true + }, + "@next/swc-linux-arm64-musl": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.2.tgz", + "integrity": "sha512-wKRCQ27xCUJx5d6IivfjYGq8oVngqIhlhSAJntgXLt7Uo9sRT/3EppMHqUZRfyuNBTbykEre1s5166z+pvRB5A==", + "optional": true + }, + "@next/swc-linux-x64-gnu": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.2.tgz", + "integrity": "sha512-NpCa+UVhhuNeaFVUP1Bftm0uqtvLWq2JTm7+Ta48+2Uqj2mNXrDIvyn1DY/ZEfmW/1yvGBRaUAv9zkMkMRixQA==", + "optional": true + }, + "@next/swc-linux-x64-musl": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.2.tgz", + "integrity": "sha512-ZWVC72x0lW4aj44e3khvBrj2oSYj1bD0jESmyah3zG/3DplEy/FOtYkMzbMjHTdDSheso7zH8GIlW6CDQnKhmQ==", + "optional": true + }, + "@next/swc-win32-arm64-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.2.tgz", + "integrity": "sha512-pLT+OWYpzJig5K4VKhLttlIfBcVZfr2+Xbjra0Tjs83NQSkFS+y7xx+YhCwvpEmXYLIvaggj2ONPyjbiigOvHQ==", + "optional": true + }, + "@next/swc-win32-ia32-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.2.tgz", + "integrity": "sha512-dhpiksQCyGca4WY0fJyzK3FxMDFoqMb0Cn+uDB+9GYjpU2K5//UGPQlCwiK4JHxuhg8oLMag5Nf3/IPSJNG8jw==", + "optional": true + }, + "@next/swc-win32-x64-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.2.tgz", + "integrity": "sha512-O7bort1Vld00cu8g0jHZq3cbSTUNMohOEvYqsqE10+yfohhdPHzvzO+ziJRz4Dyyr/fYKREwS7gR4JC0soSOMw==", + "optional": true }, "postcss": { "version": "8.4.14", @@ -66329,9 +66562,7 @@ } }, "rc-cascader": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/rc-cascader/-/rc-cascader-3.7.2.tgz", - "integrity": "sha512-5nPEM76eMyikd0NFiy1gjwiB9m+bOzjY6Lnd5bVC6Ar3XLlOpOnlCcV3oBFWLN3f7B18tAGpaAVlT2uyEDCv9w==", + "version": "3.7.0", "requires": { "@babel/runtime": "^7.12.5", "array-tree-filter": "^2.1.0", @@ -66342,9 +66573,7 @@ } }, "rc-checkbox": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/rc-checkbox/-/rc-checkbox-3.0.1.tgz", - "integrity": "sha512-k7nxDWxYF+jDI0ZcCvuvj71xONmWRVe5+1MKcERRR9MRyP3tZ69b+yUCSXXh+sik4/Hc9P5wHr2nnUoGS2zBjA==", + "version": "3.0.0", "requires": { "@babel/runtime": "^7.10.1", "classnames": "^2.3.2", @@ -66375,18 +66604,6 @@ "rc-util": "^5.21.0" } }, - "rc-drawer": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/rc-drawer/-/rc-drawer-6.3.0.tgz", - "integrity": "sha512-uBZVb3xTAR+dBV53d/bUhTctCw3pwcwJoM7g5aX+7vgwt2zzVzoJ6aqFjYJpBlZ9zp0dVYN8fV+hykFE7c4lig==", - "requires": { - "@babel/runtime": "^7.10.1", - "@rc-component/portal": "^1.1.1", - "classnames": "^2.2.6", - "rc-motion": "^2.6.1", - "rc-util": "^5.21.2" - } - }, "rc-dropdown": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/rc-dropdown/-/rc-dropdown-4.0.1.tgz", @@ -66398,6 +66615,16 @@ "rc-util": "^5.17.0" } }, + "rc-field-form": { + "version": "1.34.0", + "resolved": "https://registry.npmjs.org/rc-field-form/-/rc-field-form-1.34.0.tgz", + "integrity": "sha512-soGJulqlQq5u7PY0FiG1tz6G3NgXFNGEWfJjSQAzStsbxoxnP9CRETzQ8oI9fIAuXwI8eReEZxyqqMpwL0xEfw==", + "requires": { + "@babel/runtime": "^7.18.0", + "async-validator": "^4.1.0", + "rc-util": "^5.32.2" + } + }, "rc-image": { "version": "5.13.0", "resolved": "https://registry.npmjs.org/rc-image/-/rc-image-5.13.0.tgz", @@ -66445,9 +66672,7 @@ } }, "rc-menu": { - "version": "9.8.4", - "resolved": "https://registry.npmjs.org/rc-menu/-/rc-menu-9.8.4.tgz", - "integrity": "sha512-lmw2j8I2fhdIzHmC9ajfImfckt0WDb2KVJJBBRIsxPEw2kGkEfjLMUoB1NgiNT/Q5cC8PdjGOGQjHJIJMwyNMw==", + "version": "9.8.2", "requires": { "@babel/runtime": "^7.10.1", "classnames": "2.x", @@ -66458,9 +66683,7 @@ } }, "rc-motion": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/rc-motion/-/rc-motion-2.7.3.tgz", - "integrity": "sha512-2xUvo8yGHdOHeQbdI8BtBsCIrWKchEmFEIskf0nmHtJsou+meLd/JE+vnvSX2JxcBrJtXY2LuBpxAOxrbY/wMQ==", + "version": "2.6.3", "requires": { "@babel/runtime": "^7.11.1", "classnames": "^2.2.1", @@ -66479,9 +66702,7 @@ } }, "rc-overflow": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/rc-overflow/-/rc-overflow-1.3.1.tgz", - "integrity": "sha512-RY0nVBlfP9CkxrpgaLlGzkSoh9JhjJLu6Icqs9E7CW6Ewh9s0peF9OHIex4OhfoPsR92LR0fN6BlCY9Z4VoUtA==", + "version": "1.2.8", "requires": { "@babel/runtime": "^7.11.1", "classnames": "^2.2.1", @@ -66499,9 +66720,7 @@ } }, "rc-picker": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/rc-picker/-/rc-picker-2.7.2.tgz", - "integrity": "sha512-KbUKgbzgWVN5L+V9xhZDKSmseHIyFneBlmuMtMrZ9fU7Oypw6D+owS5kuUicIEV08Y17oXt8dUqauMeC5IFBPg==", + "version": "2.7.0", "requires": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.1", @@ -66514,9 +66733,9 @@ } }, "rc-progress": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/rc-progress/-/rc-progress-3.4.2.tgz", - "integrity": "sha512-iAGhwWU+tsayP+Jkl9T4+6rHeQTG9kDz8JAHZk4XtQOcYN5fj9H34NXNEdRdZx94VUDHMqCb1yOIvi8eJRh67w==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/rc-progress/-/rc-progress-3.4.1.tgz", + "integrity": "sha512-eAFDHXlk8aWpoXl0llrenPMt9qKHQXphxcVsnKs0FHC6eCSk1ebJtyaVjJUzKe0233ogiLDeEFK1Uihz3s67hw==", "requires": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.6", @@ -66613,9 +66832,7 @@ } }, "rc-tabs": { - "version": "12.5.10", - "resolved": "https://registry.npmjs.org/rc-tabs/-/rc-tabs-12.5.10.tgz", - "integrity": "sha512-Ay0l0jtd4eXepFH9vWBvinBjqOpqzcsJTerBGwJy435P2S90Uu38q8U/mvc1sxUEVOXX5ZCFbxcWPnfG3dH+tQ==", + "version": "12.5.7", "requires": { "@babel/runtime": "^7.11.2", "classnames": "2.x", @@ -66649,15 +66866,13 @@ } }, "rc-tree": { - "version": "5.7.6", - "resolved": "https://registry.npmjs.org/rc-tree/-/rc-tree-5.7.6.tgz", - "integrity": "sha512-Dzam4VFcohXfcw+K4syq177RKqdqYun1XRc6etAEpRvsTruo4udhcsPrsEfOrRkrhnmkO58Q9F1/lgvm2dznVQ==", + "version": "5.7.2", "requires": { "@babel/runtime": "^7.10.1", "classnames": "2.x", "rc-motion": "^2.0.1", "rc-util": "^5.16.1", - "rc-virtual-list": "^3.5.1" + "rc-virtual-list": "^3.4.8" } }, "rc-tree-select": { @@ -66711,9 +66926,7 @@ } }, "rc-virtual-list": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/rc-virtual-list/-/rc-virtual-list-3.5.2.tgz", - "integrity": "sha512-sE2G9hTPjVmatQni8OP2Kx33+Oth6DMKm67OblBBmgMBJDJQOOFpSGH7KZ6Pm85rrI2IGxDRXZCr0QhYOH2pfQ==", + "version": "3.4.13", "requires": { "@babel/runtime": "^7.20.0", "classnames": "^2.2.6", @@ -71020,12 +71233,6 @@ "requires": { "lockfile": "1.0.4" } - }, - "core-js": { - "version": "3.30.2", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.30.2.tgz", - "integrity": "sha512-uBJiDmwqsbJCWHAwjrx3cvjbMXP7xD72Dmsn5LOJpiRmE3WbBbN5rCqQ2Qh6Ek6/eOrjlWngEynBWo4VxerQhg==", - "dev": true } } }, @@ -72233,14 +72440,67 @@ "zod": { "version": "3.21.4", "resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz", - "integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==", - "dev": true + "integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==" }, "zwitch": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==", "dev": true + }, + "@next/swc-darwin-arm64": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.2.tgz", + "integrity": "sha512-6BBlqGu3ewgJflv9iLCwO1v1hqlecaIH2AotpKfVUEzUxuuDNJQZ2a4KLb4MBl8T9/vca1YuWhSqtbF6ZuUJJw==", + "optional": true + }, + "@next/swc-darwin-x64": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.2.tgz", + "integrity": "sha512-iZuYr7ZvGLPjPmfhhMl0ISm+z8EiyLBC1bLyFwGBxkWmPXqdJ60mzuTaDSr5WezDwv0fz32HB7JHmRC6JVHSZg==", + "optional": true + }, + "@next/swc-linux-arm64-gnu": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.2.tgz", + "integrity": "sha512-2xVabFtIge6BJTcJrW8YuUnYTuQjh4jEuRuS2mscyNVOj6zUZkom3CQg+egKOoS+zh2rrro66ffSKIS+ztFJTg==", + "optional": true + }, + "@next/swc-linux-arm64-musl": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.2.tgz", + "integrity": "sha512-wKRCQ27xCUJx5d6IivfjYGq8oVngqIhlhSAJntgXLt7Uo9sRT/3EppMHqUZRfyuNBTbykEre1s5166z+pvRB5A==", + "optional": true + }, + "@next/swc-linux-x64-gnu": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.2.tgz", + "integrity": "sha512-NpCa+UVhhuNeaFVUP1Bftm0uqtvLWq2JTm7+Ta48+2Uqj2mNXrDIvyn1DY/ZEfmW/1yvGBRaUAv9zkMkMRixQA==", + "optional": true + }, + "@next/swc-linux-x64-musl": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.2.tgz", + "integrity": "sha512-ZWVC72x0lW4aj44e3khvBrj2oSYj1bD0jESmyah3zG/3DplEy/FOtYkMzbMjHTdDSheso7zH8GIlW6CDQnKhmQ==", + "optional": true + }, + "@next/swc-win32-arm64-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.2.tgz", + "integrity": "sha512-pLT+OWYpzJig5K4VKhLttlIfBcVZfr2+Xbjra0Tjs83NQSkFS+y7xx+YhCwvpEmXYLIvaggj2ONPyjbiigOvHQ==", + "optional": true + }, + "@next/swc-win32-ia32-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.2.tgz", + "integrity": "sha512-dhpiksQCyGca4WY0fJyzK3FxMDFoqMb0Cn+uDB+9GYjpU2K5//UGPQlCwiK4JHxuhg8oLMag5Nf3/IPSJNG8jw==", + "optional": true + }, + "@next/swc-win32-x64-msvc": { + "version": "13.4.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.2.tgz", + "integrity": "sha512-O7bort1Vld00cu8g0jHZq3cbSTUNMohOEvYqsqE10+yfohhdPHzvzO+ziJRz4Dyyr/fYKREwS7gR4JC0soSOMw==", + "optional": true } } } diff --git a/package.json b/package.json index 1083ae98078..171bee797a7 100644 --- a/package.json +++ b/package.json @@ -16,24 +16,26 @@ ], "license": "MIT", "scripts": { - "gpt:file:example": "yarn gpt:file --file ./gpt/services/openai.js --file ./gpt/commit.js --file ./gpt/file.js --question \"Fix all JSDoc issues, dont modify any other aspectf of these files besides JSDOC\"", + "gpt:file:example": "npm run gpt:file --file ./gpt/services/openai.js --file ./gpt/commit.js --file ./gpt/file.js --question \"Fix all JSDoc issues, dont modify any other aspectf of these files besides JSDOC\"", "gpt:commit": "node ./gpt --commit", "gpt:file": "node ./gpt", "gpt:pr": "node ./gpt --pr", + "build:prod": "nx run-many --target=build --projects=3000-home --verbose --output-style=stream", "build": "nx run-many --target=build --projects=3000-home --verbose --output-style=stream", "oldbuuild": "nx build", "build:libs": "nx run-many --target=build --projects=utils,node,nextjs-mf --verbose --output-style=stream --maxParallel=1", "lint": "nx run-many --target=lint", "test": "nx run-many --target=test", - "start:next": "yarn build:libs && concurrently 'nx run 3000-home:serve:development --output-style=stream' 'nx run 3001-shop:serve:development --output-style=stream' 'nx run 3002-checkout:serve:development --output-style=stream'", - "start:nextho": "yarn build:libs && concurrently 'nx run 3000-home:serve:development --output-style=stream'", - "serve:next": "yarn build:libs && concurrently 'nx run 3000-home:serve:production --output-style=stream' 'nx run 3001-shop:serve:production --output-style=stream' 'nx run 3002-checkout:serve:production --output-style=stream'", + "start:next": "npm run build:libs && concurrently 'nx run 3000-home:serve:development --output-style=stream' 'nx run 3001-shop:serve:development --output-style=stream' 'nx run 3002-checkout:serve:development --output-style=stream'", + "start:nextho": "npm run build:libs && nx run-many --target=serve --projects=3000-home --output-style=stream --verbose", + "serve:next": "npm run build:libs && concurrently 'nx run 3000-home:serve:production --output-style=stream' 'nx run 3001-shop:serve:production --output-style=stream' 'nx run 3002-checkout:serve:production --output-style=stream'", "prod": "nx build:libs && nx run-many --target=build --verbose --output-style=stream", "commit": "cz", "git:pruneTags": "git tag -l | xargs git tag -d && git fetch --all --prune --tags", "prerelease:node": "nx run node:version --releaseAs=prerelease --preid=beta", "prerelease:next": "nx run nextjs-mf:version --releaseAs=prerelease --preid=beta", "prerelease:utils": "nx run utils:version --releaseAs=prerelease --preid=beta", + "prerelease:all": "nx run-many --target=version --projects=utils,node,nextjs-mf --releaseAs=prerelease --preid=rc --maxParallel=1 --allowEmptyRelease=true", "release:node": "nx run node:version --releaseAs=minor", "release:next": "nx run nextjs-mf:version --releaseAs=patch", "release:utils": "nx run utils:version --releaseAs=minor", @@ -53,7 +55,7 @@ "core-js": "^3.30.2", "fast-glob": "^3.2.12", "lodash.get": "^4.4.2", - "next": "13.3.1", + "next": "13.4.2", "rambda": "^7.5.0", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/packages/nextjs-mf/CHANGELOG.md b/packages/nextjs-mf/CHANGELOG.md index 5d23ebce1a9..b29f4da17e3 100644 --- a/packages/nextjs-mf/CHANGELOG.md +++ b/packages/nextjs-mf/CHANGELOG.md @@ -2,6 +2,367 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [6.7.2-rc.1](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.7.2-rc.0...nextjs-mf-6.7.2-rc.1) (2023-07-01) + + +### Features + +* support edge workers ([#1084](https://github.com/module-federation/nextjs-mf/issues/1084)) ([3f5df94](https://github.com/module-federation/nextjs-mf/commit/3f5df944ea787cf958fd4cf7fabed84432a50a10)) + + + +## [6.7.2-rc.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.7.1...nextjs-mf-6.7.2-rc.0) (2023-06-30) + + +### Bug Fixes + +* module type errors ([4c7b3ff](https://github.com/module-federation/nextjs-mf/commit/4c7b3ffad0726c6d9f51a8fb72ec7eefb3633073)) +* ts errors ([44de0be](https://github.com/module-federation/nextjs-mf/commit/44de0beb8c2d94028f738849f2bab438ce530ebe)) + + + +## [6.5.2-rc8.1](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.2-rc8.0...nextjs-mf-6.5.2-rc8.1) (2023-06-28) + + +### Bug Fixes + +* disable flushing remotes to ssr for now ([6c5cfae](https://github.com/module-federation/nextjs-mf/commit/6c5cfaec3be94aeb3f1e12c24965b3904da23bae)) + + + +## [6.5.2-rc8.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.2-rc7.0...nextjs-mf-6.5.2-rc8.0) (2023-06-27) + + + +## [6.5.2-rc7.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.2-rc6.0...nextjs-mf-6.5.2-rc7.0) (2023-06-27) + + +### Bug Fixes + +* image path fallback ([fc176ff](https://github.com/module-federation/nextjs-mf/commit/fc176ffa74a082ab0d7a198315f3b0827eb13037)) + + + +## [6.5.2-rc6.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.2-rc5.0...nextjs-mf-6.5.2-rc6.0) (2023-06-23) + + +### Bug Fixes + +* remove loggers ([a86b070](https://github.com/module-federation/nextjs-mf/commit/a86b070e11f31303a8833f806f7d2015e55a441b)) + + + +## [6.5.2-rc5.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.2-rc4.0...nextjs-mf-6.5.2-rc5.0) (2023-06-23) + + +### Bug Fixes + +* Non-Deterministic Chunk ID Handling ([#986](https://github.com/module-federation/nextjs-mf/issues/986)) ([b051c12](https://github.com/module-federation/nextjs-mf/commit/b051c12bbaf54f7327a4d25407326b6a7d1d9594)) + + + +## [6.5.2-rc4.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.2-rc3.1...nextjs-mf-6.5.2-rc4.0) (2023-06-21) + + +### Bug Fixes + +* Api routes ([#984](https://github.com/module-federation/nextjs-mf/issues/984)) ([903296a](https://github.com/module-federation/nextjs-mf/commit/903296af090d344845288fc940536a3b741eb1e1)) +* Resolve condition names ([#974](https://github.com/module-federation/nextjs-mf/issues/974)) ([5e8b49c](https://github.com/module-federation/nextjs-mf/commit/5e8b49cf60f19dae6be4818a1c0ff783c7689393)) +* Resolve conditional exports ([#971](https://github.com/module-federation/nextjs-mf/issues/971)) ([1c42e2a](https://github.com/module-federation/nextjs-mf/commit/1c42e2a721a9e93b2e9acebc09099dda66699a42)) +* Runtime module checking ([#969](https://github.com/module-federation/nextjs-mf/issues/969)) ([b5c7af1](https://github.com/module-federation/nextjs-mf/commit/b5c7af1697a63d9e19f901238a4c0382ea0c3f50)) + + + +## [6.5.2-rc3.1](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.2-rc3.0...nextjs-mf-6.5.2-rc3.1) (2023-06-09) + + +### Bug Fixes + +* Path loader patches ([#960](https://github.com/module-federation/nextjs-mf/issues/960)) ([d362a77](https://github.com/module-federation/nextjs-mf/commit/d362a7752c4364cc499a27f2b6eeb5399543cb29)) + + + +## [6.5.2-rc3.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.2-beta.0...nextjs-mf-6.5.2-rc3.0) (2023-06-09) + + +### Bug Fixes + +* remove logs or wrap in debug flag ([#959](https://github.com/module-federation/nextjs-mf/issues/959)) ([5ea321a](https://github.com/module-federation/nextjs-mf/commit/5ea321a6ee4323456f9ad1e62bb2e765df612017)) + + + +## [6.5.2-beta.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.2-rc1.0...nextjs-mf-6.5.2-beta.0) (2023-05-26) + + +### Bug Fixes + +* Improve chunk correlation ([#936](https://github.com/module-federation/nextjs-mf/issues/936)) ([4dad1eb](https://github.com/module-federation/nextjs-mf/commit/4dad1eb370feacd6ecb4c1726c435d5c579f424d)) +* remove default props deprecation on flush chunks ([103fa91](https://github.com/module-federation/nextjs-mf/commit/103fa910d39e25d283076755a2eedf4e926ba242)) + + +### Features + +* support custom distDir ([3d8d540](https://github.com/module-federation/nextjs-mf/commit/3d8d5408f73be9b8798f02fbd2382457510fdc3f)) + + + +## [6.5.2-rc1.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.2-rc.0...nextjs-mf-6.5.2-rc1.0) (2023-05-25) + + +### Bug Fixes + +* Improved Entrypoint Module Detection and Refactoring ([#932](https://github.com/module-federation/nextjs-mf/issues/932)) ([d09e841](https://github.com/module-federation/nextjs-mf/commit/d09e841fb2e01300e61c046e18b9d02842920b4a)) +* remove specific module type from package ([ad8caf7](https://github.com/module-federation/nextjs-mf/commit/ad8caf7df575a67a866e882e515d9a4e249f5ad8)) + + + +## [6.5.2-rc.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.5.1...nextjs-mf-6.5.2-rc.0) (2023-05-23) + + +### Bug Fixes + +* chunk and module duplications ([#885](https://github.com/module-federation/nextjs-mf/issues/885)) ([199e6b9](https://github.com/module-federation/nextjs-mf/commit/199e6b9937f4a2ca6caedb3ae4767342de463cb6)) +* client prod build issues ([#899](https://github.com/module-federation/nextjs-mf/issues/899)) ([470d7ad](https://github.com/module-federation/nextjs-mf/commit/470d7ad408ae8d64dbccc5a9528eaa2ed60fa2ca)) +* deprecation warnings about chunkGraph ([9af484d](https://github.com/module-federation/nextjs-mf/commit/9af484dedba44b346d25ac5cdd10292ad018143d)) +* externalization and missing runtime chunks ([#887](https://github.com/module-federation/nextjs-mf/issues/887)) ([c79cd62](https://github.com/module-federation/nextjs-mf/commit/c79cd6226d3134f1d6294cd8eba40c8c33af5cb5)) +* missing chunk hashes on exposed modules ([#893](https://github.com/module-federation/nextjs-mf/issues/893)) ([cfa43f5](https://github.com/module-federation/nextjs-mf/commit/cfa43f506999d5ce3ab6afeea513d50d85f7886e)) + + + +## [6.4.1-rc.2](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.1-rc.1...nextjs-mf-6.4.1-rc.2) (2023-05-17) + + + +## [6.4.1-rc.1](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.1-rc.0...nextjs-mf-6.4.1-rc.1) (2023-05-17) + + +### Bug Fixes + +* **chunk-module-duplication:** prevent runtime reset and share scope loss ([14bfc38](https://github.com/module-federation/nextjs-mf/commit/14bfc38515a4da3be7321d4b6d876905d45ad20b)) + + + +## [6.4.1-rc.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.1-beta.7...nextjs-mf-6.4.1-rc.0) (2023-05-16) + + +### Bug Fixes + +* Improved Share Scope Properties and Fixed Production Build Issues ([#884](https://github.com/module-federation/nextjs-mf/issues/884)) ([de7b2ce](https://github.com/module-federation/nextjs-mf/commit/de7b2cec7518f6b069818a511275e359c616bb73)) +* remove old files ([fa281ec](https://github.com/module-federation/nextjs-mf/commit/fa281ecf0a5486bcf995f548deaef993f437c068)) + + +### Features + +* remove entry injection ([4e6981f](https://github.com/module-federation/nextjs-mf/commit/4e6981f8d8a312ae383b1c2cd337882b268e2b9b)) + + + +## [6.4.1-beta.7](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.1-beta.6...nextjs-mf-6.4.1-beta.7) (2023-05-16) + + +### Bug Fixes + +* ensure eager modules always exist in host (inject dependent modules somewhere in build pipeline) ([12bb896](https://github.com/module-federation/nextjs-mf/commit/12bb896d37324b4f3d0d59da04463b1d04428a01)) + + + +## [6.4.1-beta.6](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.1-beta.5...nextjs-mf-6.4.1-beta.6) (2023-05-15) + + +### Features + +* Quantum Modules ([#872](https://github.com/module-federation/nextjs-mf/issues/872)) ([2991039](https://github.com/module-federation/nextjs-mf/commit/299103932b4e0aa6d8017be588ffa5272f519260)) + + + +## [6.4.1-beta.5](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.1-beta.4...nextjs-mf-6.4.1-beta.5) (2023-05-13) + + +### Bug Fixes + +* remove debugging runtime variable ([d15dc2d](https://github.com/module-federation/nextjs-mf/commit/d15dc2dc6f6297532d89295690c6f561fee7955f)) + + + +## [6.4.1-beta.4](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.1-beta.3...nextjs-mf-6.4.1-beta.4) (2023-05-13) + + +### Bug Fixes + +* add warning on auto page stitch ([2f068cf](https://github.com/module-federation/nextjs-mf/commit/2f068cfd71f0aad12285b9ab4cfbd515f399211c)) +* remove commented out code from InvertedContainerPlugin.ts ([7d52961](https://github.com/module-federation/nextjs-mf/commit/7d529612869f061733d7d87c9770036b7c2b0bbb)) +* resolve backmerge issues with build ([2ad095c](https://github.com/module-federation/nextjs-mf/commit/2ad095cc3198dfd153644cee5fb4f37fa3bf6f03)) + + +### Features + +* [7] Async boundary runtime server ([#851](https://github.com/module-federation/nextjs-mf/issues/851)) ([7fa792a](https://github.com/module-federation/nextjs-mf/commit/7fa792a4b518cd007b5ac41db225e20521063e73)), closes [#864](https://github.com/module-federation/nextjs-mf/issues/864) +* [v7] Async boundary runtime ([#835](https://github.com/module-federation/nextjs-mf/issues/835)) ([840e3b5](https://github.com/module-federation/nextjs-mf/commit/840e3b5bddfbb99b5d8d0f5f24bf5e179e8b52ad)), closes [#851](https://github.com/module-federation/nextjs-mf/issues/851) [#864](https://github.com/module-federation/nextjs-mf/issues/864) +* enable eager sharing ([b1e4418](https://github.com/module-federation/nextjs-mf/commit/b1e4418304afd30c5f4719469db50c17c279a021)) + + +### BREAKING CHANGES + +* automaticAsyncBoundary option has been removed + +* fix: exclude specific pages from page map automatically + +* refactor: conslidate codebase + +* fix: improve hot reload share recovery + +* refactor: remove server jsonp template + +* chore: remove dead code from runtime modules + +* fix: clean up jsonp getCustomJsonpCode + +getting chunk loading global from compiler output options + +* feat: adding cleanInitArrays runtime helper + +* chore: remove share scope hoist and module hoisting system + +* chore: cleanup code + +* chore: remove dead code from add module runtime plugin + +likely can remove whole plugin in future + +* chore: remove logs from delegate modules + +* chore: remove old utils + +* fix: add warning on auto page stitch + +* fix: remove commented out code from InvertedContainerPlugin.ts + +* chore: improve logging to see if its local load or remote load + +* chore: clean up old custom promises factories + +* fix: remove container proxy code + +* fix: remove container proxy code +* automaticAsyncBoundary option has been removed + +* fix: exclude specific pages from page map automatically + +* refactor: conslidate codebase + +* fix: improve hot reload share recovery + +* refactor: remove server jsonp template + +* chore: remove dead code from runtime modules + +* fix: clean up jsonp getCustomJsonpCode + +getting chunk loading global from compiler output options + +* feat: adding cleanInitArrays runtime helper + +* chore: remove share scope hoist and module hoisting system + +* chore: cleanup code + + + +## [6.4.1-beta.3](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.1-beta.2...nextjs-mf-6.4.1-beta.3) (2023-05-03) + + +### Bug Fixes + +* implement exact version resolution ([ee95f5f](https://github.com/module-federation/nextjs-mf/commit/ee95f5f3fb2d0d5757bfff85e85dcf6658673b9c)) +* improve eager modularization ([f593725](https://github.com/module-federation/nextjs-mf/commit/f593725e24672dbf95eae018f2656cab68ec2c4e)) +* improve module and async module loading in runtmie module ([c841a4b](https://github.com/module-federation/nextjs-mf/commit/c841a4bd9e2205b438fc1c8855c66e1eee764e0a)) +* improve stability of chunk push ([98ad6ad](https://github.com/module-federation/nextjs-mf/commit/98ad6ad66ae19429a4808dc9215c6efef6b69fee)) +* improve startup inversion ([42e59f1](https://github.com/module-federation/nextjs-mf/commit/42e59f1b0c58d98c4a16d1efd1ab00d0748311f0)) +* prevent hmr destroying share scope ([ffc1131](https://github.com/module-federation/nextjs-mf/commit/ffc1131b2607387805d3137561df3ae756d07244)) + + +### Features + +* eager load initial consumes ([6a05a5f](https://github.com/module-federation/nextjs-mf/commit/6a05a5f456dd0c5047f034cf7e9d3945a99f737b)) +* install an async boundary runtime module ([cbbc7f5](https://github.com/module-federation/nextjs-mf/commit/cbbc7f53dd908c42cb1897e3aa9e70a9819a002a)) + + + +## [6.4.1-beta.2](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.1-beta.1...nextjs-mf-6.4.1-beta.2) (2023-04-28) + + +### Bug Fixes + +* disable next chunk splits ([2f731ee](https://github.com/module-federation/nextjs-mf/commit/2f731eee497c0f4d3057600f22bc2556e8b32410)) + + + +## [6.4.1-beta.1](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.1-beta.0...nextjs-mf-6.4.1-beta.1) (2023-04-28) + + + +## [6.4.1-beta.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.4.0...nextjs-mf-6.4.1-beta.0) (2023-04-28) + + +### Features + +* [v7] host inversion ([#769](https://github.com/module-federation/nextjs-mf/issues/769)) ([53b9e4b](https://github.com/module-federation/nextjs-mf/commit/53b9e4b4a0dd11adfaf394140133e9244156b839)) +* Custom Startup Runtime modules ([0f4bb27](https://github.com/module-federation/nextjs-mf/commit/0f4bb278a1e3be602c489d39062e7e236c47cca1)) +* Improve module chunk connections ([#802](https://github.com/module-federation/nextjs-mf/issues/802)) ([ce0bd7b](https://github.com/module-federation/nextjs-mf/commit/ce0bd7b16e080f712e6db0bdcd3955a8167c274f)), closes [#803](https://github.com/module-federation/nextjs-mf/issues/803) [#808](https://github.com/module-federation/nextjs-mf/issues/808) [#811](https://github.com/module-federation/nextjs-mf/issues/811) +* remove child compiler pluign ([#780](https://github.com/module-federation/nextjs-mf/issues/780)) ([ed7ce3a](https://github.com/module-federation/nextjs-mf/commit/ed7ce3a6220bf0fa142da50d8101ad4693c8b178)) + + +### BREAKING CHANGES + +* Internal child compilers are no longer used +BREAKING_CHANGE: Internal child compilers are no longer used + + + +## [6.3.1-beta.0](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.3.1...nextjs-mf-6.3.1-beta.0) (2023-04-19) + + +### Bug Fixes + +* cache busting and async quirks when mixing delegates ([1fc6e67](https://github.com/module-federation/nextjs-mf/commit/1fc6e67ee33a3efb53ff59d2b3ac333f1d42a158)) +* ensure app functions with async boundary loader ([717e885](https://github.com/module-federation/nextjs-mf/commit/717e88558475158bf1eb5ae88e53a3624b3277ff)) +* get delegates working ([#527](https://github.com/module-federation/nextjs-mf/issues/527)) ([7655568](https://github.com/module-federation/nextjs-mf/commit/7655568fcef8dbfda40573deb5d3d029c101074c)) +* improved asset pipeline ([63928b2](https://github.com/module-federation/nextjs-mf/commit/63928b28150c2c4e3adb9e14fb7aa54f5cf1578d)) +* move delegate modules into both webpack runtimes ([0570021](https://github.com/module-federation/nextjs-mf/commit/0570021d1040888a9f00394e64f7530a22e74a75)) +* move host remote reg into loader ([188b9e4](https://github.com/module-federation/nextjs-mf/commit/188b9e432b95ba4934a838a49571435ea27b4d0b)) +* peer dependencies metadata ([b603587](https://github.com/module-federation/nextjs-mf/commit/b6035870e5130bfd5b5c70951cc17bb38a50fbdd)) +* put error triggers if delegates are passed non-primitives ([0a780bb](https://github.com/module-federation/nextjs-mf/commit/0a780bb07c9421b58605fc133f236a918ef5a0d8)) +* remove dead code, use commonjs for delegate exports ([ad646d7](https://github.com/module-federation/nextjs-mf/commit/ad646d7306a2442ae6d9b2a72b33fb5ce66a9ba4)) +* solve double async boundary ([88b3f4f](https://github.com/module-federation/nextjs-mf/commit/88b3f4f08b217e2f88b535ec9c7290bad697888b)) +* solve externalization ([49f52e5](https://github.com/module-federation/nextjs-mf/commit/49f52e53ddddc990d31e6aa510d67dc0552a9d9a)) +* support windows paths ([98ca26f](https://github.com/module-federation/nextjs-mf/commit/98ca26f3062b9fa67fc8ba8152fd85eda9b5df10)) +* use EntryPlugin for injection of remotes ([e522c5a](https://github.com/module-federation/nextjs-mf/commit/e522c5ad2b7adcbd6c39f9c5fdb7a3e418277b7a)) + + +### Features + +* delegate module support ([76c9df3](https://github.com/module-federation/nextjs-mf/commit/76c9df3b97d60040466e9a01cfe3f45e8f9c6b78)) +* delegate module support ([3567aa5](https://github.com/module-federation/nextjs-mf/commit/3567aa5f6d0a00ca6df103c796657eb8953bc96a)) +* delegate module support ([8dd154c](https://github.com/module-federation/nextjs-mf/commit/8dd154c261b34183b12250ce204904cd3e085658)) +* delegates part two ([1be2686](https://github.com/module-federation/nextjs-mf/commit/1be2686624798a7df9f447b48279294985b3f592)) +* implement basic single runtime ([2432c3e](https://github.com/module-federation/nextjs-mf/commit/2432c3ec553759ca24d17a46b696c1123a86ec5a)) +* implement module runtime hoisting ([17c5b2f](https://github.com/module-federation/nextjs-mf/commit/17c5b2fc5f67c4321959ae30a69742c3128bc9a5)) +* improve automatic async boundary loader on single compile instance ([63fc327](https://github.com/module-federation/nextjs-mf/commit/63fc3273500d1626c7e8c4dab14268ae5cb9de7a)) +* improve chunk correlation ([22d8afc](https://github.com/module-federation/nextjs-mf/commit/22d8afccff101044fcdeba390656950dbc6eafed)) +* new chunk flushing system for exposed modules ([97a75d8](https://github.com/module-federation/nextjs-mf/commit/97a75d8702f2ddc5e12cff2ac4d24aca1df6f990)) +* new next federation plugin ([7e096df](https://github.com/module-federation/nextjs-mf/commit/7e096df89682369cdc92095be6936b58b9b5787f)) +* new output copy plugin for prod server exposure ([85da209](https://github.com/module-federation/nextjs-mf/commit/85da209103046567bdc93f71d421ea413ac1d37b)) +* remove child compilers ([c124f37](https://github.com/module-federation/nextjs-mf/commit/c124f3797ad327971066a4ad75f0317531653c08)) +* removing old promise template stuff from build utils ([d827cd6](https://github.com/module-federation/nextjs-mf/commit/d827cd60fc12bd65b4091db5f7e3d9b96bcdc12b)) + + +### BREAKING CHANGES + +* Plugin No longer uses child sidecars to create containers. +* deleting support for promiseTemplate + + + ## [6.7.1](https://github.com/module-federation/nextjs-mf/compare/nextjs-mf-6.7.0...nextjs-mf-6.7.1) (2023-06-30) diff --git a/packages/nextjs-mf/README.md b/packages/nextjs-mf/README.md index e69ca1d9150..775d165a827 100644 --- a/packages/nextjs-mf/README.md +++ b/packages/nextjs-mf/README.md @@ -28,47 +28,76 @@ You do not need to share these packages, sharing next internals yourself will ca
See DEFAULT_SHARE_SCOPE: -```js -const DEFAULT_SHARE_SCOPE = { - react: { - singleton: true, +
+ See DEFAULT_SHARE_SCOPE: + +```ts +export const DEFAULT_SHARE_SCOPE: SharedObject = { + 'next/dynamic': { + eager: false, requiredVersion: false, - }, - 'react/': { singleton: true, - requiredVersion: false, + import: undefined, }, - 'react-dom': { - singleton: true, + 'next/head': { + eager: false, requiredVersion: false, + singleton: true, + import: undefined, }, - 'next/dynamic': { + 'next/link': { + eager: true, requiredVersion: false, singleton: true, + import: undefined, }, - 'styled-jsx': { + 'next/router': { requiredVersion: false, singleton: true, + import: false, + eager: false, }, - 'styled-jsx/style': { + 'next/script': { requiredVersion: false, singleton: true, + import: undefined, + eager: false, }, - 'next/link': { + react: { + singleton: true, requiredVersion: false, + eager: false, + import: false, + }, + 'react-dom': { singleton: true, + requiredVersion: false, + eager: false, + import: false, }, - 'next/router': { + 'react/jsx-dev-runtime': { + singleton: true, requiredVersion: false, + import: undefined, + eager: false, + }, + 'react/jsx-runtime': { singleton: true, + requiredVersion: false, + eager: false, + import: false, }, - 'next/script': { + 'styled-jsx': { requiredVersion: false, singleton: true, + import: undefined, + eager: false, }, - 'next/head': { + 'styled-jsx/style': { requiredVersion: false, singleton: true, + import: undefined, + eager: false, }, }; ``` @@ -78,30 +107,24 @@ const DEFAULT_SHARE_SCOPE = { ## Usage ```js -const SampleComponent = dynamic(() => import('next2/sampleComponent'), { - ssr: false, -}); +import React, {lazy} from 'react'; +const SampleComponent = lazy(() => import('next2/sampleComponent')); ``` -If you want support for sync imports. It is possible in next@12 as long as there is an async boundary. +To avoid hydration errors, use `React.lazy` instead of `next/dynamic` for lazy loading federated components. #### See the implementation here: https://github.com/module-federation/module-federation-examples/tree/master/nextjs/home/pages With async boundary installed at the page level. You can then do the following ```js -if (process.browser) { - const SomeHook = require('next2/someHook'); -} -// if client only file +const SomeHook = require('next2/someHook'); import SomeComponent from 'next2/someComponent'; ``` -Make sure you are using `mini-css-extract-plugin@2` - version 2 supports resolving assets through `publicPath:'auto'` - ## Demo -You can see it in action here: https://github.com/module-federation/module-federation-examples/tree/master/nextjs +You can see it in action here: https://github.com/module-federation/module-federation-examples/tree/master/nextjs-ssr ## Options @@ -118,41 +141,21 @@ new NextFederationPlugin({ exposes: {}, shared: {}, extraOptions: { - verbose: boolean, // `false` by default + debug: boolean, // `false` by default exposePages: boolean, // `false` by default enableImageLoaderFix: boolean, // `false` by default enableUrlLoaderFix: boolean, // `false` by default - automaticAsyncBoundary: boolean, // `false` by default skipSharingNextInternals: boolean, // `false` by default }, }); ``` +- `debug` – enables debug mode. It will print additional information about what is going on under the hood. - `exposePages` – exposes automatically all nextjs pages for you and theirs `./pages-map`. - `enableImageLoaderFix` – adds public hostname to all assets bundled by `nextjs-image-loader`. So if you serve remoteEntry from `http://example.com` then all bundled assets will get this hostname in runtime. It's something like Base URL in HTML but for federated modules. - `enableUrlLoaderFix` – adds public hostname to all assets bundled by `url-loader`. -- `automaticAsyncBoundary` – adds automatic async boundary for all federated modules. It's required for sync imports to work. - `skipSharingNextInternals` – disables sharing of next internals. You can use it if you want to share next internals yourself or want to use this plugin on non next applications -### BREAKING CHANGE ABOUT SHARED MODULES: - -Previously, we used to "rekey" all shared packages used in a host in order to prevent eager consumption issues. However, this caused unforeseen issues when trying to share a singleton package, as the package would end up being bundled multiple times per page. - -As a result, we have had to stop rekeying shared modules in userland and only do so on internal Next packages themselves. - -If you need to dangerously share a package using the old method, you can do so by using the following code: - -```js -const shared = { - fakeLodash: { - import: 'lodash', - shareKey: 'lodash', - }, -}; -``` - -Please note that this method is now considered dangerous and should be used with caution. - ## Demo You can see it in action here: https://github.com/module-federation/module-federation-examples/pull/2147 @@ -190,15 +193,8 @@ module.exports = { }, }; -// _app.js or some other file in as high up in the app (like next's new layouts) -// this ensures various parts of next.js are imported and "used" somewhere so that they wont be tree shaken out -// note: this is optional in the latest release, as it is auto-injected by NextFederationPlugin now -import '@module-federation/nextjs-mf/src/include-defaults'; ``` -2. For the consuming application, we'll call it "next1", add an instance of the ModuleFederationPlugin to your webpack config, and ensure you have a [custom Next.js App](https://nextjs.org/docs/advanced-features/custom-app) `pages/_app.js` (or `.tsx`): - Inside that \_app.js or layout.js file, ensure you import `include-defaults` file (this is now optional as include-defaults is auto injected into \_app) - ```js // next.config.js @@ -220,54 +216,43 @@ module.exports = { }, }; -// _app.js or some other file in as high up in the app (like next's new layouts) -// this ensures various parts of next.js are imported and "used" somewhere so that they wont be tree shaken out -// note: this is optional in the latest release, as it is auto-injected by NextFederationPlugin now -import '@module-federation/nextjs-mf/src/include-defaults'; ``` -4. Use next/dynamic or low level api to import remotes. +4. Use react.lazy, low level api, or require/import from to import remotes. ```js -import dynamic from 'next/dynamic'; +import React, {lazy} from 'react'; -const SampleComponent = dynamic(() => window.next2.get('./sampleComponent').then((factory) => factory()), { - ssr: false, -}); +const SampleComponent = lazy(() => window.next2.get('./sampleComponent').then((factory) => { + return {default: factory()} +})); // or -const SampleComponent = dynamic(() => import('next2/sampleComponent'), { - ssr: false, -}); -``` +const SampleComponent = lazy(() => import('next2/sampleComponent')); -## Beta: Delegate modules +//or + + import Sample from "next2/sampleComponent"; +``` -Delegate modules are a new feature in module federation that allow you to control the -loading process of remote modules by delegating it to an internal file bundled by webpack. -This is done by exporting a promise in the delegate file that resolves to a remote/container interface. +## Delegate modules -A container interface is the low-level `{get, init}` API that remote entries expose to a consuming app. -In the browser, a remote container would be window.app1, and in Node, it would be `global.__remote_scope__.app1`. +Delegated modules are now a standard feature in module federation, giving you the ability to manage the loading procedure of remote modules via an internally bundled file by webpack. This is facilitated by exporting a promise in the delegate file that resolves to a remote/container interface. -To use delegate modules, a method for script loading must be implemented in the delegate file. -A common method is to use webpack's built-in `__webpack_require__.l` method, but any method can be used. -This method is exposed to the runtime and is the same method that webpack uses internally to load remotes. +A container interface represents the fundamental `{get, init}` API that remote entries present to a consuming app. Within the browser, a remote container could be `window.app1`, and in Node, it could be `globalThis.__remote_scope__.app1`. -**Delegate modules will require a minimum version of 6.1.x across all apps, -since consumers will need to be able to handle the new container interface.** +Implementing a method for script loading in the delegate file is necessary for the utilization of delegated modules. Although the built-in `__webpack_require__.l` method of webpack is a prevalent method, any method is suitable. This method is made available to the runtime and is identical to the method webpack employs internally to load remotes. -The beta does not currently support chunk flushing, this will be added in a future release. +Please note that using delegated modules demands a minimum version of `6.1.x` across all applications, given that consumers must be capable of handling the new container interface. -Here's an example of using a delegate module with `__webpack_require__.l`: +Here's a sample usage of a delegated module with `__webpack_require__.l`:
See Example: (click) -In this example, the delegate module exports a promise that -loads the remote entry script located at "http://localhost:3000/_next/static/chunks/remoteEntry.js" -based on the `__resourceQuery` variable, which is set by webpack at runtime. -If an error occurs while loading the script, a custom error object is created and the promise is rejected with this error. +In this example, the delegated module exports a promise that loads the remote entry script located at "http://localhost:3000/_next/static/chunks/remoteEntry.js", +based on the `__resourceQuery` variable set by webpack at runtime. +If an error surfaces while loading the script, a unique error object is generated, and the promise is rejected with this error. ```js //next.config.js @@ -275,24 +260,26 @@ const { createDelegatedModule } = require('@module-federation/utilities'); const remotes = { checkout: createDelegatedModule(require.resolve('./remote-delegate.js'), { remote: `checkout@http://localhost:3002/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`, + otherParam: 'testing', }), }; //remote-delegate.js -import { importDelegatedModule } from '@module-federation/utilities'; -//Delegate MUST use module.exports, not export default - this is a webpack limitation -module.exports = new Promise((resolve, reject) => { - console.log('Delegate being called for', __resourceQuery); +// Delegates must utilize module.exports, not export default - this is due to a webpack constraint +// ALL imports MUST BE dynamic imports in here like import() +module.exports = new Promise(async (resolve, reject) => { + const { importDelegatedModule } = await import( + '@module-federation/utilities/src/utils/importDelegatedModule' + ); + // eslint-disable-next-line no-undef const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); - const [global, url] = currentRequest.split('@'); - importDelegatedModule({ global, - url, + url: url + '?' + Date.now(), }) - .then((container) => { - resolve(container); + .then((remote) => { + resolve(remote); }) .catch((err) => reject(err)); }); @@ -324,7 +311,7 @@ For more information on `__resourceQuery` visit: https://webpack.js.org/api/modu ```js // next.config.js - +// its advised you use createDelegatedModule from @module-federation/utilities instead of manually creating the delegate module const remotes = { // pass pointer to remote-delegate, pass delegate remote name as query param, // at runtime webpack will pass this as __resourceQuery @@ -351,9 +338,9 @@ const remotes = { // remote-delegate.js module.exports = new Promise((resolve, reject) => { // some node specific for NodeFederation - if (!global.__remote_scope__) { + if (!globalThis.__remote_scope__) { // create a global scope for container, similar to how remotes are set on window in the browser - global.__remote_scope__ = { + globalThis.__remote_scope__ = { _config: {}, }; } @@ -364,7 +351,7 @@ module.exports = new Promise((resolve, reject) => { const [containerGlobal, url] = currentRequest.split('@'); // if node server, register the containers known origins if (typeof window === 'undefined') { - global.__remote_scope__._config[global] = url; + globalThis.__remote_scope__._config[global] = url; } const __webpack_error__ = new Error(); // if you use NodeFederationPlugin, ive build a server-side version of __webpack_require__.l, with the same api. @@ -373,7 +360,7 @@ module.exports = new Promise((resolve, reject) => { url, function (event) { // resolve promise with container, for browser env or node env. - const container = typeof window === 'undefined' ? global.__remote_scope__[containerGlobal] : window[containerGlobal]; + const container = typeof window === 'undefined' ? globalThis.__remote_scope__[containerGlobal] : window[containerGlobal]; console.log('delegate resolving', container); if (typeof container !== 'undefined') return resolve(container); var realSrc = event && event.target && event.target.src; @@ -450,6 +437,10 @@ class MyDocument extends Document { } ``` +## For Express.js + +Hot reloading Express.js required additional steps: https://github.com/module-federation/universe/blob/main/packages/node/README.md + ## Contact If you have any questions or need to report a bug diff --git a/packages/nextjs-mf/__snapshots__/chunk-intergration.test.ts.snap b/packages/nextjs-mf/__snapshots__/chunk-intergration.test.ts.snap new file mode 100644 index 00000000000..367b6776e3b --- /dev/null +++ b/packages/nextjs-mf/__snapshots__/chunk-intergration.test.ts.snap @@ -0,0 +1,7155 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Next.js build output client modules main chunk 1`] = ` +[ + "../../node_modules/@swc/helpers/lib/_async_to_generator.js", + "../../node_modules/@swc/helpers/lib/_extends.js", + "../../node_modules/@swc/helpers/lib/_interop_require_default.js", + "../../node_modules/@swc/helpers/lib/_interop_require_wildcard.js", + "../../node_modules/@swc/helpers/lib/_object_without_properties_loose.js", + "../../node_modules/client-only/index.js", + "../../node_modules/next/dist/build/polyfills/polyfill-module.js", + "../../node_modules/next/dist/compiled/@next/react-dev-overlay/dist/client.js", + "../../node_modules/next/dist/client/add-base-path.js", + "../../node_modules/next/dist/client/add-locale.js", + "../../node_modules/next/dist/client/detect-domain-locale.js", + "../../node_modules/next/dist/client/dev/dev-build-watcher.js", + "../../node_modules/next/dist/client/dev/error-overlay/format-webpack-messages.js", + "../../node_modules/next/dist/client/dev/error-overlay/hot-dev-client.js", + "../../node_modules/next/dist/client/dev/error-overlay/websocket.js", + "../../node_modules/next/dist/client/dev/fouc.js", + "../../node_modules/next/dist/client/dev/on-demand-entries-client.js", + "../../node_modules/next/dist/client/dev/webpack-hot-middleware-client.js", + "../../node_modules/next/dist/client/get-domain-locale.js", + "../../node_modules/next/dist/client/has-base-path.js", + "../../node_modules/next/dist/client/head-manager.js", + "../../node_modules/next/dist/client/index.js", + "../../node_modules/next/dist/client/link.js", + "../../node_modules/next/dist/client/next-dev.js", + "../../node_modules/next/dist/client/normalize-trailing-slash.js", + "../../node_modules/next/dist/client/on-recoverable-error.js", + "../../node_modules/next/dist/client/page-loader.js", + "../../node_modules/next/dist/client/performance-relayer.js", + "../../node_modules/next/dist/client/portal/index.js", + "../../node_modules/next/dist/client/remove-base-path.js", + "../../node_modules/next/dist/client/remove-locale.js", + "../../node_modules/next/dist/client/request-idle-callback.js", + "../../node_modules/next/dist/client/route-announcer.js", + "../../node_modules/next/dist/client/route-loader.js", + "../../node_modules/next/dist/client/router.js", + "../../node_modules/next/dist/client/script.js", + "../../node_modules/next/dist/client/trusted-types.js", + "../../node_modules/next/dist/client/use-intersection.js", + "../../node_modules/next/dist/client/with-router.js", + "../../node_modules/next/dist/compiled/strip-ansi/index.js", + "../../node_modules/next/dist/pages/_app.js", + "../../node_modules/next/dist/pages/_error.js", + "../../node_modules/next/dist/shared/lib/amp-context.js", + "../../node_modules/next/dist/shared/lib/amp-mode.js", + "../../node_modules/next/dist/shared/lib/app-router-context.js", + "../../node_modules/next/dist/shared/lib/dynamic.js", + "../../node_modules/next/dist/shared/lib/escape-regexp.js", + "../../node_modules/next/dist/shared/lib/head-manager-context.js", + "../../node_modules/next/dist/shared/lib/head.js", + "../../node_modules/next/dist/shared/lib/hooks-client-context.js", + "../../node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js", + "../../node_modules/next/dist/shared/lib/image-config-context.js", + "../../node_modules/next/dist/shared/lib/image-config.js", + "../../node_modules/next/dist/shared/lib/is-plain-object.js", + "../../node_modules/next/dist/shared/lib/lazy-dynamic/no-ssr-error.js", + "../../node_modules/next/dist/shared/lib/loadable-context.js", + "../../node_modules/next/dist/shared/lib/loadable.js", + "../../node_modules/next/dist/shared/lib/mitt.js", + "../../node_modules/next/dist/shared/lib/page-path/denormalize-page-path.js", + "../../node_modules/next/dist/shared/lib/page-path/normalize-path-sep.js", + "../../node_modules/next/dist/shared/lib/router-context.js", + "../../node_modules/next/dist/shared/lib/router/adapters.js", + "../../node_modules/next/dist/shared/lib/router/router.js", + "../../node_modules/next/dist/shared/lib/router/utils/add-locale.js", + "../../node_modules/next/dist/shared/lib/router/utils/add-path-prefix.js", + "../../node_modules/next/dist/shared/lib/router/utils/add-path-suffix.js", + "../../node_modules/next/dist/shared/lib/router/utils/compare-states.js", + "../../node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js", + "../../node_modules/next/dist/shared/lib/router/utils/format-url.js", + "../../node_modules/next/dist/shared/lib/router/utils/get-asset-path-from-route.js", + "../../node_modules/next/dist/shared/lib/router/utils/get-next-pathname-info.js", + "../../node_modules/next/dist/shared/lib/router/utils/handle-smooth-scroll.js", + "../../node_modules/next/dist/shared/lib/router/utils/index.js", + "../../node_modules/next/dist/shared/lib/router/utils/interpolate-as.js", + "../../node_modules/next/dist/shared/lib/router/utils/is-bot.js", + "../../node_modules/next/dist/shared/lib/router/utils/is-dynamic.js", + "../../node_modules/next/dist/shared/lib/router/utils/is-local-url.js", + "../../node_modules/next/dist/shared/lib/router/utils/omit.js", + "../../node_modules/next/dist/shared/lib/router/utils/parse-path.js", + "../../node_modules/next/dist/shared/lib/router/utils/parse-relative-url.js", + "../../node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js", + "../../node_modules/next/dist/shared/lib/router/utils/querystring.js", + "../../node_modules/next/dist/shared/lib/router/utils/remove-path-prefix.js", + "../../node_modules/next/dist/shared/lib/router/utils/remove-trailing-slash.js", + "../../node_modules/next/dist/shared/lib/router/utils/resolve-href.js", + "../../node_modules/next/dist/shared/lib/router/utils/route-matcher.js", + "../../node_modules/next/dist/shared/lib/router/utils/route-regex.js", + "../../node_modules/next/dist/shared/lib/router/utils/sorted-routes.js", + "../../node_modules/next/dist/shared/lib/runtime-config.js", + "../../node_modules/next/dist/shared/lib/side-effect.js", + "../../node_modules/next/dist/shared/lib/utils.js", + "../../node_modules/next/dist/shared/lib/utils/warn-once.js", + "../../node_modules/styled-jsx/dist/index/index.js", + "../../node_modules/next/dist/compiled/anser/index.js", + "../../node_modules/next/dist/compiled/css.escape/css.escape.js", + "../../node_modules/next/dist/compiled/platform/platform.js", + "../../node_modules/next/dist/compiled/react-is/cjs/react-is.development.js", + "../../node_modules/next/dist/compiled/react-is/index.js", + "../../node_modules/next/dist/compiled/stacktrace-parser/stack-trace-parser.cjs.js", + "../../node_modules/next/dist/compiled/web-vitals/web-vitals.js", + "../../node_modules/next/dist/lib/is-api-route.js", + "../../node_modules/next/dist/lib/is-error.js", + "../../node_modules/next/dynamic.js?pop", + "../../node_modules/next/head.js?pop", + "../../node_modules/next/link.js?pop", + "../../node_modules/next/router.js?pop", + "../../node_modules/next/script.js?pop", + "../../node_modules/process/browser.js", + "../../node_modules/react-dom/cjs/react-dom.development.js", + "../../node_modules/react-dom/client.js", + "../../node_modules/react-dom/index.js?pop", + "../../node_modules/react/cjs/react-jsx-dev-runtime.development.js", + "../../node_modules/react/cjs/react-jsx-runtime.development.js", + "../../node_modules/react/cjs/react.development.js", + "../../node_modules/react/index.js?pop", + "../../node_modules/react/jsx-dev-runtime.js?pop", + "../../node_modules/react/jsx-runtime.js?pop", + "../../node_modules/scheduler/cjs/scheduler.development.js", + "../../node_modules/scheduler/index.js", + "../../node_modules/styled-jsx/index.js?pop", + "../../node_modules/styled-jsx/style.js?pop", + "?d22b", + "../../dist/packages/nextjs-mf/src/internal-delegate-hoist.js", +] +`; + +exports[`Next.js build output client partial remote 1`] = ` +""use strict"; +(self["webpackChunkhome_app"] = self["webpackChunkhome_app"] || []).push([["home_app_single"],{ + +/***/ "webpack/container/entry/home_app": +/*!***********************!*\\ + !*** container entry ***! + \\***********************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +var moduleMap = { + "./pages-map": function() { + return __webpack_require__.e("dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_dist_packages_nextjs-mf_src_loaders_-50dce4").then(function() { return function() { return (__webpack_require__(/*! ../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js */ "../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js")); }; }); + }, + "./pages-map-v2": function() { + return __webpack_require__.e("dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_v2_dist_packages_nextjs-mf_src_loade-8dd7f8").then(function() { return function() { return (__webpack_require__(/*! ../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js?v2!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js */ "../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js?v2!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js")); }; }); + }, + "./pages/dynamic-remote": function() { + return __webpack_require__.e("pages_dynamic-remote_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/dynamic-remote.js */ "./pages/dynamic-remote.js")); }; }); + }, + "./pages/index": function() { + return __webpack_require__.e("pages_index_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/index.tsx */ "./pages/index.tsx")); }; }); + }, + "./pages/checkout/[...slug]": function() { + return __webpack_require__.e("pages_checkout_slug_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/[...slug].tsx */ "./pages/checkout/[...slug].tsx")); }; }); + }, + "./pages/checkout/[pid]": function() { + return __webpack_require__.e("pages_checkout_pid_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/[pid].tsx */ "./pages/checkout/[pid].tsx")); }; }); + }, + "./pages/checkout/exposed-pages": function() { + return __webpack_require__.e("pages_checkout_exposed-pages_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/exposed-pages.tsx */ "./pages/checkout/exposed-pages.tsx")); }; }); + }, + "./pages/checkout/index": function() { + return __webpack_require__.e("pages_checkout_index_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/index.tsx */ "./pages/checkout/index.tsx")); }; }); + }, + "./pages/checkout/test-check-button": function() { + return __webpack_require__.e("pages_checkout_test-check-button_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/test-check-button.tsx */ "./pages/checkout/test-check-button.tsx")); }; }); + }, + "./pages/checkout/test-title": function() { + return __webpack_require__.e("pages_checkout_test-title_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/test-title.tsx */ "./pages/checkout/test-title.tsx")); }; }); + }, + "./pages/home/exposed-pages": function() { + return __webpack_require__.e("pages_home_exposed-pages_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/exposed-pages.tsx */ "./pages/home/exposed-pages.tsx")); }; }); + }, + "./pages/home/test-broken-remotes": function() { + return __webpack_require__.e("pages_home_test-broken-remotes_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-broken-remotes.tsx */ "./pages/home/test-broken-remotes.tsx")); }; }); + }, + "./pages/home/test-remote-hook": function() { + return __webpack_require__.e("pages_home_test-remote-hook_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-remote-hook.tsx */ "./pages/home/test-remote-hook.tsx")); }; }); + }, + "./pages/home/test-shared-nav": function() { + return __webpack_require__.e("pages_home_test-shared-nav_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-shared-nav.tsx */ "./pages/home/test-shared-nav.tsx")); }; }); + }, + "./pages/shop/exposed-pages": function() { + return __webpack_require__.e("pages_shop_exposed-pages_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/exposed-pages.js */ "./pages/shop/exposed-pages.js")); }; }); + }, + "./pages/shop/index": function() { + return __webpack_require__.e("pages_shop_index_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/index.js */ "./pages/shop/index.js")); }; }); + }, + "./pages/shop/test-webpack-png": function() { + return __webpack_require__.e("pages_shop_test-webpack-png_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/test-webpack-png.js */ "./pages/shop/test-webpack-png.js")); }; }); + }, + "./pages/shop/test-webpack-svg": function() { + return __webpack_require__.e("pages_shop_test-webpack-svg_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/test-webpack-svg.js */ "./pages/shop/test-webpack-svg.js")); }; }); + }, + "./pages/shop/products/[...slug]": function() { + return __webpack_require__.e("pages_shop_products_slug_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/products/[...slug].js */ "./pages/shop/products/[...slug].js")); }; }); + }, + "./SharedNav": function() { + return __webpack_require__.e("components_SharedNav_tsx").then(function() { return function() { return (__webpack_require__(/*! ./components/SharedNav */ "./components/SharedNav.tsx")); }; }); + }, + "./menu": function() { + return __webpack_require__.e("components_menu_tsx").then(function() { return function() { return (__webpack_require__(/*! ./components/menu */ "./components/menu.tsx")); }; }); + } +}; +var get = function(module, getScope) { + __webpack_require__.R = getScope; + getScope = ( + __webpack_require__.o(moduleMap, module) + ? moduleMap[module]() + : Promise.resolve().then(function() { + throw new Error('Module "' + module + '" does not exist in container.'); + }) + ); + __webpack_require__.R = undefined; + return getScope; +}; +var init = function(shareScope, initScope) { + if (!__webpack_require__.S) return; + var name = "default" + var oldScope = __webpack_require__.S[name]; + if(oldScope && oldScope !== shareScope) throw new Error("Container initialization failed as it has already been initialized with a different share scope"); + __webpack_require__.S[name] = shareScope; + return __webpack_require__.I(name, initScope); +}; + +// This exports getters to disallow modifications +__webpack_require__.d(exports, { + get: function() { return get; }, + init: function() { return init; } +}); + +/***/ }) + +}, +/******/ function(__webpack_require__) { // webpackRuntimeModules +/******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); } +/******/ var __webpack_exports__ = (__webpack_exec__("webpack/container/entry/home_app")); +/******/ window.home_app_single = __webpack_exports__; +/******/ } +]); +//# sourceMappingURL=home_app_single.js.map" +`; + +exports[`Next.js build output client remoteEntry.js 1`] = ` +"/******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "webpack/container/entry/home_app": +/*!***********************!*\\ + !*** container entry ***! + \\***********************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +var moduleMap = { + "./pages-map": function() { + return __webpack_require__.e("dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_dist_packages_nextjs-mf_src_loaders_-50dce4").then(function() { return function() { return (__webpack_require__(/*! ../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js */ "../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js")); }; }); + }, + "./pages-map-v2": function() { + return __webpack_require__.e("dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_v2_dist_packages_nextjs-mf_src_loade-8dd7f8").then(function() { return function() { return (__webpack_require__(/*! ../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js?v2!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js */ "../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js?v2!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js")); }; }); + }, + "./pages/dynamic-remote": function() { + return __webpack_require__.e("pages_dynamic-remote_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/dynamic-remote.js */ "./pages/dynamic-remote.js")); }; }); + }, + "./pages/index": function() { + return __webpack_require__.e("pages_index_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/index.tsx */ "./pages/index.tsx")); }; }); + }, + "./pages/checkout/[...slug]": function() { + return __webpack_require__.e("pages_checkout_slug_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/[...slug].tsx */ "./pages/checkout/[...slug].tsx")); }; }); + }, + "./pages/checkout/[pid]": function() { + return __webpack_require__.e("pages_checkout_pid_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/[pid].tsx */ "./pages/checkout/[pid].tsx")); }; }); + }, + "./pages/checkout/exposed-pages": function() { + return __webpack_require__.e("pages_checkout_exposed-pages_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/exposed-pages.tsx */ "./pages/checkout/exposed-pages.tsx")); }; }); + }, + "./pages/checkout/index": function() { + return __webpack_require__.e("pages_checkout_index_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/index.tsx */ "./pages/checkout/index.tsx")); }; }); + }, + "./pages/checkout/test-check-button": function() { + return __webpack_require__.e("pages_checkout_test-check-button_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/test-check-button.tsx */ "./pages/checkout/test-check-button.tsx")); }; }); + }, + "./pages/checkout/test-title": function() { + return __webpack_require__.e("pages_checkout_test-title_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/test-title.tsx */ "./pages/checkout/test-title.tsx")); }; }); + }, + "./pages/home/exposed-pages": function() { + return __webpack_require__.e("pages_home_exposed-pages_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/exposed-pages.tsx */ "./pages/home/exposed-pages.tsx")); }; }); + }, + "./pages/home/test-broken-remotes": function() { + return __webpack_require__.e("pages_home_test-broken-remotes_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-broken-remotes.tsx */ "./pages/home/test-broken-remotes.tsx")); }; }); + }, + "./pages/home/test-remote-hook": function() { + return __webpack_require__.e("pages_home_test-remote-hook_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-remote-hook.tsx */ "./pages/home/test-remote-hook.tsx")); }; }); + }, + "./pages/home/test-shared-nav": function() { + return __webpack_require__.e("pages_home_test-shared-nav_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-shared-nav.tsx */ "./pages/home/test-shared-nav.tsx")); }; }); + }, + "./pages/shop/exposed-pages": function() { + return __webpack_require__.e("pages_shop_exposed-pages_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/exposed-pages.js */ "./pages/shop/exposed-pages.js")); }; }); + }, + "./pages/shop/index": function() { + return __webpack_require__.e("pages_shop_index_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/index.js */ "./pages/shop/index.js")); }; }); + }, + "./pages/shop/test-webpack-png": function() { + return __webpack_require__.e("pages_shop_test-webpack-png_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/test-webpack-png.js */ "./pages/shop/test-webpack-png.js")); }; }); + }, + "./pages/shop/test-webpack-svg": function() { + return __webpack_require__.e("pages_shop_test-webpack-svg_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/test-webpack-svg.js */ "./pages/shop/test-webpack-svg.js")); }; }); + }, + "./pages/shop/products/[...slug]": function() { + return __webpack_require__.e("pages_shop_products_slug_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/products/[...slug].js */ "./pages/shop/products/[...slug].js")); }; }); + }, + "./SharedNav": function() { + return __webpack_require__.e("components_SharedNav_tsx").then(function() { return function() { return (__webpack_require__(/*! ./components/SharedNav */ "./components/SharedNav.tsx")); }; }); + }, + "./menu": function() { + return __webpack_require__.e("components_menu_tsx").then(function() { return function() { return (__webpack_require__(/*! ./components/menu */ "./components/menu.tsx")); }; }); + } +}; +var get = function(module, getScope) { + __webpack_require__.R = getScope; + getScope = ( + __webpack_require__.o(moduleMap, module) + ? moduleMap[module]() + : Promise.resolve().then(function() { + throw new Error('Module "' + module + '" does not exist in container.'); + }) + ); + __webpack_require__.R = undefined; + return getScope; +}; +var init = function(shareScope, initScope) { + if (!__webpack_require__.S) return; + var name = "default" + var oldScope = __webpack_require__.S[name]; + if(oldScope && oldScope !== shareScope) throw new Error("Container initialization failed as it has already been initialized with a different share scope"); + __webpack_require__.S[name] = shareScope; + return __webpack_require__.I(name, initScope); +}; + +// This exports getters to disallow modifications +__webpack_require__.d(exports, { + get: function() { return get; }, + init: function() { return init; } +}); + +/***/ }), + +/***/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js": +/*!**************************************************************************************************************************************!*\\ + !*** ../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js ***! + \\**************************************************************************************************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var __resourceQuery = "?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js"; + +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { + const { importDelegatedModule } = await __webpack_require__.e(/*! import() */ "dist_packages_utilities_src_utils_common_js").then(__webpack_require__.bind(__webpack_require__, /*! @module-federation/utilities/src/utils/common */ "../../dist/packages/utilities/src/utils/common.js")); + // eslint-disable-next-line no-undef + const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); + const [global, url] = currentRequest.split('@'); + importDelegatedModule({ + global, + url: url + '?' + Date.now(), + }) + .then((remote) => { + resolve(remote); + }) + .catch((err) => reject(err)); +}); +//# sourceMappingURL=default-delegate.js.map + +/***/ }), + +/***/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js": +/*!**********************************************************************************************************************************!*\\ + !*** ../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js ***! + \\**********************************************************************************************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var __resourceQuery = "?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js"; + +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { + const { importDelegatedModule } = await __webpack_require__.e(/*! import() */ "dist_packages_utilities_src_utils_common_js").then(__webpack_require__.bind(__webpack_require__, /*! @module-federation/utilities/src/utils/common */ "../../dist/packages/utilities/src/utils/common.js")); + // eslint-disable-next-line no-undef + const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); + const [global, url] = currentRequest.split('@'); + importDelegatedModule({ + global, + url: url + '?' + Date.now(), + }) + .then((remote) => { + resolve(remote); + }) + .catch((err) => reject(err)); +}); +//# sourceMappingURL=default-delegate.js.map + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ if (cachedModule.error !== undefined) throw cachedModule.error; +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ id: moduleId, +/******/ loaded: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ var threw = true; +/******/ try { +/******/ var execOptions = { id: moduleId, module: module, factory: __webpack_modules__[moduleId], require: __webpack_require__ }; +/******/ __webpack_require__.i.forEach(function(handler) { handler(execOptions); }); +/******/ module = execOptions.module; +/******/ execOptions.factory.call(module.exports, module, module.exports, execOptions.require); +/******/ threw = false; +/******/ } finally { +/******/ if(threw) delete __webpack_module_cache__[moduleId]; +/******/ } +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = __webpack_modules__; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = __webpack_module_cache__; +/******/ +/******/ // expose the module execution interceptor +/******/ __webpack_require__.i = []; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/create fake namespace object */ +/******/ !function() { +/******/ var getProto = Object.getPrototypeOf ? function(obj) { return Object.getPrototypeOf(obj); } : function(obj) { return obj.__proto__; }; +/******/ var leafPrototypes; +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 16: return value when it's Promise-like +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = this(value); +/******/ if(mode & 8) return value; +/******/ if(typeof value === 'object' && value) { +/******/ if((mode & 4) && value.__esModule) return value; +/******/ if((mode & 16) && typeof value.then === 'function') return value; +/******/ } +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ var def = {}; +/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)]; +/******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) { +/******/ Object.getOwnPropertyNames(current).forEach(function(key) { def[key] = function() { return value[key]; }; }); +/******/ } +/******/ def['default'] = function() { return value; }; +/******/ __webpack_require__.d(ns, def); +/******/ return ns; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/ensure chunk */ +/******/ !function() { +/******/ __webpack_require__.f = {}; +/******/ // This file contains only the entry chunk. +/******/ // The chunk loading function for additional chunks +/******/ __webpack_require__.e = function(chunkId) { +/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) { +/******/ __webpack_require__.f[key](chunkId, promises); +/******/ return promises; +/******/ }, [])); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/get javascript chunk filename */ +/******/ !function() { +/******/ // This function allow to reference async chunks +/******/ __webpack_require__.u = function(chunkId) { +/******/ // return url for filenames based on template +/******/ return "static/chunks/" + chunkId + ".js"; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/get javascript update chunk filename */ +/******/ !function() { +/******/ // This function allow to reference all chunks +/******/ __webpack_require__.hu = function(chunkId) { +/******/ // return url for filenames based on template +/******/ return "static/webpack/" + chunkId + "." + __webpack_require__.h() + ".hot-update.js"; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/get update manifest filename */ +/******/ !function() { +/******/ __webpack_require__.hmrF = function() { return "static/webpack/" + __webpack_require__.h() + ".home_app.hot-update.json"; }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/getFullHash */ +/******/ !function() { +/******/ __webpack_require__.h = function() { return "8a32b85331c94bdf"; } +/******/ }(); +/******/ +/******/ /* webpack/runtime/global */ +/******/ !function() { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/******/ /* webpack/runtime/load script */ +/******/ !function() { +/******/ var inProgress = {}; +/******/ var dataWebpackPrefix = "home_app:"; +/******/ // loadScript function to load a script via script tag +/******/ __webpack_require__.l = function(url, done, key, chunkId) { +/******/ if(inProgress[url]) { inProgress[url].push(done); return; } +/******/ var script, needAttach; +/******/ if(key !== undefined) { +/******/ var scripts = document.getElementsByTagName("script"); +/******/ for(var i = 0; i < scripts.length; i++) { +/******/ var s = scripts[i]; +/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; } +/******/ } +/******/ } +/******/ if(!script) { +/******/ needAttach = true; +/******/ script = document.createElement('script'); +/******/ +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120; +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); +/******/ } +/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key); +/******/ script.src = __webpack_require__.tu(url); +/******/ } +/******/ inProgress[url] = [done]; +/******/ var onScriptComplete = function(prev, event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var doneFns = inProgress[url]; +/******/ delete inProgress[url]; +/******/ script.parentNode && script.parentNode.removeChild(script); +/******/ doneFns && doneFns.forEach(function(fn) { return fn(event); }); +/******/ if(prev) return prev(event); +/******/ } +/******/ ; +/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000); +/******/ script.onerror = onScriptComplete.bind(null, script.onerror); +/******/ script.onload = onScriptComplete.bind(null, script.onload); +/******/ needAttach && document.head.appendChild(script); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ !function() { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/node module decorator */ +/******/ !function() { +/******/ __webpack_require__.nmd = function(module) { +/******/ module.paths = []; +/******/ if (!module.children) module.children = []; +/******/ return module; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/remotes loading */ +/******/ !function() { +/******/ var chunkMapping = { +/******/ "pages_checkout_slug_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/[...slug]" +/******/ ], +/******/ "pages_checkout_pid_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/[pid]" +/******/ ], +/******/ "pages_checkout_exposed-pages_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/exposed-pages" +/******/ ], +/******/ "pages_checkout_index_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/index" +/******/ ], +/******/ "pages_checkout_test-check-button_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/test-check-button" +/******/ ], +/******/ "pages_checkout_test-title_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/test-title" +/******/ ], +/******/ "pages_home_test-remote-hook_tsx_hasBoundary": [ +/******/ "webpack/container/remote/shop/useCustomRemoteHook" +/******/ ], +/******/ "pages_shop_exposed-pages_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/exposed-pages" +/******/ ], +/******/ "pages_shop_index_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/index" +/******/ ], +/******/ "pages_shop_test-webpack-png_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-png" +/******/ ], +/******/ "pages_shop_test-webpack-svg_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-svg" +/******/ ], +/******/ "pages_shop_products_slug_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/products/[...slug]" +/******/ ], +/******/ "webpack_container_remote_checkout_CheckoutTitle": [ +/******/ "webpack/container/remote/checkout/CheckoutTitle" +/******/ ], +/******/ "webpack_container_remote_checkout_ButtonOldAnt": [ +/******/ "webpack/container/remote/checkout/ButtonOldAnt" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackSvg": [ +/******/ "webpack/container/remote/shop/WebpackSvg" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackPng": [ +/******/ "webpack/container/remote/shop/WebpackPng" +/******/ ] +/******/ }; +/******/ var idToExternalAndNameMapping = { +/******/ "webpack/container/remote/checkout/pages/checkout/[...slug]": [ +/******/ "default", +/******/ "./pages/checkout/[...slug]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/[pid]": [ +/******/ "default", +/******/ "./pages/checkout/[pid]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/exposed-pages": [ +/******/ "default", +/******/ "./pages/checkout/exposed-pages", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/index": [ +/******/ "default", +/******/ "./pages/checkout/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/test-check-button": [ +/******/ "default", +/******/ "./pages/checkout/test-check-button", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/test-title": [ +/******/ "default", +/******/ "./pages/checkout/test-title", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/useCustomRemoteHook": [ +/******/ "default", +/******/ "./useCustomRemoteHook", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/exposed-pages": [ +/******/ "default", +/******/ "./pages/shop/exposed-pages", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/index": [ +/******/ "default", +/******/ "./pages/shop/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-png": [ +/******/ "default", +/******/ "./pages/shop/test-webpack-png", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-svg": [ +/******/ "default", +/******/ "./pages/shop/test-webpack-svg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/products/[...slug]": [ +/******/ "default", +/******/ "./pages/shop/products/[...slug]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/CheckoutTitle": [ +/******/ "default", +/******/ "./CheckoutTitle", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/ButtonOldAnt": [ +/******/ "default", +/******/ "./ButtonOldAnt", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackSvg": [ +/******/ "default", +/******/ "./WebpackSvg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackPng": [ +/******/ "default", +/******/ "./WebpackPng", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ] +/******/ }; +/******/ __webpack_require__.f.remotes = function(chunkId, promises) { +/******/ if(__webpack_require__.o(chunkMapping, chunkId)) { +/******/ chunkMapping[chunkId].forEach(function(id) { +/******/ var getScope = __webpack_require__.R; +/******/ if(!getScope) getScope = []; +/******/ var data = idToExternalAndNameMapping[id]; +/******/ if(getScope.indexOf(data) >= 0) return; +/******/ getScope.push(data); +/******/ if(data.p) return promises.push(data.p); +/******/ var onError = function(error) { +/******/ if(!error) error = new Error("Container missing"); +/******/ if(typeof error.message === "string") +/******/ error.message += '\\nwhile loading "' + data[1] + '" from ' + data[2]; +/******/ __webpack_require__.m[id] = function() { +/******/ throw error; +/******/ } +/******/ data.p = 0; +/******/ }; +/******/ var handleFunction = function(fn, arg1, arg2, d, next, first) { +/******/ try { +/******/ var promise = fn(arg1, arg2); +/******/ if(promise && promise.then) { +/******/ var p = promise.then(function(result) { return next(result, d); }, onError); +/******/ if(first) promises.push(data.p = p); else return p; +/******/ } else { +/******/ return next(promise, d, first); +/******/ } +/******/ } catch(error) { +/******/ onError(error); +/******/ } +/******/ } +/******/ var onExternal = function(external, _, first) { return external ? handleFunction(__webpack_require__.I, data[0], 0, external, onInitialized, first) : onError(); }; +/******/ var onInitialized = function(_, external, first) { return handleFunction(external.get, data[1], getScope, 0, onFactory, first); }; +/******/ var onFactory = function(factory) { +/******/ data.p = 1; +/******/ __webpack_require__.m[id] = function(module) { +/******/ module.exports = factory(); +/******/ } +/******/ }; +/******/ handleFunction(__webpack_require__, data[2], 0, 0, onExternal, 1); +/******/ }); +/******/ } +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/remotes loading */ +/******/ !function() { +/******/ var chunkMapping = { +/******/ "pages_checkout_slug_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/[...slug]" +/******/ ], +/******/ "pages_checkout_pid_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/[pid]" +/******/ ], +/******/ "pages_checkout_exposed-pages_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/exposed-pages" +/******/ ], +/******/ "pages_checkout_index_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/index" +/******/ ], +/******/ "pages_checkout_test-check-button_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/test-check-button" +/******/ ], +/******/ "pages_checkout_test-title_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/test-title" +/******/ ], +/******/ "pages_home_test-remote-hook_tsx_hasBoundary": [ +/******/ "webpack/container/remote/shop/useCustomRemoteHook" +/******/ ], +/******/ "pages_shop_exposed-pages_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/exposed-pages" +/******/ ], +/******/ "pages_shop_index_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/index" +/******/ ], +/******/ "pages_shop_test-webpack-png_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-png" +/******/ ], +/******/ "pages_shop_test-webpack-svg_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-svg" +/******/ ], +/******/ "pages_shop_products_slug_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/products/[...slug]" +/******/ ], +/******/ "webpack_container_remote_checkout_CheckoutTitle": [ +/******/ "webpack/container/remote/checkout/CheckoutTitle" +/******/ ], +/******/ "webpack_container_remote_checkout_ButtonOldAnt": [ +/******/ "webpack/container/remote/checkout/ButtonOldAnt" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackSvg": [ +/******/ "webpack/container/remote/shop/WebpackSvg" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackPng": [ +/******/ "webpack/container/remote/shop/WebpackPng" +/******/ ] +/******/ }; +/******/ var idToExternalAndNameMapping = { +/******/ "webpack/container/remote/checkout/pages/checkout/[...slug]": [ +/******/ "default", +/******/ "./pages/checkout/[...slug]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/[pid]": [ +/******/ "default", +/******/ "./pages/checkout/[pid]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/exposed-pages": [ +/******/ "default", +/******/ "./pages/checkout/exposed-pages", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/index": [ +/******/ "default", +/******/ "./pages/checkout/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/test-check-button": [ +/******/ "default", +/******/ "./pages/checkout/test-check-button", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/test-title": [ +/******/ "default", +/******/ "./pages/checkout/test-title", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/useCustomRemoteHook": [ +/******/ "default", +/******/ "./useCustomRemoteHook", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/exposed-pages": [ +/******/ "default", +/******/ "./pages/shop/exposed-pages", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/index": [ +/******/ "default", +/******/ "./pages/shop/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-png": [ +/******/ "default", +/******/ "./pages/shop/test-webpack-png", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-svg": [ +/******/ "default", +/******/ "./pages/shop/test-webpack-svg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/products/[...slug]": [ +/******/ "default", +/******/ "./pages/shop/products/[...slug]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/CheckoutTitle": [ +/******/ "default", +/******/ "./CheckoutTitle", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/ButtonOldAnt": [ +/******/ "default", +/******/ "./ButtonOldAnt", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackSvg": [ +/******/ "default", +/******/ "./WebpackSvg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackPng": [ +/******/ "default", +/******/ "./WebpackPng", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ] +/******/ }; +/******/ __webpack_require__.f.remotes = function(chunkId, promises) { +/******/ if(__webpack_require__.o(chunkMapping, chunkId)) { +/******/ chunkMapping[chunkId].forEach(function(id) { +/******/ var getScope = __webpack_require__.R; +/******/ if(!getScope) getScope = []; +/******/ var data = idToExternalAndNameMapping[id]; +/******/ if(getScope.indexOf(data) >= 0) return; +/******/ getScope.push(data); +/******/ if(data.p) return promises.push(data.p); +/******/ var onError = function(error) { +/******/ if(!error) error = new Error("Container missing"); +/******/ if(typeof error.message === "string") +/******/ error.message += '\\nwhile loading "' + data[1] + '" from ' + data[2]; +/******/ __webpack_require__.m[id] = function() { +/******/ throw error; +/******/ } +/******/ data.p = 0; +/******/ }; +/******/ var handleFunction = function(fn, arg1, arg2, d, next, first) { +/******/ try { +/******/ var promise = fn(arg1, arg2); +/******/ if(promise && promise.then) { +/******/ var p = promise.then(function(result) { return next(result, d); }, onError); +/******/ if(first) promises.push(data.p = p); else return p; +/******/ } else { +/******/ return next(promise, d, first); +/******/ } +/******/ } catch(error) { +/******/ onError(error); +/******/ } +/******/ } +/******/ var onExternal = function(external, _, first) { return external ? handleFunction(__webpack_require__.I, data[0], 0, external, onInitialized, first) : onError(); }; +/******/ var onInitialized = function(_, external, first) { return handleFunction(external.get, data[1], getScope, 0, onFactory, first); }; +/******/ var onFactory = function(factory) { +/******/ data.p = 1; +/******/ __webpack_require__.m[id] = function(module) { +/******/ module.exports = factory(); +/******/ } +/******/ }; +/******/ handleFunction(__webpack_require__, data[2], 0, 0, onExternal, 1); +/******/ }); +/******/ } +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/sharing */ +/******/ !function() { +/******/ __webpack_require__.S = {}; +/******/ var initPromises = {}; +/******/ var initTokens = {}; +/******/ __webpack_require__.I = function(name, initScope) { +/******/ if(!initScope) initScope = []; +/******/ // handling circular init calls +/******/ var initToken = initTokens[name]; +/******/ if(!initToken) initToken = initTokens[name] = {}; +/******/ if(initScope.indexOf(initToken) >= 0) return; +/******/ initScope.push(initToken); +/******/ // only runs once +/******/ if(initPromises[name]) return initPromises[name]; +/******/ // creates a new share scope if needed +/******/ if(!__webpack_require__.o(__webpack_require__.S, name)) __webpack_require__.S[name] = {}; +/******/ // runs all init snippets from all modules reachable +/******/ var scope = __webpack_require__.S[name]; +/******/ var warn = function(msg) { return typeof console !== "undefined" && console.warn && console.warn(msg); }; +/******/ var uniqueName = "home_app"; +/******/ var register = function(name, version, factory, eager) { +/******/ var versions = scope[name] = scope[name] || {}; +/******/ var activeVersion = versions[version]; +/******/ if(!activeVersion || (!activeVersion.loaded && (!eager != !activeVersion.eager ? eager : uniqueName > activeVersion.from))) versions[version] = { get: factory, from: uniqueName, eager: !!eager }; +/******/ }; +/******/ var initExternal = function(id) { +/******/ var handleError = function(err) { warn("Initialization of sharing external failed: " + err); }; +/******/ try { +/******/ var module = __webpack_require__(id); +/******/ if(!module) return; +/******/ var initFn = function(module) { return module && module.init && module.init(__webpack_require__.S[name], initScope); } +/******/ if(module.then) return promises.push(module.then(initFn, handleError)); +/******/ var initResult = initFn(module); +/******/ if(initResult && initResult.then) return promises.push(initResult['catch'](handleError)); +/******/ } catch(err) { handleError(err); } +/******/ } +/******/ var promises = []; +/******/ switch(name) { +/******/ case "default": { +/******/ register("antd", "4.24.9", function() { return __webpack_require__.e("node_modules_antd_es_index_js").then(function() { return function() { return __webpack_require__(/*! ../../node_modules/antd/es/index.js */ "../../node_modules/antd/es/index.js"); }; }); }); +/******/ initExternal("../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js"); +/******/ initExternal("../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js"); +/******/ } +/******/ break; +/******/ } +/******/ if(!promises.length) return initPromises[name] = 1; +/******/ return initPromises[name] = Promise.all(promises).then(function() { return initPromises[name] = 1; }); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/trusted types policy */ +/******/ !function() { +/******/ var policy; +/******/ __webpack_require__.tt = function() { +/******/ // Create Trusted Type policy if Trusted Types are available and the policy doesn't exist yet. +/******/ if (policy === undefined) { +/******/ policy = { +/******/ createScriptURL: function(url) { return url; } +/******/ }; +/******/ if (typeof trustedTypes !== "undefined" && trustedTypes.createPolicy) { +/******/ policy = trustedTypes.createPolicy("nextjs#bundler", policy); +/******/ } +/******/ } +/******/ return policy; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/trusted types script url */ +/******/ !function() { +/******/ __webpack_require__.tu = function(url) { return __webpack_require__.tt().createScriptURL(url); }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hot module replacement */ +/******/ !function() { +/******/ var currentModuleData = {}; +/******/ var installedModules = __webpack_require__.c; +/******/ +/******/ // module and require creation +/******/ var currentChildModule; +/******/ var currentParents = []; +/******/ +/******/ // status +/******/ var registeredStatusHandlers = []; +/******/ var currentStatus = "idle"; +/******/ +/******/ // while downloading +/******/ var blockingPromises = 0; +/******/ var blockingPromisesWaiting = []; +/******/ +/******/ // The update info +/******/ var currentUpdateApplyHandlers; +/******/ var queuedInvalidatedModules; +/******/ +/******/ // eslint-disable-next-line no-unused-vars +/******/ __webpack_require__.hmrD = currentModuleData; +/******/ +/******/ __webpack_require__.i.push(function (options) { +/******/ var module = options.module; +/******/ var require = createRequire(options.require, options.id); +/******/ module.hot = createModuleHotObject(options.id, module); +/******/ module.parents = currentParents; +/******/ module.children = []; +/******/ currentParents = []; +/******/ options.require = require; +/******/ }); +/******/ +/******/ __webpack_require__.hmrC = {}; +/******/ __webpack_require__.hmrI = {}; +/******/ +/******/ function createRequire(require, moduleId) { +/******/ var me = installedModules[moduleId]; +/******/ if (!me) return require; +/******/ var fn = function (request) { +/******/ if (me.hot.active) { +/******/ if (installedModules[request]) { +/******/ var parents = installedModules[request].parents; +/******/ if (parents.indexOf(moduleId) === -1) { +/******/ parents.push(moduleId); +/******/ } +/******/ } else { +/******/ currentParents = [moduleId]; +/******/ currentChildModule = request; +/******/ } +/******/ if (me.children.indexOf(request) === -1) { +/******/ me.children.push(request); +/******/ } +/******/ } else { +/******/ console.warn( +/******/ "[HMR] unexpected require(" + +/******/ request + +/******/ ") from disposed module " + +/******/ moduleId +/******/ ); +/******/ currentParents = []; +/******/ } +/******/ return require(request); +/******/ }; +/******/ var createPropertyDescriptor = function (name) { +/******/ return { +/******/ configurable: true, +/******/ enumerable: true, +/******/ get: function () { +/******/ return require[name]; +/******/ }, +/******/ set: function (value) { +/******/ require[name] = value; +/******/ } +/******/ }; +/******/ }; +/******/ for (var name in require) { +/******/ if (Object.prototype.hasOwnProperty.call(require, name) && name !== "e") { +/******/ Object.defineProperty(fn, name, createPropertyDescriptor(name)); +/******/ } +/******/ } +/******/ fn.e = function (chunkId) { +/******/ return trackBlockingPromise(require.e(chunkId)); +/******/ }; +/******/ return fn; +/******/ } +/******/ +/******/ function createModuleHotObject(moduleId, me) { +/******/ var _main = currentChildModule !== moduleId; +/******/ var hot = { +/******/ // private stuff +/******/ _acceptedDependencies: {}, +/******/ _acceptedErrorHandlers: {}, +/******/ _declinedDependencies: {}, +/******/ _selfAccepted: false, +/******/ _selfDeclined: false, +/******/ _selfInvalidated: false, +/******/ _disposeHandlers: [], +/******/ _main: _main, +/******/ _requireSelf: function () { +/******/ currentParents = me.parents.slice(); +/******/ currentChildModule = _main ? undefined : moduleId; +/******/ __webpack_require__(moduleId); +/******/ }, +/******/ +/******/ // Module API +/******/ active: true, +/******/ accept: function (dep, callback, errorHandler) { +/******/ if (dep === undefined) hot._selfAccepted = true; +/******/ else if (typeof dep === "function") hot._selfAccepted = dep; +/******/ else if (typeof dep === "object" && dep !== null) { +/******/ for (var i = 0; i < dep.length; i++) { +/******/ hot._acceptedDependencies[dep[i]] = callback || function () {}; +/******/ hot._acceptedErrorHandlers[dep[i]] = errorHandler; +/******/ } +/******/ } else { +/******/ hot._acceptedDependencies[dep] = callback || function () {}; +/******/ hot._acceptedErrorHandlers[dep] = errorHandler; +/******/ } +/******/ }, +/******/ decline: function (dep) { +/******/ if (dep === undefined) hot._selfDeclined = true; +/******/ else if (typeof dep === "object" && dep !== null) +/******/ for (var i = 0; i < dep.length; i++) +/******/ hot._declinedDependencies[dep[i]] = true; +/******/ else hot._declinedDependencies[dep] = true; +/******/ }, +/******/ dispose: function (callback) { +/******/ hot._disposeHandlers.push(callback); +/******/ }, +/******/ addDisposeHandler: function (callback) { +/******/ hot._disposeHandlers.push(callback); +/******/ }, +/******/ removeDisposeHandler: function (callback) { +/******/ var idx = hot._disposeHandlers.indexOf(callback); +/******/ if (idx >= 0) hot._disposeHandlers.splice(idx, 1); +/******/ }, +/******/ invalidate: function () { +/******/ this._selfInvalidated = true; +/******/ switch (currentStatus) { +/******/ case "idle": +/******/ currentUpdateApplyHandlers = []; +/******/ Object.keys(__webpack_require__.hmrI).forEach(function (key) { +/******/ __webpack_require__.hmrI[key]( +/******/ moduleId, +/******/ currentUpdateApplyHandlers +/******/ ); +/******/ }); +/******/ setStatus("ready"); +/******/ break; +/******/ case "ready": +/******/ Object.keys(__webpack_require__.hmrI).forEach(function (key) { +/******/ __webpack_require__.hmrI[key]( +/******/ moduleId, +/******/ currentUpdateApplyHandlers +/******/ ); +/******/ }); +/******/ break; +/******/ case "prepare": +/******/ case "check": +/******/ case "dispose": +/******/ case "apply": +/******/ (queuedInvalidatedModules = queuedInvalidatedModules || []).push( +/******/ moduleId +/******/ ); +/******/ break; +/******/ default: +/******/ // ignore requests in error states +/******/ break; +/******/ } +/******/ }, +/******/ +/******/ // Management API +/******/ check: hotCheck, +/******/ apply: hotApply, +/******/ status: function (l) { +/******/ if (!l) return currentStatus; +/******/ registeredStatusHandlers.push(l); +/******/ }, +/******/ addStatusHandler: function (l) { +/******/ registeredStatusHandlers.push(l); +/******/ }, +/******/ removeStatusHandler: function (l) { +/******/ var idx = registeredStatusHandlers.indexOf(l); +/******/ if (idx >= 0) registeredStatusHandlers.splice(idx, 1); +/******/ }, +/******/ +/******/ //inherit from previous dispose call +/******/ data: currentModuleData[moduleId] +/******/ }; +/******/ currentChildModule = undefined; +/******/ return hot; +/******/ } +/******/ +/******/ function setStatus(newStatus) { +/******/ currentStatus = newStatus; +/******/ var results = []; +/******/ +/******/ for (var i = 0; i < registeredStatusHandlers.length; i++) +/******/ results[i] = registeredStatusHandlers[i].call(null, newStatus); +/******/ +/******/ return Promise.all(results); +/******/ } +/******/ +/******/ function unblock() { +/******/ if (--blockingPromises === 0) { +/******/ setStatus("ready").then(function () { +/******/ if (blockingPromises === 0) { +/******/ var list = blockingPromisesWaiting; +/******/ blockingPromisesWaiting = []; +/******/ for (var i = 0; i < list.length; i++) { +/******/ list[i](); +/******/ } +/******/ } +/******/ }); +/******/ } +/******/ } +/******/ +/******/ function trackBlockingPromise(promise) { +/******/ switch (currentStatus) { +/******/ case "ready": +/******/ setStatus("prepare"); +/******/ /* fallthrough */ +/******/ case "prepare": +/******/ blockingPromises++; +/******/ promise.then(unblock, unblock); +/******/ return promise; +/******/ default: +/******/ return promise; +/******/ } +/******/ } +/******/ +/******/ function waitForBlockingPromises(fn) { +/******/ if (blockingPromises === 0) return fn(); +/******/ return new Promise(function (resolve) { +/******/ blockingPromisesWaiting.push(function () { +/******/ resolve(fn()); +/******/ }); +/******/ }); +/******/ } +/******/ +/******/ function hotCheck(applyOnUpdate) { +/******/ if (currentStatus !== "idle") { +/******/ throw new Error("check() is only allowed in idle status"); +/******/ } +/******/ return setStatus("check") +/******/ .then(__webpack_require__.hmrM) +/******/ .then(function (update) { +/******/ if (!update) { +/******/ return setStatus(applyInvalidatedModules() ? "ready" : "idle").then( +/******/ function () { +/******/ return null; +/******/ } +/******/ ); +/******/ } +/******/ +/******/ return setStatus("prepare").then(function () { +/******/ var updatedModules = []; +/******/ currentUpdateApplyHandlers = []; +/******/ +/******/ return Promise.all( +/******/ Object.keys(__webpack_require__.hmrC).reduce(function ( +/******/ promises, +/******/ key +/******/ ) { +/******/ __webpack_require__.hmrC[key]( +/******/ update.c, +/******/ update.r, +/******/ update.m, +/******/ promises, +/******/ currentUpdateApplyHandlers, +/******/ updatedModules +/******/ ); +/******/ return promises; +/******/ }, +/******/ []) +/******/ ).then(function () { +/******/ return waitForBlockingPromises(function () { +/******/ if (applyOnUpdate) { +/******/ return internalApply(applyOnUpdate); +/******/ } else { +/******/ return setStatus("ready").then(function () { +/******/ return updatedModules; +/******/ }); +/******/ } +/******/ }); +/******/ }); +/******/ }); +/******/ }); +/******/ } +/******/ +/******/ function hotApply(options) { +/******/ if (currentStatus !== "ready") { +/******/ return Promise.resolve().then(function () { +/******/ throw new Error( +/******/ "apply() is only allowed in ready status (state: " + +/******/ currentStatus + +/******/ ")" +/******/ ); +/******/ }); +/******/ } +/******/ return internalApply(options); +/******/ } +/******/ +/******/ function internalApply(options) { +/******/ options = options || {}; +/******/ +/******/ applyInvalidatedModules(); +/******/ +/******/ var results = currentUpdateApplyHandlers.map(function (handler) { +/******/ return handler(options); +/******/ }); +/******/ currentUpdateApplyHandlers = undefined; +/******/ +/******/ var errors = results +/******/ .map(function (r) { +/******/ return r.error; +/******/ }) +/******/ .filter(Boolean); +/******/ +/******/ if (errors.length > 0) { +/******/ return setStatus("abort").then(function () { +/******/ throw errors[0]; +/******/ }); +/******/ } +/******/ +/******/ // Now in "dispose" phase +/******/ var disposePromise = setStatus("dispose"); +/******/ +/******/ results.forEach(function (result) { +/******/ if (result.dispose) result.dispose(); +/******/ }); +/******/ +/******/ // Now in "apply" phase +/******/ var applyPromise = setStatus("apply"); +/******/ +/******/ var error; +/******/ var reportError = function (err) { +/******/ if (!error) error = err; +/******/ }; +/******/ +/******/ var outdatedModules = []; +/******/ results.forEach(function (result) { +/******/ if (result.apply) { +/******/ var modules = result.apply(reportError); +/******/ if (modules) { +/******/ for (var i = 0; i < modules.length; i++) { +/******/ outdatedModules.push(modules[i]); +/******/ } +/******/ } +/******/ } +/******/ }); +/******/ +/******/ return Promise.all([disposePromise, applyPromise]).then(function () { +/******/ // handle errors in accept handlers and self accepted module load +/******/ if (error) { +/******/ return setStatus("fail").then(function () { +/******/ throw error; +/******/ }); +/******/ } +/******/ +/******/ if (queuedInvalidatedModules) { +/******/ return internalApply(options).then(function (list) { +/******/ outdatedModules.forEach(function (moduleId) { +/******/ if (list.indexOf(moduleId) < 0) list.push(moduleId); +/******/ }); +/******/ return list; +/******/ }); +/******/ } +/******/ +/******/ return setStatus("idle").then(function () { +/******/ return outdatedModules; +/******/ }); +/******/ }); +/******/ } +/******/ +/******/ function applyInvalidatedModules() { +/******/ if (queuedInvalidatedModules) { +/******/ if (!currentUpdateApplyHandlers) currentUpdateApplyHandlers = []; +/******/ Object.keys(__webpack_require__.hmrI).forEach(function (key) { +/******/ queuedInvalidatedModules.forEach(function (moduleId) { +/******/ __webpack_require__.hmrI[key]( +/******/ moduleId, +/******/ currentUpdateApplyHandlers +/******/ ); +/******/ }); +/******/ }); +/******/ queuedInvalidatedModules = undefined; +/******/ return true; +/******/ } +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/publicPath */ +/******/ !function() { +/******/ var scriptUrl; +/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +/******/ var document = __webpack_require__.g.document; +/******/ if (!scriptUrl && document) { +/******/ if (document.currentScript) +/******/ scriptUrl = document.currentScript.src +/******/ if (!scriptUrl) { +/******/ var scripts = document.getElementsByTagName("script"); +/******/ if(scripts.length) scriptUrl = scripts[scripts.length - 1].src +/******/ } +/******/ } +/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration +/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic. +/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/"); +/******/ __webpack_require__.p = scriptUrl + "../../"; +/******/ }(); +/******/ +/******/ /* webpack/runtime/react refresh */ +/******/ !function() { +/******/ if (__webpack_require__.i) { +/******/ __webpack_require__.i.push(function(options) { +/******/ var originalFactory = options.factory; +/******/ options.factory = function(moduleObject, moduleExports, webpackRequire) { +/******/ var hasRefresh = typeof self !== "undefined" && !!self.$RefreshInterceptModuleExecution$; +/******/ var cleanup = hasRefresh ? self.$RefreshInterceptModuleExecution$(moduleObject.id) : function() {}; +/******/ try { +/******/ originalFactory.call(this, moduleObject, moduleExports, webpackRequire); +/******/ } finally { +/******/ cleanup(); +/******/ } +/******/ } +/******/ }) +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/compat */ +/******/ +/******/ +/******/ // noop fns to prevent runtime errors during initialization +/******/ if (typeof self !== "undefined") { +/******/ self.$RefreshReg$ = function () {}; +/******/ self.$RefreshSig$ = function () { +/******/ return function (type) { +/******/ return type; +/******/ }; +/******/ }; +/******/ } +/******/ +/******/ /* webpack/runtime/consumes */ +/******/ !function() { +/******/ var parseVersion = function(str) { +/******/ // see webpack/lib/util/semver.js for original code +/******/ var p=function(p){return p.split(".").map((function(p){return+p==p?+p:p}))},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r; +/******/ } +/******/ var versionLt = function(a, b) { +/******/ // see webpack/lib/util/semver.js for original code +/******/ a=parseVersion(a),b=parseVersion(b);for(var r=0;;){if(r>=a.length)return r=b.length)return"u"==n;var t=b[r],f=(typeof t)[0];if(n!=f)return"o"==n&&"n"==f||("s"==f||"u"==n);if("o"!=n&&"u"!=n&&e!=t)return e=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var e=1,a=1;a0?".":"")+(e=2,t)}return n}var g=[];for(a=1;a=version.length||"o"==(s=(typeof(f=version[n]))[0]))return!a||("u"==g?i>e&&!r:""==g!=r);if("u"==s){if(!a||"u"!=g)return!1}else if(a)if(g==s)if(i<=e){if(f!=range[i])return!1}else{if(r?f>range[i]:f=a.length)return r=b.length)return"u"==n;var t=b[r],f=(typeof t)[0];if(n!=f)return"o"==n&&"n"==f||("s"==f||"u"==n);if("o"!=n&&"u"!=n&&e!=t)return e=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var e=1,a=1;a0?".":"")+(e=2,t)}return n}var g=[];for(a=1;a=version.length||"o"==(s=(typeof(f=version[n]))[0]))return!a||("u"==g?i>e&&!r:""==g!=r);if("u"==s){if(!a||"u"!=g)return!1}else if(a)if(g==s)if(i<=e){if(f!=range[i])return!1}else{if(r?f>range[i]:f 0) { +/******/ var queueItem = queue.pop(); +/******/ var moduleId = queueItem.id; +/******/ var chain = queueItem.chain; +/******/ var module = __webpack_require__.c[moduleId]; +/******/ if ( +/******/ !module || +/******/ (module.hot._selfAccepted && !module.hot._selfInvalidated) +/******/ ) +/******/ continue; +/******/ if (module.hot._selfDeclined) { +/******/ return { +/******/ type: "self-declined", +/******/ chain: chain, +/******/ moduleId: moduleId +/******/ }; +/******/ } +/******/ if (module.hot._main) { +/******/ return { +/******/ type: "unaccepted", +/******/ chain: chain, +/******/ moduleId: moduleId +/******/ }; +/******/ } +/******/ for (var i = 0; i < module.parents.length; i++) { +/******/ var parentId = module.parents[i]; +/******/ var parent = __webpack_require__.c[parentId]; +/******/ if (!parent) continue; +/******/ if (parent.hot._declinedDependencies[moduleId]) { +/******/ return { +/******/ type: "declined", +/******/ chain: chain.concat([parentId]), +/******/ moduleId: moduleId, +/******/ parentId: parentId +/******/ }; +/******/ } +/******/ if (outdatedModules.indexOf(parentId) !== -1) continue; +/******/ if (parent.hot._acceptedDependencies[moduleId]) { +/******/ if (!outdatedDependencies[parentId]) +/******/ outdatedDependencies[parentId] = []; +/******/ addAllToSet(outdatedDependencies[parentId], [moduleId]); +/******/ continue; +/******/ } +/******/ delete outdatedDependencies[parentId]; +/******/ outdatedModules.push(parentId); +/******/ queue.push({ +/******/ chain: chain.concat([parentId]), +/******/ id: parentId +/******/ }); +/******/ } +/******/ } +/******/ +/******/ return { +/******/ type: "accepted", +/******/ moduleId: updateModuleId, +/******/ outdatedModules: outdatedModules, +/******/ outdatedDependencies: outdatedDependencies +/******/ }; +/******/ } +/******/ +/******/ function addAllToSet(a, b) { +/******/ for (var i = 0; i < b.length; i++) { +/******/ var item = b[i]; +/******/ if (a.indexOf(item) === -1) a.push(item); +/******/ } +/******/ } +/******/ +/******/ // at begin all updates modules are outdated +/******/ // the "outdated" status can propagate to parents if they don't accept the children +/******/ var outdatedDependencies = {}; +/******/ var outdatedModules = []; +/******/ var appliedUpdate = {}; +/******/ +/******/ var warnUnexpectedRequire = function warnUnexpectedRequire(module) { +/******/ console.warn( +/******/ "[HMR] unexpected require(" + module.id + ") to disposed module" +/******/ ); +/******/ }; +/******/ +/******/ for (var moduleId in currentUpdate) { +/******/ if (__webpack_require__.o(currentUpdate, moduleId)) { +/******/ var newModuleFactory = currentUpdate[moduleId]; +/******/ /** @type {TODO} */ +/******/ var result; +/******/ if (newModuleFactory) { +/******/ result = getAffectedModuleEffects(moduleId); +/******/ } else { +/******/ result = { +/******/ type: "disposed", +/******/ moduleId: moduleId +/******/ }; +/******/ } +/******/ /** @type {Error|false} */ +/******/ var abortError = false; +/******/ var doApply = false; +/******/ var doDispose = false; +/******/ var chainInfo = ""; +/******/ if (result.chain) { +/******/ chainInfo = "\\nUpdate propagation: " + result.chain.join(" -> "); +/******/ } +/******/ switch (result.type) { +/******/ case "self-declined": +/******/ if (options.onDeclined) options.onDeclined(result); +/******/ if (!options.ignoreDeclined) +/******/ abortError = new Error( +/******/ "Aborted because of self decline: " + +/******/ result.moduleId + +/******/ chainInfo +/******/ ); +/******/ break; +/******/ case "declined": +/******/ if (options.onDeclined) options.onDeclined(result); +/******/ if (!options.ignoreDeclined) +/******/ abortError = new Error( +/******/ "Aborted because of declined dependency: " + +/******/ result.moduleId + +/******/ " in " + +/******/ result.parentId + +/******/ chainInfo +/******/ ); +/******/ break; +/******/ case "unaccepted": +/******/ if (options.onUnaccepted) options.onUnaccepted(result); +/******/ if (!options.ignoreUnaccepted) +/******/ abortError = new Error( +/******/ "Aborted because " + moduleId + " is not accepted" + chainInfo +/******/ ); +/******/ break; +/******/ case "accepted": +/******/ if (options.onAccepted) options.onAccepted(result); +/******/ doApply = true; +/******/ break; +/******/ case "disposed": +/******/ if (options.onDisposed) options.onDisposed(result); +/******/ doDispose = true; +/******/ break; +/******/ default: +/******/ throw new Error("Unexception type " + result.type); +/******/ } +/******/ if (abortError) { +/******/ return { +/******/ error: abortError +/******/ }; +/******/ } +/******/ if (doApply) { +/******/ appliedUpdate[moduleId] = newModuleFactory; +/******/ addAllToSet(outdatedModules, result.outdatedModules); +/******/ for (moduleId in result.outdatedDependencies) { +/******/ if (__webpack_require__.o(result.outdatedDependencies, moduleId)) { +/******/ if (!outdatedDependencies[moduleId]) +/******/ outdatedDependencies[moduleId] = []; +/******/ addAllToSet( +/******/ outdatedDependencies[moduleId], +/******/ result.outdatedDependencies[moduleId] +/******/ ); +/******/ } +/******/ } +/******/ } +/******/ if (doDispose) { +/******/ addAllToSet(outdatedModules, [result.moduleId]); +/******/ appliedUpdate[moduleId] = warnUnexpectedRequire; +/******/ } +/******/ } +/******/ } +/******/ currentUpdate = undefined; +/******/ +/******/ // Store self accepted outdated modules to require them later by the module system +/******/ var outdatedSelfAcceptedModules = []; +/******/ for (var j = 0; j < outdatedModules.length; j++) { +/******/ var outdatedModuleId = outdatedModules[j]; +/******/ var module = __webpack_require__.c[outdatedModuleId]; +/******/ if ( +/******/ module && +/******/ (module.hot._selfAccepted || module.hot._main) && +/******/ // removed self-accepted modules should not be required +/******/ appliedUpdate[outdatedModuleId] !== warnUnexpectedRequire && +/******/ // when called invalidate self-accepting is not possible +/******/ !module.hot._selfInvalidated +/******/ ) { +/******/ outdatedSelfAcceptedModules.push({ +/******/ module: outdatedModuleId, +/******/ require: module.hot._requireSelf, +/******/ errorHandler: module.hot._selfAccepted +/******/ }); +/******/ } +/******/ } +/******/ +/******/ var moduleOutdatedDependencies; +/******/ +/******/ return { +/******/ dispose: function () { +/******/ currentUpdateRemovedChunks.forEach(function (chunkId) { +/******/ delete installedChunks[chunkId]; +/******/ }); +/******/ currentUpdateRemovedChunks = undefined; +/******/ +/******/ var idx; +/******/ var queue = outdatedModules.slice(); +/******/ while (queue.length > 0) { +/******/ var moduleId = queue.pop(); +/******/ var module = __webpack_require__.c[moduleId]; +/******/ if (!module) continue; +/******/ +/******/ var data = {}; +/******/ +/******/ // Call dispose handlers +/******/ var disposeHandlers = module.hot._disposeHandlers; +/******/ for (j = 0; j < disposeHandlers.length; j++) { +/******/ disposeHandlers[j].call(null, data); +/******/ } +/******/ __webpack_require__.hmrD[moduleId] = data; +/******/ +/******/ // disable module (this disables requires from this module) +/******/ module.hot.active = false; +/******/ +/******/ // remove module from cache +/******/ delete __webpack_require__.c[moduleId]; +/******/ +/******/ // when disposing there is no need to call dispose handler +/******/ delete outdatedDependencies[moduleId]; +/******/ +/******/ // remove "parents" references from all children +/******/ for (j = 0; j < module.children.length; j++) { +/******/ var child = __webpack_require__.c[module.children[j]]; +/******/ if (!child) continue; +/******/ idx = child.parents.indexOf(moduleId); +/******/ if (idx >= 0) { +/******/ child.parents.splice(idx, 1); +/******/ } +/******/ } +/******/ } +/******/ +/******/ // remove outdated dependency from module children +/******/ var dependency; +/******/ for (var outdatedModuleId in outdatedDependencies) { +/******/ if (__webpack_require__.o(outdatedDependencies, outdatedModuleId)) { +/******/ module = __webpack_require__.c[outdatedModuleId]; +/******/ if (module) { +/******/ moduleOutdatedDependencies = +/******/ outdatedDependencies[outdatedModuleId]; +/******/ for (j = 0; j < moduleOutdatedDependencies.length; j++) { +/******/ dependency = moduleOutdatedDependencies[j]; +/******/ idx = module.children.indexOf(dependency); +/******/ if (idx >= 0) module.children.splice(idx, 1); +/******/ } +/******/ } +/******/ } +/******/ } +/******/ }, +/******/ apply: function (reportError) { +/******/ // insert new code +/******/ for (var updateModuleId in appliedUpdate) { +/******/ if (__webpack_require__.o(appliedUpdate, updateModuleId)) { +/******/ __webpack_require__.m[updateModuleId] = appliedUpdate[updateModuleId]; +/******/ } +/******/ } +/******/ +/******/ // run new runtime modules +/******/ for (var i = 0; i < currentUpdateRuntime.length; i++) { +/******/ currentUpdateRuntime[i](__webpack_require__); +/******/ } +/******/ +/******/ // call accept handlers +/******/ for (var outdatedModuleId in outdatedDependencies) { +/******/ if (__webpack_require__.o(outdatedDependencies, outdatedModuleId)) { +/******/ var module = __webpack_require__.c[outdatedModuleId]; +/******/ if (module) { +/******/ moduleOutdatedDependencies = +/******/ outdatedDependencies[outdatedModuleId]; +/******/ var callbacks = []; +/******/ var errorHandlers = []; +/******/ var dependenciesForCallbacks = []; +/******/ for (var j = 0; j < moduleOutdatedDependencies.length; j++) { +/******/ var dependency = moduleOutdatedDependencies[j]; +/******/ var acceptCallback = +/******/ module.hot._acceptedDependencies[dependency]; +/******/ var errorHandler = +/******/ module.hot._acceptedErrorHandlers[dependency]; +/******/ if (acceptCallback) { +/******/ if (callbacks.indexOf(acceptCallback) !== -1) continue; +/******/ callbacks.push(acceptCallback); +/******/ errorHandlers.push(errorHandler); +/******/ dependenciesForCallbacks.push(dependency); +/******/ } +/******/ } +/******/ for (var k = 0; k < callbacks.length; k++) { +/******/ try { +/******/ callbacks[k].call(null, moduleOutdatedDependencies); +/******/ } catch (err) { +/******/ if (typeof errorHandlers[k] === "function") { +/******/ try { +/******/ errorHandlers[k](err, { +/******/ moduleId: outdatedModuleId, +/******/ dependencyId: dependenciesForCallbacks[k] +/******/ }); +/******/ } catch (err2) { +/******/ if (options.onErrored) { +/******/ options.onErrored({ +/******/ type: "accept-error-handler-errored", +/******/ moduleId: outdatedModuleId, +/******/ dependencyId: dependenciesForCallbacks[k], +/******/ error: err2, +/******/ originalError: err +/******/ }); +/******/ } +/******/ if (!options.ignoreErrored) { +/******/ reportError(err2); +/******/ reportError(err); +/******/ } +/******/ } +/******/ } else { +/******/ if (options.onErrored) { +/******/ options.onErrored({ +/******/ type: "accept-errored", +/******/ moduleId: outdatedModuleId, +/******/ dependencyId: dependenciesForCallbacks[k], +/******/ error: err +/******/ }); +/******/ } +/******/ if (!options.ignoreErrored) { +/******/ reportError(err); +/******/ } +/******/ } +/******/ } +/******/ } +/******/ } +/******/ } +/******/ } +/******/ +/******/ // Load self accepted modules +/******/ for (var o = 0; o < outdatedSelfAcceptedModules.length; o++) { +/******/ var item = outdatedSelfAcceptedModules[o]; +/******/ var moduleId = item.module; +/******/ try { +/******/ item.require(moduleId); +/******/ } catch (err) { +/******/ if (typeof item.errorHandler === "function") { +/******/ try { +/******/ item.errorHandler(err, { +/******/ moduleId: moduleId, +/******/ module: __webpack_require__.c[moduleId] +/******/ }); +/******/ } catch (err2) { +/******/ if (options.onErrored) { +/******/ options.onErrored({ +/******/ type: "self-accept-error-handler-errored", +/******/ moduleId: moduleId, +/******/ error: err2, +/******/ originalError: err +/******/ }); +/******/ } +/******/ if (!options.ignoreErrored) { +/******/ reportError(err2); +/******/ reportError(err); +/******/ } +/******/ } +/******/ } else { +/******/ if (options.onErrored) { +/******/ options.onErrored({ +/******/ type: "self-accept-errored", +/******/ moduleId: moduleId, +/******/ error: err +/******/ }); +/******/ } +/******/ if (!options.ignoreErrored) { +/******/ reportError(err); +/******/ } +/******/ } +/******/ } +/******/ } +/******/ +/******/ return outdatedModules; +/******/ } +/******/ }; +/******/ } +/******/ __webpack_require__.hmrI.jsonp = function (moduleId, applyHandlers) { +/******/ if (!currentUpdate) { +/******/ currentUpdate = {}; +/******/ currentUpdateRuntime = []; +/******/ currentUpdateRemovedChunks = []; +/******/ applyHandlers.push(applyHandler); +/******/ } +/******/ if (!__webpack_require__.o(currentUpdate, moduleId)) { +/******/ currentUpdate[moduleId] = __webpack_require__.m[moduleId]; +/******/ } +/******/ }; +/******/ __webpack_require__.hmrC.jsonp = function ( +/******/ chunkIds, +/******/ removedChunks, +/******/ removedModules, +/******/ promises, +/******/ applyHandlers, +/******/ updatedModulesList +/******/ ) { +/******/ applyHandlers.push(applyHandler); +/******/ currentUpdateChunks = {}; +/******/ currentUpdateRemovedChunks = removedChunks; +/******/ currentUpdate = removedModules.reduce(function (obj, key) { +/******/ obj[key] = false; +/******/ return obj; +/******/ }, {}); +/******/ currentUpdateRuntime = []; +/******/ chunkIds.forEach(function (chunkId) { +/******/ if ( +/******/ __webpack_require__.o(installedChunks, chunkId) && +/******/ installedChunks[chunkId] !== undefined +/******/ ) { +/******/ promises.push(loadUpdateChunk(chunkId, updatedModulesList)); +/******/ currentUpdateChunks[chunkId] = true; +/******/ } else { +/******/ currentUpdateChunks[chunkId] = false; +/******/ } +/******/ }); +/******/ if (__webpack_require__.f) { +/******/ __webpack_require__.f.jsonpHmr = function (chunkId, promises) { +/******/ if ( +/******/ currentUpdateChunks && +/******/ __webpack_require__.o(currentUpdateChunks, chunkId) && +/******/ !currentUpdateChunks[chunkId] +/******/ ) { +/******/ promises.push(loadUpdateChunk(chunkId)); +/******/ currentUpdateChunks[chunkId] = true; +/******/ } +/******/ }; +/******/ } +/******/ }; +/******/ +/******/ __webpack_require__.hmrM = function() { +/******/ if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API"); +/******/ return fetch(__webpack_require__.p + __webpack_require__.hmrF()).then(function(response) { +/******/ if(response.status === 404) return; // no update available +/******/ if(!response.ok) throw new Error("Failed to fetch update manifest " + response.statusText); +/******/ return response.json(); +/******/ }); +/******/ }; +/******/ +/******/ // no on chunks loaded +/******/ +/******/ // install a JSONP callback for chunk loading +/******/ var webpackJsonpCallback = function(parentChunkLoadingFunction, data) { +/******/ var chunkIds = data[0]; +/******/ var moreModules = data[1]; +/******/ var runtime = data[2]; +/******/ // add "moreModules" to the modules object, +/******/ // then flag all "chunkIds" as loaded and fire callback +/******/ var moduleId, chunkId, i = 0; +/******/ if(chunkIds.some(function(id) { return installedChunks[id] !== 0; })) { +/******/ for(moduleId in moreModules) { +/******/ if(__webpack_require__.o(moreModules, moduleId)) { +/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(runtime) var result = runtime(__webpack_require__); +/******/ } +/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { +/******/ installedChunks[chunkId][0](); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } +/******/ +/******/ } +/******/ +/******/ var chunkLoadingGlobal = self["webpackChunkhome_app"] = self["webpackChunkhome_app"] || []; +/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); +/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); +/******/ }(); +/******/ +/************************************************************************/ +/******/ +/******/ // module cache are used so entry inlining is disabled +/******/ // startup +/******/ // Load entry module and return exports +/******/ var __webpack_exports__ = __webpack_require__("webpack/container/entry/home_app"); +/******/ window.home_app = __webpack_exports__; +/******/ +/******/ })() +; +//# sourceMappingURL=remoteEntry.js.map" +`; + +exports[`Next.js build output client webpack-runtime 1`] = ` +"/******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "webpack/container/entry/home_app": +/*!***********************!*\\ + !*** container entry ***! + \\***********************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +var moduleMap = { + "./pages-map": function() { + return __webpack_require__.e("dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_dist_packages_nextjs-mf_src_loaders_-50dce4").then(function() { return function() { return (__webpack_require__(/*! ../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js */ "../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js")); }; }); + }, + "./pages-map-v2": function() { + return __webpack_require__.e("dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_v2_dist_packages_nextjs-mf_src_loade-8dd7f8").then(function() { return function() { return (__webpack_require__(/*! ../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js?v2!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js */ "../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js?v2!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js")); }; }); + }, + "./pages/dynamic-remote": function() { + return __webpack_require__.e("pages_dynamic-remote_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/dynamic-remote.js */ "./pages/dynamic-remote.js")); }; }); + }, + "./pages/index": function() { + return __webpack_require__.e("pages_index_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/index.tsx */ "./pages/index.tsx")); }; }); + }, + "./pages/checkout/[...slug]": function() { + return __webpack_require__.e("pages_checkout_slug_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/[...slug].tsx */ "./pages/checkout/[...slug].tsx")); }; }); + }, + "./pages/checkout/[pid]": function() { + return __webpack_require__.e("pages_checkout_pid_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/[pid].tsx */ "./pages/checkout/[pid].tsx")); }; }); + }, + "./pages/checkout/exposed-pages": function() { + return __webpack_require__.e("pages_checkout_exposed-pages_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/exposed-pages.tsx */ "./pages/checkout/exposed-pages.tsx")); }; }); + }, + "./pages/checkout/index": function() { + return __webpack_require__.e("pages_checkout_index_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/index.tsx */ "./pages/checkout/index.tsx")); }; }); + }, + "./pages/checkout/test-check-button": function() { + return __webpack_require__.e("pages_checkout_test-check-button_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/test-check-button.tsx */ "./pages/checkout/test-check-button.tsx")); }; }); + }, + "./pages/checkout/test-title": function() { + return __webpack_require__.e("pages_checkout_test-title_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/test-title.tsx */ "./pages/checkout/test-title.tsx")); }; }); + }, + "./pages/home/exposed-pages": function() { + return __webpack_require__.e("pages_home_exposed-pages_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/exposed-pages.tsx */ "./pages/home/exposed-pages.tsx")); }; }); + }, + "./pages/home/test-broken-remotes": function() { + return __webpack_require__.e("pages_home_test-broken-remotes_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-broken-remotes.tsx */ "./pages/home/test-broken-remotes.tsx")); }; }); + }, + "./pages/home/test-remote-hook": function() { + return __webpack_require__.e("pages_home_test-remote-hook_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-remote-hook.tsx */ "./pages/home/test-remote-hook.tsx")); }; }); + }, + "./pages/home/test-shared-nav": function() { + return __webpack_require__.e("pages_home_test-shared-nav_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-shared-nav.tsx */ "./pages/home/test-shared-nav.tsx")); }; }); + }, + "./pages/shop/exposed-pages": function() { + return __webpack_require__.e("pages_shop_exposed-pages_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/exposed-pages.js */ "./pages/shop/exposed-pages.js")); }; }); + }, + "./pages/shop/index": function() { + return __webpack_require__.e("pages_shop_index_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/index.js */ "./pages/shop/index.js")); }; }); + }, + "./pages/shop/test-webpack-png": function() { + return __webpack_require__.e("pages_shop_test-webpack-png_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/test-webpack-png.js */ "./pages/shop/test-webpack-png.js")); }; }); + }, + "./pages/shop/test-webpack-svg": function() { + return __webpack_require__.e("pages_shop_test-webpack-svg_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/test-webpack-svg.js */ "./pages/shop/test-webpack-svg.js")); }; }); + }, + "./pages/shop/products/[...slug]": function() { + return __webpack_require__.e("pages_shop_products_slug_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/products/[...slug].js */ "./pages/shop/products/[...slug].js")); }; }); + }, + "./SharedNav": function() { + return __webpack_require__.e("components_SharedNav_tsx").then(function() { return function() { return (__webpack_require__(/*! ./components/SharedNav */ "./components/SharedNav.tsx")); }; }); + }, + "./menu": function() { + return __webpack_require__.e("components_menu_tsx").then(function() { return function() { return (__webpack_require__(/*! ./components/menu */ "./components/menu.tsx")); }; }); + } +}; +var get = function(module, getScope) { + __webpack_require__.R = getScope; + getScope = ( + __webpack_require__.o(moduleMap, module) + ? moduleMap[module]() + : Promise.resolve().then(function() { + throw new Error('Module "' + module + '" does not exist in container.'); + }) + ); + __webpack_require__.R = undefined; + return getScope; +}; +var init = function(shareScope, initScope) { + if (!__webpack_require__.S) return; + var name = "default" + var oldScope = __webpack_require__.S[name]; + if(oldScope && oldScope !== shareScope) throw new Error("Container initialization failed as it has already been initialized with a different share scope"); + __webpack_require__.S[name] = shareScope; + return __webpack_require__.I(name, initScope); +}; + +// This exports getters to disallow modifications +__webpack_require__.d(exports, { + get: function() { return get; }, + init: function() { return init; } +}); + +/***/ }), + +/***/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js": +/*!**************************************************************************************************************************************!*\\ + !*** ../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js ***! + \\**************************************************************************************************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var __resourceQuery = "?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js"; + +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { + const { importDelegatedModule } = await __webpack_require__.e(/*! import() */ "dist_packages_utilities_src_utils_common_js").then(__webpack_require__.bind(__webpack_require__, /*! @module-federation/utilities/src/utils/common */ "../../dist/packages/utilities/src/utils/common.js")); + // eslint-disable-next-line no-undef + const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); + const [global, url] = currentRequest.split('@'); + importDelegatedModule({ + global, + url: url + '?' + Date.now(), + }) + .then((remote) => { + resolve(remote); + }) + .catch((err) => reject(err)); +}); +//# sourceMappingURL=default-delegate.js.map + +/***/ }), + +/***/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js": +/*!**********************************************************************************************************************************!*\\ + !*** ../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js ***! + \\**********************************************************************************************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var __resourceQuery = "?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js"; + +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { + const { importDelegatedModule } = await __webpack_require__.e(/*! import() */ "dist_packages_utilities_src_utils_common_js").then(__webpack_require__.bind(__webpack_require__, /*! @module-federation/utilities/src/utils/common */ "../../dist/packages/utilities/src/utils/common.js")); + // eslint-disable-next-line no-undef + const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); + const [global, url] = currentRequest.split('@'); + importDelegatedModule({ + global, + url: url + '?' + Date.now(), + }) + .then((remote) => { + resolve(remote); + }) + .catch((err) => reject(err)); +}); +//# sourceMappingURL=default-delegate.js.map + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ if (cachedModule.error !== undefined) throw cachedModule.error; +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ id: moduleId, +/******/ loaded: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ var threw = true; +/******/ try { +/******/ var execOptions = { id: moduleId, module: module, factory: __webpack_modules__[moduleId], require: __webpack_require__ }; +/******/ __webpack_require__.i.forEach(function(handler) { handler(execOptions); }); +/******/ module = execOptions.module; +/******/ execOptions.factory.call(module.exports, module, module.exports, execOptions.require); +/******/ threw = false; +/******/ } finally { +/******/ if(threw) delete __webpack_module_cache__[moduleId]; +/******/ } +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = __webpack_modules__; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = __webpack_module_cache__; +/******/ +/******/ // expose the module execution interceptor +/******/ __webpack_require__.i = []; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/chunk loaded */ +/******/ !function() { +/******/ var deferred = []; +/******/ __webpack_require__.O = function(result, chunkIds, fn, priority) { +/******/ if(chunkIds) { +/******/ priority = priority || 0; +/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; +/******/ deferred[i] = [chunkIds, fn, priority]; +/******/ return; +/******/ } +/******/ var notFulfilled = Infinity; +/******/ for (var i = 0; i < deferred.length; i++) { +/******/ var chunkIds = deferred[i][0]; +/******/ var fn = deferred[i][1]; +/******/ var priority = deferred[i][2]; +/******/ var fulfilled = true; +/******/ for (var j = 0; j < chunkIds.length; j++) { +/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every(function(key) { return __webpack_require__.O[key](chunkIds[j]); })) { +/******/ chunkIds.splice(j--, 1); +/******/ } else { +/******/ fulfilled = false; +/******/ if(priority < notFulfilled) notFulfilled = priority; +/******/ } +/******/ } +/******/ if(fulfilled) { +/******/ deferred.splice(i--, 1) +/******/ var r = fn(); +/******/ if (r !== undefined) result = r; +/******/ } +/******/ } +/******/ return result; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/create fake namespace object */ +/******/ !function() { +/******/ var getProto = Object.getPrototypeOf ? function(obj) { return Object.getPrototypeOf(obj); } : function(obj) { return obj.__proto__; }; +/******/ var leafPrototypes; +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 16: return value when it's Promise-like +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = this(value); +/******/ if(mode & 8) return value; +/******/ if(typeof value === 'object' && value) { +/******/ if((mode & 4) && value.__esModule) return value; +/******/ if((mode & 16) && typeof value.then === 'function') return value; +/******/ } +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ var def = {}; +/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)]; +/******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) { +/******/ Object.getOwnPropertyNames(current).forEach(function(key) { def[key] = function() { return value[key]; }; }); +/******/ } +/******/ def['default'] = function() { return value; }; +/******/ __webpack_require__.d(ns, def); +/******/ return ns; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/ensure chunk */ +/******/ !function() { +/******/ __webpack_require__.f = {}; +/******/ // This file contains only the entry chunk. +/******/ // The chunk loading function for additional chunks +/******/ __webpack_require__.e = function(chunkId) { +/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) { +/******/ __webpack_require__.f[key](chunkId, promises); +/******/ return promises; +/******/ }, [])); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/get javascript chunk filename */ +/******/ !function() { +/******/ // This function allow to reference async chunks +/******/ __webpack_require__.u = function(chunkId) { +/******/ // return url for filenames based on template +/******/ return "static/chunks/" + chunkId + ".js"; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/get javascript update chunk filename */ +/******/ !function() { +/******/ // This function allow to reference all chunks +/******/ __webpack_require__.hu = function(chunkId) { +/******/ // return url for filenames based on template +/******/ return "static/webpack/" + chunkId + "." + __webpack_require__.h() + ".hot-update.js"; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/get update manifest filename */ +/******/ !function() { +/******/ __webpack_require__.hmrF = function() { return "static/webpack/" + __webpack_require__.h() + ".webpack.hot-update.json"; }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/getFullHash */ +/******/ !function() { +/******/ __webpack_require__.h = function() { return "8a32b85331c94bdf"; } +/******/ }(); +/******/ +/******/ /* webpack/runtime/global */ +/******/ !function() { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/******/ /* webpack/runtime/load script */ +/******/ !function() { +/******/ var inProgress = {}; +/******/ var dataWebpackPrefix = "home_app:"; +/******/ // loadScript function to load a script via script tag +/******/ __webpack_require__.l = function(url, done, key, chunkId) { +/******/ if(inProgress[url]) { inProgress[url].push(done); return; } +/******/ var script, needAttach; +/******/ if(key !== undefined) { +/******/ var scripts = document.getElementsByTagName("script"); +/******/ for(var i = 0; i < scripts.length; i++) { +/******/ var s = scripts[i]; +/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; } +/******/ } +/******/ } +/******/ if(!script) { +/******/ needAttach = true; +/******/ script = document.createElement('script'); +/******/ +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120; +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); +/******/ } +/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key); +/******/ script.src = __webpack_require__.tu(url); +/******/ } +/******/ inProgress[url] = [done]; +/******/ var onScriptComplete = function(prev, event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var doneFns = inProgress[url]; +/******/ delete inProgress[url]; +/******/ script.parentNode && script.parentNode.removeChild(script); +/******/ doneFns && doneFns.forEach(function(fn) { return fn(event); }); +/******/ if(prev) return prev(event); +/******/ } +/******/ ; +/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000); +/******/ script.onerror = onScriptComplete.bind(null, script.onerror); +/******/ script.onload = onScriptComplete.bind(null, script.onload); +/******/ needAttach && document.head.appendChild(script); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ !function() { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/node module decorator */ +/******/ !function() { +/******/ __webpack_require__.nmd = function(module) { +/******/ module.paths = []; +/******/ if (!module.children) module.children = []; +/******/ return module; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/remotes loading */ +/******/ !function() { +/******/ var chunkMapping = { +/******/ "pages_home_test-remote-hook_tsx_hasBoundary": [ +/******/ "webpack/container/remote/shop/useCustomRemoteHook" +/******/ ], +/******/ "pages_checkout_index_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/index" +/******/ ], +/******/ "pages_checkout_slug_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/[...slug]" +/******/ ], +/******/ "pages_checkout_pid_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/[pid]" +/******/ ], +/******/ "pages_checkout_exposed-pages_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/exposed-pages" +/******/ ], +/******/ "pages_checkout_test-check-button_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/test-check-button" +/******/ ], +/******/ "pages_checkout_test-title_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/test-title" +/******/ ], +/******/ "pages_shop_exposed-pages_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/exposed-pages" +/******/ ], +/******/ "pages_shop_index_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/index" +/******/ ], +/******/ "pages_shop_test-webpack-png_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-png" +/******/ ], +/******/ "pages_shop_test-webpack-svg_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-svg" +/******/ ], +/******/ "pages_shop_products_slug_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/products/[...slug]" +/******/ ], +/******/ "webpack_container_remote_shop_menu": [ +/******/ "webpack/container/remote/shop/menu" +/******/ ], +/******/ "webpack_container_remote_checkout_menu": [ +/******/ "webpack/container/remote/checkout/menu" +/******/ ], +/******/ "webpack_container_remote_checkout_CheckoutTitle": [ +/******/ "webpack/container/remote/checkout/CheckoutTitle" +/******/ ], +/******/ "webpack_container_remote_checkout_ButtonOldAnt": [ +/******/ "webpack/container/remote/checkout/ButtonOldAnt" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackSvg": [ +/******/ "webpack/container/remote/shop/WebpackSvg" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackPng": [ +/******/ "webpack/container/remote/shop/WebpackPng" +/******/ ] +/******/ }; +/******/ var idToExternalAndNameMapping = { +/******/ "webpack/container/remote/shop/useCustomRemoteHook": [ +/******/ "default", +/******/ "./useCustomRemoteHook", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/index": [ +/******/ "default", +/******/ "./pages/checkout/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/[...slug]": [ +/******/ "default", +/******/ "./pages/checkout/[...slug]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/[pid]": [ +/******/ "default", +/******/ "./pages/checkout/[pid]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/exposed-pages": [ +/******/ "default", +/******/ "./pages/checkout/exposed-pages", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/test-check-button": [ +/******/ "default", +/******/ "./pages/checkout/test-check-button", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/test-title": [ +/******/ "default", +/******/ "./pages/checkout/test-title", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/exposed-pages": [ +/******/ "default", +/******/ "./pages/shop/exposed-pages", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/index": [ +/******/ "default", +/******/ "./pages/shop/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-png": [ +/******/ "default", +/******/ "./pages/shop/test-webpack-png", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-svg": [ +/******/ "default", +/******/ "./pages/shop/test-webpack-svg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/products/[...slug]": [ +/******/ "default", +/******/ "./pages/shop/products/[...slug]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/menu": [ +/******/ "default", +/******/ "./menu", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/menu": [ +/******/ "default", +/******/ "./menu", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/CheckoutTitle": [ +/******/ "default", +/******/ "./CheckoutTitle", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/ButtonOldAnt": [ +/******/ "default", +/******/ "./ButtonOldAnt", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackSvg": [ +/******/ "default", +/******/ "./WebpackSvg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackPng": [ +/******/ "default", +/******/ "./WebpackPng", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ] +/******/ }; +/******/ __webpack_require__.f.remotes = function(chunkId, promises) { +/******/ if(__webpack_require__.o(chunkMapping, chunkId)) { +/******/ chunkMapping[chunkId].forEach(function(id) { +/******/ var getScope = __webpack_require__.R; +/******/ if(!getScope) getScope = []; +/******/ var data = idToExternalAndNameMapping[id]; +/******/ if(getScope.indexOf(data) >= 0) return; +/******/ getScope.push(data); +/******/ if(data.p) return promises.push(data.p); +/******/ var onError = function(error) { +/******/ if(!error) error = new Error("Container missing"); +/******/ if(typeof error.message === "string") +/******/ error.message += '\\nwhile loading "' + data[1] + '" from ' + data[2]; +/******/ __webpack_require__.m[id] = function() { +/******/ throw error; +/******/ } +/******/ data.p = 0; +/******/ }; +/******/ var handleFunction = function(fn, arg1, arg2, d, next, first) { +/******/ try { +/******/ var promise = fn(arg1, arg2); +/******/ if(promise && promise.then) { +/******/ var p = promise.then(function(result) { return next(result, d); }, onError); +/******/ if(first) promises.push(data.p = p); else return p; +/******/ } else { +/******/ return next(promise, d, first); +/******/ } +/******/ } catch(error) { +/******/ onError(error); +/******/ } +/******/ } +/******/ var onExternal = function(external, _, first) { return external ? handleFunction(__webpack_require__.I, data[0], 0, external, onInitialized, first) : onError(); }; +/******/ var onInitialized = function(_, external, first) { return handleFunction(external.get, data[1], getScope, 0, onFactory, first); }; +/******/ var onFactory = function(factory) { +/******/ data.p = 1; +/******/ __webpack_require__.m[id] = function(module) { +/******/ module.exports = factory(); +/******/ } +/******/ }; +/******/ handleFunction(__webpack_require__, data[2], 0, 0, onExternal, 1); +/******/ }); +/******/ } +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/remotes loading */ +/******/ !function() { +/******/ var chunkMapping = { +/******/ "pages_home_test-remote-hook_tsx_hasBoundary": [ +/******/ "webpack/container/remote/shop/useCustomRemoteHook" +/******/ ], +/******/ "pages_checkout_index_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/index" +/******/ ], +/******/ "pages_checkout_slug_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/[...slug]" +/******/ ], +/******/ "pages_checkout_pid_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/[pid]" +/******/ ], +/******/ "pages_checkout_exposed-pages_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/exposed-pages" +/******/ ], +/******/ "pages_checkout_test-check-button_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/test-check-button" +/******/ ], +/******/ "pages_checkout_test-title_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/test-title" +/******/ ], +/******/ "pages_shop_exposed-pages_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/exposed-pages" +/******/ ], +/******/ "pages_shop_index_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/index" +/******/ ], +/******/ "pages_shop_test-webpack-png_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-png" +/******/ ], +/******/ "pages_shop_test-webpack-svg_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-svg" +/******/ ], +/******/ "pages_shop_products_slug_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/products/[...slug]" +/******/ ], +/******/ "webpack_container_remote_shop_menu": [ +/******/ "webpack/container/remote/shop/menu" +/******/ ], +/******/ "webpack_container_remote_checkout_menu": [ +/******/ "webpack/container/remote/checkout/menu" +/******/ ], +/******/ "webpack_container_remote_checkout_CheckoutTitle": [ +/******/ "webpack/container/remote/checkout/CheckoutTitle" +/******/ ], +/******/ "webpack_container_remote_checkout_ButtonOldAnt": [ +/******/ "webpack/container/remote/checkout/ButtonOldAnt" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackSvg": [ +/******/ "webpack/container/remote/shop/WebpackSvg" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackPng": [ +/******/ "webpack/container/remote/shop/WebpackPng" +/******/ ] +/******/ }; +/******/ var idToExternalAndNameMapping = { +/******/ "webpack/container/remote/shop/useCustomRemoteHook": [ +/******/ "default", +/******/ "./useCustomRemoteHook", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/index": [ +/******/ "default", +/******/ "./pages/checkout/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/[...slug]": [ +/******/ "default", +/******/ "./pages/checkout/[...slug]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/[pid]": [ +/******/ "default", +/******/ "./pages/checkout/[pid]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/exposed-pages": [ +/******/ "default", +/******/ "./pages/checkout/exposed-pages", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/test-check-button": [ +/******/ "default", +/******/ "./pages/checkout/test-check-button", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/test-title": [ +/******/ "default", +/******/ "./pages/checkout/test-title", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/exposed-pages": [ +/******/ "default", +/******/ "./pages/shop/exposed-pages", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/index": [ +/******/ "default", +/******/ "./pages/shop/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-png": [ +/******/ "default", +/******/ "./pages/shop/test-webpack-png", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-svg": [ +/******/ "default", +/******/ "./pages/shop/test-webpack-svg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/products/[...slug]": [ +/******/ "default", +/******/ "./pages/shop/products/[...slug]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/menu": [ +/******/ "default", +/******/ "./menu", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/menu": [ +/******/ "default", +/******/ "./menu", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/CheckoutTitle": [ +/******/ "default", +/******/ "./CheckoutTitle", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/ButtonOldAnt": [ +/******/ "default", +/******/ "./ButtonOldAnt", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackSvg": [ +/******/ "default", +/******/ "./WebpackSvg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackPng": [ +/******/ "default", +/******/ "./WebpackPng", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js" +/******/ ] +/******/ }; +/******/ __webpack_require__.f.remotes = function(chunkId, promises) { +/******/ if(__webpack_require__.o(chunkMapping, chunkId)) { +/******/ chunkMapping[chunkId].forEach(function(id) { +/******/ var getScope = __webpack_require__.R; +/******/ if(!getScope) getScope = []; +/******/ var data = idToExternalAndNameMapping[id]; +/******/ if(getScope.indexOf(data) >= 0) return; +/******/ getScope.push(data); +/******/ if(data.p) return promises.push(data.p); +/******/ var onError = function(error) { +/******/ if(!error) error = new Error("Container missing"); +/******/ if(typeof error.message === "string") +/******/ error.message += '\\nwhile loading "' + data[1] + '" from ' + data[2]; +/******/ __webpack_require__.m[id] = function() { +/******/ throw error; +/******/ } +/******/ data.p = 0; +/******/ }; +/******/ var handleFunction = function(fn, arg1, arg2, d, next, first) { +/******/ try { +/******/ var promise = fn(arg1, arg2); +/******/ if(promise && promise.then) { +/******/ var p = promise.then(function(result) { return next(result, d); }, onError); +/******/ if(first) promises.push(data.p = p); else return p; +/******/ } else { +/******/ return next(promise, d, first); +/******/ } +/******/ } catch(error) { +/******/ onError(error); +/******/ } +/******/ } +/******/ var onExternal = function(external, _, first) { return external ? handleFunction(__webpack_require__.I, data[0], 0, external, onInitialized, first) : onError(); }; +/******/ var onInitialized = function(_, external, first) { return handleFunction(external.get, data[1], getScope, 0, onFactory, first); }; +/******/ var onFactory = function(factory) { +/******/ data.p = 1; +/******/ __webpack_require__.m[id] = function(module) { +/******/ module.exports = factory(); +/******/ } +/******/ }; +/******/ handleFunction(__webpack_require__, data[2], 0, 0, onExternal, 1); +/******/ }); +/******/ } +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/runtimeId */ +/******/ !function() { +/******/ __webpack_require__.j = "webpack"; +/******/ }(); +/******/ +/******/ /* webpack/runtime/sharing */ +/******/ !function() { +/******/ __webpack_require__.S = {}; +/******/ var initPromises = {}; +/******/ var initTokens = {}; +/******/ __webpack_require__.I = function(name, initScope) { +/******/ if(!initScope) initScope = []; +/******/ // handling circular init calls +/******/ var initToken = initTokens[name]; +/******/ if(!initToken) initToken = initTokens[name] = {}; +/******/ if(initScope.indexOf(initToken) >= 0) return; +/******/ initScope.push(initToken); +/******/ // only runs once +/******/ if(initPromises[name]) return initPromises[name]; +/******/ // creates a new share scope if needed +/******/ if(!__webpack_require__.o(__webpack_require__.S, name)) __webpack_require__.S[name] = {}; +/******/ // runs all init snippets from all modules reachable +/******/ var scope = __webpack_require__.S[name]; +/******/ var warn = function(msg) { return typeof console !== "undefined" && console.warn && console.warn(msg); }; +/******/ var uniqueName = "home_app"; +/******/ var register = function(name, version, factory, eager) { +/******/ var versions = scope[name] = scope[name] || {}; +/******/ var activeVersion = versions[version]; +/******/ if(!activeVersion || (!activeVersion.loaded && (!eager != !activeVersion.eager ? eager : uniqueName > activeVersion.from))) versions[version] = { get: factory, from: uniqueName, eager: !!eager }; +/******/ }; +/******/ var initExternal = function(id) { +/******/ var handleError = function(err) { warn("Initialization of sharing external failed: " + err); }; +/******/ try { +/******/ var module = __webpack_require__(id); +/******/ if(!module) return; +/******/ var initFn = function(module) { return module && module.init && module.init(__webpack_require__.S[name], initScope); } +/******/ if(module.then) return promises.push(module.then(initFn, handleError)); +/******/ var initResult = initFn(module); +/******/ if(initResult && initResult.then) return promises.push(initResult['catch'](handleError)); +/******/ } catch(err) { handleError(err); } +/******/ } +/******/ var promises = []; +/******/ switch(name) { +/******/ case "default": { +/******/ register("antd", "4.24.9", function() { return __webpack_require__.e("node_modules_antd_es_index_js").then(function() { return function() { return __webpack_require__(/*! ../../node_modules/antd/es/index.js */ "../../node_modules/antd/es/index.js"); }; }); }); +/******/ initExternal("../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/chunks/remoteEntry.js"); +/******/ initExternal("../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/chunks/remoteEntry.js"); +/******/ } +/******/ break; +/******/ } +/******/ if(!promises.length) return initPromises[name] = 1; +/******/ return initPromises[name] = Promise.all(promises).then(function() { return initPromises[name] = 1; }); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/trusted types policy */ +/******/ !function() { +/******/ var policy; +/******/ __webpack_require__.tt = function() { +/******/ // Create Trusted Type policy if Trusted Types are available and the policy doesn't exist yet. +/******/ if (policy === undefined) { +/******/ policy = { +/******/ createScriptURL: function(url) { return url; } +/******/ }; +/******/ if (typeof trustedTypes !== "undefined" && trustedTypes.createPolicy) { +/******/ policy = trustedTypes.createPolicy("nextjs#bundler", policy); +/******/ } +/******/ } +/******/ return policy; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/trusted types script url */ +/******/ !function() { +/******/ __webpack_require__.tu = function(url) { return __webpack_require__.tt().createScriptURL(url); }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hot module replacement */ +/******/ !function() { +/******/ var currentModuleData = {}; +/******/ var installedModules = __webpack_require__.c; +/******/ +/******/ // module and require creation +/******/ var currentChildModule; +/******/ var currentParents = []; +/******/ +/******/ // status +/******/ var registeredStatusHandlers = []; +/******/ var currentStatus = "idle"; +/******/ +/******/ // while downloading +/******/ var blockingPromises = 0; +/******/ var blockingPromisesWaiting = []; +/******/ +/******/ // The update info +/******/ var currentUpdateApplyHandlers; +/******/ var queuedInvalidatedModules; +/******/ +/******/ // eslint-disable-next-line no-unused-vars +/******/ __webpack_require__.hmrD = currentModuleData; +/******/ +/******/ __webpack_require__.i.push(function (options) { +/******/ var module = options.module; +/******/ var require = createRequire(options.require, options.id); +/******/ module.hot = createModuleHotObject(options.id, module); +/******/ module.parents = currentParents; +/******/ module.children = []; +/******/ currentParents = []; +/******/ options.require = require; +/******/ }); +/******/ +/******/ __webpack_require__.hmrC = {}; +/******/ __webpack_require__.hmrI = {}; +/******/ +/******/ function createRequire(require, moduleId) { +/******/ var me = installedModules[moduleId]; +/******/ if (!me) return require; +/******/ var fn = function (request) { +/******/ if (me.hot.active) { +/******/ if (installedModules[request]) { +/******/ var parents = installedModules[request].parents; +/******/ if (parents.indexOf(moduleId) === -1) { +/******/ parents.push(moduleId); +/******/ } +/******/ } else { +/******/ currentParents = [moduleId]; +/******/ currentChildModule = request; +/******/ } +/******/ if (me.children.indexOf(request) === -1) { +/******/ me.children.push(request); +/******/ } +/******/ } else { +/******/ console.warn( +/******/ "[HMR] unexpected require(" + +/******/ request + +/******/ ") from disposed module " + +/******/ moduleId +/******/ ); +/******/ currentParents = []; +/******/ } +/******/ return require(request); +/******/ }; +/******/ var createPropertyDescriptor = function (name) { +/******/ return { +/******/ configurable: true, +/******/ enumerable: true, +/******/ get: function () { +/******/ return require[name]; +/******/ }, +/******/ set: function (value) { +/******/ require[name] = value; +/******/ } +/******/ }; +/******/ }; +/******/ for (var name in require) { +/******/ if (Object.prototype.hasOwnProperty.call(require, name) && name !== "e") { +/******/ Object.defineProperty(fn, name, createPropertyDescriptor(name)); +/******/ } +/******/ } +/******/ fn.e = function (chunkId) { +/******/ return trackBlockingPromise(require.e(chunkId)); +/******/ }; +/******/ return fn; +/******/ } +/******/ +/******/ function createModuleHotObject(moduleId, me) { +/******/ var _main = currentChildModule !== moduleId; +/******/ var hot = { +/******/ // private stuff +/******/ _acceptedDependencies: {}, +/******/ _acceptedErrorHandlers: {}, +/******/ _declinedDependencies: {}, +/******/ _selfAccepted: false, +/******/ _selfDeclined: false, +/******/ _selfInvalidated: false, +/******/ _disposeHandlers: [], +/******/ _main: _main, +/******/ _requireSelf: function () { +/******/ currentParents = me.parents.slice(); +/******/ currentChildModule = _main ? undefined : moduleId; +/******/ __webpack_require__(moduleId); +/******/ }, +/******/ +/******/ // Module API +/******/ active: true, +/******/ accept: function (dep, callback, errorHandler) { +/******/ if (dep === undefined) hot._selfAccepted = true; +/******/ else if (typeof dep === "function") hot._selfAccepted = dep; +/******/ else if (typeof dep === "object" && dep !== null) { +/******/ for (var i = 0; i < dep.length; i++) { +/******/ hot._acceptedDependencies[dep[i]] = callback || function () {}; +/******/ hot._acceptedErrorHandlers[dep[i]] = errorHandler; +/******/ } +/******/ } else { +/******/ hot._acceptedDependencies[dep] = callback || function () {}; +/******/ hot._acceptedErrorHandlers[dep] = errorHandler; +/******/ } +/******/ }, +/******/ decline: function (dep) { +/******/ if (dep === undefined) hot._selfDeclined = true; +/******/ else if (typeof dep === "object" && dep !== null) +/******/ for (var i = 0; i < dep.length; i++) +/******/ hot._declinedDependencies[dep[i]] = true; +/******/ else hot._declinedDependencies[dep] = true; +/******/ }, +/******/ dispose: function (callback) { +/******/ hot._disposeHandlers.push(callback); +/******/ }, +/******/ addDisposeHandler: function (callback) { +/******/ hot._disposeHandlers.push(callback); +/******/ }, +/******/ removeDisposeHandler: function (callback) { +/******/ var idx = hot._disposeHandlers.indexOf(callback); +/******/ if (idx >= 0) hot._disposeHandlers.splice(idx, 1); +/******/ }, +/******/ invalidate: function () { +/******/ this._selfInvalidated = true; +/******/ switch (currentStatus) { +/******/ case "idle": +/******/ currentUpdateApplyHandlers = []; +/******/ Object.keys(__webpack_require__.hmrI).forEach(function (key) { +/******/ __webpack_require__.hmrI[key]( +/******/ moduleId, +/******/ currentUpdateApplyHandlers +/******/ ); +/******/ }); +/******/ setStatus("ready"); +/******/ break; +/******/ case "ready": +/******/ Object.keys(__webpack_require__.hmrI).forEach(function (key) { +/******/ __webpack_require__.hmrI[key]( +/******/ moduleId, +/******/ currentUpdateApplyHandlers +/******/ ); +/******/ }); +/******/ break; +/******/ case "prepare": +/******/ case "check": +/******/ case "dispose": +/******/ case "apply": +/******/ (queuedInvalidatedModules = queuedInvalidatedModules || []).push( +/******/ moduleId +/******/ ); +/******/ break; +/******/ default: +/******/ // ignore requests in error states +/******/ break; +/******/ } +/******/ }, +/******/ +/******/ // Management API +/******/ check: hotCheck, +/******/ apply: hotApply, +/******/ status: function (l) { +/******/ if (!l) return currentStatus; +/******/ registeredStatusHandlers.push(l); +/******/ }, +/******/ addStatusHandler: function (l) { +/******/ registeredStatusHandlers.push(l); +/******/ }, +/******/ removeStatusHandler: function (l) { +/******/ var idx = registeredStatusHandlers.indexOf(l); +/******/ if (idx >= 0) registeredStatusHandlers.splice(idx, 1); +/******/ }, +/******/ +/******/ //inherit from previous dispose call +/******/ data: currentModuleData[moduleId] +/******/ }; +/******/ currentChildModule = undefined; +/******/ return hot; +/******/ } +/******/ +/******/ function setStatus(newStatus) { +/******/ currentStatus = newStatus; +/******/ var results = []; +/******/ +/******/ for (var i = 0; i < registeredStatusHandlers.length; i++) +/******/ results[i] = registeredStatusHandlers[i].call(null, newStatus); +/******/ +/******/ return Promise.all(results); +/******/ } +/******/ +/******/ function unblock() { +/******/ if (--blockingPromises === 0) { +/******/ setStatus("ready").then(function () { +/******/ if (blockingPromises === 0) { +/******/ var list = blockingPromisesWaiting; +/******/ blockingPromisesWaiting = []; +/******/ for (var i = 0; i < list.length; i++) { +/******/ list[i](); +/******/ } +/******/ } +/******/ }); +/******/ } +/******/ } +/******/ +/******/ function trackBlockingPromise(promise) { +/******/ switch (currentStatus) { +/******/ case "ready": +/******/ setStatus("prepare"); +/******/ /* fallthrough */ +/******/ case "prepare": +/******/ blockingPromises++; +/******/ promise.then(unblock, unblock); +/******/ return promise; +/******/ default: +/******/ return promise; +/******/ } +/******/ } +/******/ +/******/ function waitForBlockingPromises(fn) { +/******/ if (blockingPromises === 0) return fn(); +/******/ return new Promise(function (resolve) { +/******/ blockingPromisesWaiting.push(function () { +/******/ resolve(fn()); +/******/ }); +/******/ }); +/******/ } +/******/ +/******/ function hotCheck(applyOnUpdate) { +/******/ if (currentStatus !== "idle") { +/******/ throw new Error("check() is only allowed in idle status"); +/******/ } +/******/ return setStatus("check") +/******/ .then(__webpack_require__.hmrM) +/******/ .then(function (update) { +/******/ if (!update) { +/******/ return setStatus(applyInvalidatedModules() ? "ready" : "idle").then( +/******/ function () { +/******/ return null; +/******/ } +/******/ ); +/******/ } +/******/ +/******/ return setStatus("prepare").then(function () { +/******/ var updatedModules = []; +/******/ currentUpdateApplyHandlers = []; +/******/ +/******/ return Promise.all( +/******/ Object.keys(__webpack_require__.hmrC).reduce(function ( +/******/ promises, +/******/ key +/******/ ) { +/******/ __webpack_require__.hmrC[key]( +/******/ update.c, +/******/ update.r, +/******/ update.m, +/******/ promises, +/******/ currentUpdateApplyHandlers, +/******/ updatedModules +/******/ ); +/******/ return promises; +/******/ }, +/******/ []) +/******/ ).then(function () { +/******/ return waitForBlockingPromises(function () { +/******/ if (applyOnUpdate) { +/******/ return internalApply(applyOnUpdate); +/******/ } else { +/******/ return setStatus("ready").then(function () { +/******/ return updatedModules; +/******/ }); +/******/ } +/******/ }); +/******/ }); +/******/ }); +/******/ }); +/******/ } +/******/ +/******/ function hotApply(options) { +/******/ if (currentStatus !== "ready") { +/******/ return Promise.resolve().then(function () { +/******/ throw new Error( +/******/ "apply() is only allowed in ready status (state: " + +/******/ currentStatus + +/******/ ")" +/******/ ); +/******/ }); +/******/ } +/******/ return internalApply(options); +/******/ } +/******/ +/******/ function internalApply(options) { +/******/ options = options || {}; +/******/ +/******/ applyInvalidatedModules(); +/******/ +/******/ var results = currentUpdateApplyHandlers.map(function (handler) { +/******/ return handler(options); +/******/ }); +/******/ currentUpdateApplyHandlers = undefined; +/******/ +/******/ var errors = results +/******/ .map(function (r) { +/******/ return r.error; +/******/ }) +/******/ .filter(Boolean); +/******/ +/******/ if (errors.length > 0) { +/******/ return setStatus("abort").then(function () { +/******/ throw errors[0]; +/******/ }); +/******/ } +/******/ +/******/ // Now in "dispose" phase +/******/ var disposePromise = setStatus("dispose"); +/******/ +/******/ results.forEach(function (result) { +/******/ if (result.dispose) result.dispose(); +/******/ }); +/******/ +/******/ // Now in "apply" phase +/******/ var applyPromise = setStatus("apply"); +/******/ +/******/ var error; +/******/ var reportError = function (err) { +/******/ if (!error) error = err; +/******/ }; +/******/ +/******/ var outdatedModules = []; +/******/ results.forEach(function (result) { +/******/ if (result.apply) { +/******/ var modules = result.apply(reportError); +/******/ if (modules) { +/******/ for (var i = 0; i < modules.length; i++) { +/******/ outdatedModules.push(modules[i]); +/******/ } +/******/ } +/******/ } +/******/ }); +/******/ +/******/ return Promise.all([disposePromise, applyPromise]).then(function () { +/******/ // handle errors in accept handlers and self accepted module load +/******/ if (error) { +/******/ return setStatus("fail").then(function () { +/******/ throw error; +/******/ }); +/******/ } +/******/ +/******/ if (queuedInvalidatedModules) { +/******/ return internalApply(options).then(function (list) { +/******/ outdatedModules.forEach(function (moduleId) { +/******/ if (list.indexOf(moduleId) < 0) list.push(moduleId); +/******/ }); +/******/ return list; +/******/ }); +/******/ } +/******/ +/******/ return setStatus("idle").then(function () { +/******/ return outdatedModules; +/******/ }); +/******/ }); +/******/ } +/******/ +/******/ function applyInvalidatedModules() { +/******/ if (queuedInvalidatedModules) { +/******/ if (!currentUpdateApplyHandlers) currentUpdateApplyHandlers = []; +/******/ Object.keys(__webpack_require__.hmrI).forEach(function (key) { +/******/ queuedInvalidatedModules.forEach(function (moduleId) { +/******/ __webpack_require__.hmrI[key]( +/******/ moduleId, +/******/ currentUpdateApplyHandlers +/******/ ); +/******/ }); +/******/ }); +/******/ queuedInvalidatedModules = undefined; +/******/ return true; +/******/ } +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/publicPath */ +/******/ !function() { +/******/ var scriptUrl; +/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +/******/ var document = __webpack_require__.g.document; +/******/ if (!scriptUrl && document) { +/******/ if (document.currentScript) +/******/ scriptUrl = document.currentScript.src +/******/ if (!scriptUrl) { +/******/ var scripts = document.getElementsByTagName("script"); +/******/ if(scripts.length) scriptUrl = scripts[scripts.length - 1].src +/******/ } +/******/ } +/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration +/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic. +/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/"); +/******/ __webpack_require__.p = scriptUrl + "../../"; +/******/ }(); +/******/ +/******/ /* webpack/runtime/react refresh */ +/******/ !function() { +/******/ if (__webpack_require__.i) { +/******/ __webpack_require__.i.push(function(options) { +/******/ var originalFactory = options.factory; +/******/ options.factory = function(moduleObject, moduleExports, webpackRequire) { +/******/ var hasRefresh = typeof self !== "undefined" && !!self.$RefreshInterceptModuleExecution$; +/******/ var cleanup = hasRefresh ? self.$RefreshInterceptModuleExecution$(moduleObject.id) : function() {}; +/******/ try { +/******/ originalFactory.call(this, moduleObject, moduleExports, webpackRequire); +/******/ } finally { +/******/ cleanup(); +/******/ } +/******/ } +/******/ }) +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/compat */ +/******/ +/******/ +/******/ // noop fns to prevent runtime errors during initialization +/******/ if (typeof self !== "undefined") { +/******/ self.$RefreshReg$ = function () {}; +/******/ self.$RefreshSig$ = function () { +/******/ return function (type) { +/******/ return type; +/******/ }; +/******/ }; +/******/ } +/******/ +/******/ /* webpack/runtime/consumes */ +/******/ !function() { +/******/ var parseVersion = function(str) { +/******/ // see webpack/lib/util/semver.js for original code +/******/ var p=function(p){return p.split(".").map((function(p){return+p==p?+p:p}))},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r; +/******/ } +/******/ var versionLt = function(a, b) { +/******/ // see webpack/lib/util/semver.js for original code +/******/ a=parseVersion(a),b=parseVersion(b);for(var r=0;;){if(r>=a.length)return r=b.length)return"u"==n;var t=b[r],f=(typeof t)[0];if(n!=f)return"o"==n&&"n"==f||("s"==f||"u"==n);if("o"!=n&&"u"!=n&&e!=t)return e=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var e=1,a=1;a0?".":"")+(e=2,t)}return n}var g=[];for(a=1;a=version.length||"o"==(s=(typeof(f=version[n]))[0]))return!a||("u"==g?i>e&&!r:""==g!=r);if("u"==s){if(!a||"u"!=g)return!1}else if(a)if(g==s)if(i<=e){if(f!=range[i])return!1}else{if(r?f>range[i]:f=a.length)return r=b.length)return"u"==n;var t=b[r],f=(typeof t)[0];if(n!=f)return"o"==n&&"n"==f||("s"==f||"u"==n);if("o"!=n&&"u"!=n&&e!=t)return e=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var e=1,a=1;a0?".":"")+(e=2,t)}return n}var g=[];for(a=1;a=version.length||"o"==(s=(typeof(f=version[n]))[0]))return!a||("u"==g?i>e&&!r:""==g!=r);if("u"==s){if(!a||"u"!=g)return!1}else if(a)if(g==s)if(i<=e){if(f!=range[i])return!1}else{if(r?f>range[i]:f 0) { +/******/ var queueItem = queue.pop(); +/******/ var moduleId = queueItem.id; +/******/ var chain = queueItem.chain; +/******/ var module = __webpack_require__.c[moduleId]; +/******/ if ( +/******/ !module || +/******/ (module.hot._selfAccepted && !module.hot._selfInvalidated) +/******/ ) +/******/ continue; +/******/ if (module.hot._selfDeclined) { +/******/ return { +/******/ type: "self-declined", +/******/ chain: chain, +/******/ moduleId: moduleId +/******/ }; +/******/ } +/******/ if (module.hot._main) { +/******/ return { +/******/ type: "unaccepted", +/******/ chain: chain, +/******/ moduleId: moduleId +/******/ }; +/******/ } +/******/ for (var i = 0; i < module.parents.length; i++) { +/******/ var parentId = module.parents[i]; +/******/ var parent = __webpack_require__.c[parentId]; +/******/ if (!parent) continue; +/******/ if (parent.hot._declinedDependencies[moduleId]) { +/******/ return { +/******/ type: "declined", +/******/ chain: chain.concat([parentId]), +/******/ moduleId: moduleId, +/******/ parentId: parentId +/******/ }; +/******/ } +/******/ if (outdatedModules.indexOf(parentId) !== -1) continue; +/******/ if (parent.hot._acceptedDependencies[moduleId]) { +/******/ if (!outdatedDependencies[parentId]) +/******/ outdatedDependencies[parentId] = []; +/******/ addAllToSet(outdatedDependencies[parentId], [moduleId]); +/******/ continue; +/******/ } +/******/ delete outdatedDependencies[parentId]; +/******/ outdatedModules.push(parentId); +/******/ queue.push({ +/******/ chain: chain.concat([parentId]), +/******/ id: parentId +/******/ }); +/******/ } +/******/ } +/******/ +/******/ return { +/******/ type: "accepted", +/******/ moduleId: updateModuleId, +/******/ outdatedModules: outdatedModules, +/******/ outdatedDependencies: outdatedDependencies +/******/ }; +/******/ } +/******/ +/******/ function addAllToSet(a, b) { +/******/ for (var i = 0; i < b.length; i++) { +/******/ var item = b[i]; +/******/ if (a.indexOf(item) === -1) a.push(item); +/******/ } +/******/ } +/******/ +/******/ // at begin all updates modules are outdated +/******/ // the "outdated" status can propagate to parents if they don't accept the children +/******/ var outdatedDependencies = {}; +/******/ var outdatedModules = []; +/******/ var appliedUpdate = {}; +/******/ +/******/ var warnUnexpectedRequire = function warnUnexpectedRequire(module) { +/******/ console.warn( +/******/ "[HMR] unexpected require(" + module.id + ") to disposed module" +/******/ ); +/******/ }; +/******/ +/******/ for (var moduleId in currentUpdate) { +/******/ if (__webpack_require__.o(currentUpdate, moduleId)) { +/******/ var newModuleFactory = currentUpdate[moduleId]; +/******/ /** @type {TODO} */ +/******/ var result; +/******/ if (newModuleFactory) { +/******/ result = getAffectedModuleEffects(moduleId); +/******/ } else { +/******/ result = { +/******/ type: "disposed", +/******/ moduleId: moduleId +/******/ }; +/******/ } +/******/ /** @type {Error|false} */ +/******/ var abortError = false; +/******/ var doApply = false; +/******/ var doDispose = false; +/******/ var chainInfo = ""; +/******/ if (result.chain) { +/******/ chainInfo = "\\nUpdate propagation: " + result.chain.join(" -> "); +/******/ } +/******/ switch (result.type) { +/******/ case "self-declined": +/******/ if (options.onDeclined) options.onDeclined(result); +/******/ if (!options.ignoreDeclined) +/******/ abortError = new Error( +/******/ "Aborted because of self decline: " + +/******/ result.moduleId + +/******/ chainInfo +/******/ ); +/******/ break; +/******/ case "declined": +/******/ if (options.onDeclined) options.onDeclined(result); +/******/ if (!options.ignoreDeclined) +/******/ abortError = new Error( +/******/ "Aborted because of declined dependency: " + +/******/ result.moduleId + +/******/ " in " + +/******/ result.parentId + +/******/ chainInfo +/******/ ); +/******/ break; +/******/ case "unaccepted": +/******/ if (options.onUnaccepted) options.onUnaccepted(result); +/******/ if (!options.ignoreUnaccepted) +/******/ abortError = new Error( +/******/ "Aborted because " + moduleId + " is not accepted" + chainInfo +/******/ ); +/******/ break; +/******/ case "accepted": +/******/ if (options.onAccepted) options.onAccepted(result); +/******/ doApply = true; +/******/ break; +/******/ case "disposed": +/******/ if (options.onDisposed) options.onDisposed(result); +/******/ doDispose = true; +/******/ break; +/******/ default: +/******/ throw new Error("Unexception type " + result.type); +/******/ } +/******/ if (abortError) { +/******/ return { +/******/ error: abortError +/******/ }; +/******/ } +/******/ if (doApply) { +/******/ appliedUpdate[moduleId] = newModuleFactory; +/******/ addAllToSet(outdatedModules, result.outdatedModules); +/******/ for (moduleId in result.outdatedDependencies) { +/******/ if (__webpack_require__.o(result.outdatedDependencies, moduleId)) { +/******/ if (!outdatedDependencies[moduleId]) +/******/ outdatedDependencies[moduleId] = []; +/******/ addAllToSet( +/******/ outdatedDependencies[moduleId], +/******/ result.outdatedDependencies[moduleId] +/******/ ); +/******/ } +/******/ } +/******/ } +/******/ if (doDispose) { +/******/ addAllToSet(outdatedModules, [result.moduleId]); +/******/ appliedUpdate[moduleId] = warnUnexpectedRequire; +/******/ } +/******/ } +/******/ } +/******/ currentUpdate = undefined; +/******/ +/******/ // Store self accepted outdated modules to require them later by the module system +/******/ var outdatedSelfAcceptedModules = []; +/******/ for (var j = 0; j < outdatedModules.length; j++) { +/******/ var outdatedModuleId = outdatedModules[j]; +/******/ var module = __webpack_require__.c[outdatedModuleId]; +/******/ if ( +/******/ module && +/******/ (module.hot._selfAccepted || module.hot._main) && +/******/ // removed self-accepted modules should not be required +/******/ appliedUpdate[outdatedModuleId] !== warnUnexpectedRequire && +/******/ // when called invalidate self-accepting is not possible +/******/ !module.hot._selfInvalidated +/******/ ) { +/******/ outdatedSelfAcceptedModules.push({ +/******/ module: outdatedModuleId, +/******/ require: module.hot._requireSelf, +/******/ errorHandler: module.hot._selfAccepted +/******/ }); +/******/ } +/******/ } +/******/ +/******/ var moduleOutdatedDependencies; +/******/ +/******/ return { +/******/ dispose: function () { +/******/ currentUpdateRemovedChunks.forEach(function (chunkId) { +/******/ delete installedChunks[chunkId]; +/******/ }); +/******/ currentUpdateRemovedChunks = undefined; +/******/ +/******/ var idx; +/******/ var queue = outdatedModules.slice(); +/******/ while (queue.length > 0) { +/******/ var moduleId = queue.pop(); +/******/ var module = __webpack_require__.c[moduleId]; +/******/ if (!module) continue; +/******/ +/******/ var data = {}; +/******/ +/******/ // Call dispose handlers +/******/ var disposeHandlers = module.hot._disposeHandlers; +/******/ for (j = 0; j < disposeHandlers.length; j++) { +/******/ disposeHandlers[j].call(null, data); +/******/ } +/******/ __webpack_require__.hmrD[moduleId] = data; +/******/ +/******/ // disable module (this disables requires from this module) +/******/ module.hot.active = false; +/******/ +/******/ // remove module from cache +/******/ delete __webpack_require__.c[moduleId]; +/******/ +/******/ // when disposing there is no need to call dispose handler +/******/ delete outdatedDependencies[moduleId]; +/******/ +/******/ // remove "parents" references from all children +/******/ for (j = 0; j < module.children.length; j++) { +/******/ var child = __webpack_require__.c[module.children[j]]; +/******/ if (!child) continue; +/******/ idx = child.parents.indexOf(moduleId); +/******/ if (idx >= 0) { +/******/ child.parents.splice(idx, 1); +/******/ } +/******/ } +/******/ } +/******/ +/******/ // remove outdated dependency from module children +/******/ var dependency; +/******/ for (var outdatedModuleId in outdatedDependencies) { +/******/ if (__webpack_require__.o(outdatedDependencies, outdatedModuleId)) { +/******/ module = __webpack_require__.c[outdatedModuleId]; +/******/ if (module) { +/******/ moduleOutdatedDependencies = +/******/ outdatedDependencies[outdatedModuleId]; +/******/ for (j = 0; j < moduleOutdatedDependencies.length; j++) { +/******/ dependency = moduleOutdatedDependencies[j]; +/******/ idx = module.children.indexOf(dependency); +/******/ if (idx >= 0) module.children.splice(idx, 1); +/******/ } +/******/ } +/******/ } +/******/ } +/******/ }, +/******/ apply: function (reportError) { +/******/ // insert new code +/******/ for (var updateModuleId in appliedUpdate) { +/******/ if (__webpack_require__.o(appliedUpdate, updateModuleId)) { +/******/ __webpack_require__.m[updateModuleId] = appliedUpdate[updateModuleId]; +/******/ } +/******/ } +/******/ +/******/ // run new runtime modules +/******/ for (var i = 0; i < currentUpdateRuntime.length; i++) { +/******/ currentUpdateRuntime[i](__webpack_require__); +/******/ } +/******/ +/******/ // call accept handlers +/******/ for (var outdatedModuleId in outdatedDependencies) { +/******/ if (__webpack_require__.o(outdatedDependencies, outdatedModuleId)) { +/******/ var module = __webpack_require__.c[outdatedModuleId]; +/******/ if (module) { +/******/ moduleOutdatedDependencies = +/******/ outdatedDependencies[outdatedModuleId]; +/******/ var callbacks = []; +/******/ var errorHandlers = []; +/******/ var dependenciesForCallbacks = []; +/******/ for (var j = 0; j < moduleOutdatedDependencies.length; j++) { +/******/ var dependency = moduleOutdatedDependencies[j]; +/******/ var acceptCallback = +/******/ module.hot._acceptedDependencies[dependency]; +/******/ var errorHandler = +/******/ module.hot._acceptedErrorHandlers[dependency]; +/******/ if (acceptCallback) { +/******/ if (callbacks.indexOf(acceptCallback) !== -1) continue; +/******/ callbacks.push(acceptCallback); +/******/ errorHandlers.push(errorHandler); +/******/ dependenciesForCallbacks.push(dependency); +/******/ } +/******/ } +/******/ for (var k = 0; k < callbacks.length; k++) { +/******/ try { +/******/ callbacks[k].call(null, moduleOutdatedDependencies); +/******/ } catch (err) { +/******/ if (typeof errorHandlers[k] === "function") { +/******/ try { +/******/ errorHandlers[k](err, { +/******/ moduleId: outdatedModuleId, +/******/ dependencyId: dependenciesForCallbacks[k] +/******/ }); +/******/ } catch (err2) { +/******/ if (options.onErrored) { +/******/ options.onErrored({ +/******/ type: "accept-error-handler-errored", +/******/ moduleId: outdatedModuleId, +/******/ dependencyId: dependenciesForCallbacks[k], +/******/ error: err2, +/******/ originalError: err +/******/ }); +/******/ } +/******/ if (!options.ignoreErrored) { +/******/ reportError(err2); +/******/ reportError(err); +/******/ } +/******/ } +/******/ } else { +/******/ if (options.onErrored) { +/******/ options.onErrored({ +/******/ type: "accept-errored", +/******/ moduleId: outdatedModuleId, +/******/ dependencyId: dependenciesForCallbacks[k], +/******/ error: err +/******/ }); +/******/ } +/******/ if (!options.ignoreErrored) { +/******/ reportError(err); +/******/ } +/******/ } +/******/ } +/******/ } +/******/ } +/******/ } +/******/ } +/******/ +/******/ // Load self accepted modules +/******/ for (var o = 0; o < outdatedSelfAcceptedModules.length; o++) { +/******/ var item = outdatedSelfAcceptedModules[o]; +/******/ var moduleId = item.module; +/******/ try { +/******/ item.require(moduleId); +/******/ } catch (err) { +/******/ if (typeof item.errorHandler === "function") { +/******/ try { +/******/ item.errorHandler(err, { +/******/ moduleId: moduleId, +/******/ module: __webpack_require__.c[moduleId] +/******/ }); +/******/ } catch (err2) { +/******/ if (options.onErrored) { +/******/ options.onErrored({ +/******/ type: "self-accept-error-handler-errored", +/******/ moduleId: moduleId, +/******/ error: err2, +/******/ originalError: err +/******/ }); +/******/ } +/******/ if (!options.ignoreErrored) { +/******/ reportError(err2); +/******/ reportError(err); +/******/ } +/******/ } +/******/ } else { +/******/ if (options.onErrored) { +/******/ options.onErrored({ +/******/ type: "self-accept-errored", +/******/ moduleId: moduleId, +/******/ error: err +/******/ }); +/******/ } +/******/ if (!options.ignoreErrored) { +/******/ reportError(err); +/******/ } +/******/ } +/******/ } +/******/ } +/******/ +/******/ return outdatedModules; +/******/ } +/******/ }; +/******/ } +/******/ __webpack_require__.hmrI.jsonp = function (moduleId, applyHandlers) { +/******/ if (!currentUpdate) { +/******/ currentUpdate = {}; +/******/ currentUpdateRuntime = []; +/******/ currentUpdateRemovedChunks = []; +/******/ applyHandlers.push(applyHandler); +/******/ } +/******/ if (!__webpack_require__.o(currentUpdate, moduleId)) { +/******/ currentUpdate[moduleId] = __webpack_require__.m[moduleId]; +/******/ } +/******/ }; +/******/ __webpack_require__.hmrC.jsonp = function ( +/******/ chunkIds, +/******/ removedChunks, +/******/ removedModules, +/******/ promises, +/******/ applyHandlers, +/******/ updatedModulesList +/******/ ) { +/******/ applyHandlers.push(applyHandler); +/******/ currentUpdateChunks = {}; +/******/ currentUpdateRemovedChunks = removedChunks; +/******/ currentUpdate = removedModules.reduce(function (obj, key) { +/******/ obj[key] = false; +/******/ return obj; +/******/ }, {}); +/******/ currentUpdateRuntime = []; +/******/ chunkIds.forEach(function (chunkId) { +/******/ if ( +/******/ __webpack_require__.o(installedChunks, chunkId) && +/******/ installedChunks[chunkId] !== undefined +/******/ ) { +/******/ promises.push(loadUpdateChunk(chunkId, updatedModulesList)); +/******/ currentUpdateChunks[chunkId] = true; +/******/ } else { +/******/ currentUpdateChunks[chunkId] = false; +/******/ } +/******/ }); +/******/ if (__webpack_require__.f) { +/******/ __webpack_require__.f.jsonpHmr = function (chunkId, promises) { +/******/ if ( +/******/ currentUpdateChunks && +/******/ __webpack_require__.o(currentUpdateChunks, chunkId) && +/******/ !currentUpdateChunks[chunkId] +/******/ ) { +/******/ promises.push(loadUpdateChunk(chunkId)); +/******/ currentUpdateChunks[chunkId] = true; +/******/ } +/******/ }; +/******/ } +/******/ }; +/******/ +/******/ __webpack_require__.hmrM = function() { +/******/ if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API"); +/******/ return fetch(__webpack_require__.p + __webpack_require__.hmrF()).then(function(response) { +/******/ if(response.status === 404) return; // no update available +/******/ if(!response.ok) throw new Error("Failed to fetch update manifest " + response.statusText); +/******/ return response.json(); +/******/ }); +/******/ }; +/******/ +/******/ __webpack_require__.O.j = function(chunkId) { return installedChunks[chunkId] === 0; }; +/******/ +/******/ // install a JSONP callback for chunk loading +/******/ var webpackJsonpCallback = function(parentChunkLoadingFunction, data) { +/******/ var chunkIds = data[0]; +/******/ var moreModules = data[1]; +/******/ var runtime = data[2]; +/******/ // add "moreModules" to the modules object, +/******/ // then flag all "chunkIds" as loaded and fire callback +/******/ var moduleId, chunkId, i = 0; +/******/ if(chunkIds.some(function(id) { return installedChunks[id] !== 0; })) { +/******/ for(moduleId in moreModules) { +/******/ if(__webpack_require__.o(moreModules, moduleId)) { +/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(runtime) var result = runtime(__webpack_require__); +/******/ } +/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { +/******/ installedChunks[chunkId][0](); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } +/******/ return __webpack_require__.O(result); +/******/ } +/******/ +/******/ var chunkLoadingGlobal = self["webpackChunkhome_app"] = self["webpackChunkhome_app"] || []; +/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); +/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); +/******/ }(); +/******/ +/******/ /* webpack/runtime/nonce */ +/******/ !function() { +/******/ __webpack_require__.nc = undefined; +/******/ }(); +/******/ +/************************************************************************/ +/******/ +/******/ // module factories are used so entry inlining is disabled +/******/ +/******/ })() +; +//# sourceMappingURL=webpack.js.map" +`; + +exports[`Next.js build output server partial remote 1`] = `null`; + +exports[`Next.js build output server remoteEntry.js 1`] = ` +"/******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "webpack/container/entry/home_app": +/*!***********************!*\\ + !*** container entry ***! + \\***********************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +var moduleMap = { + "./pages-map": function() { + return __webpack_require__.e("dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_dist_packages_nextjs-mf_src_loaders_-50dce4").then(function() { return function() { return (__webpack_require__(/*! ../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js */ "../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js")); }; }); + }, + "./pages-map-v2": function() { + return __webpack_require__.e("dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_v2_dist_packages_nextjs-mf_src_loade-8dd7f8").then(function() { return function() { return (__webpack_require__(/*! ../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js?v2!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js */ "../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js?v2!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js")); }; }); + }, + "./pages/dynamic-remote": function() { + return __webpack_require__.e("pages_dynamic-remote_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/dynamic-remote.js */ "./pages/dynamic-remote.js")); }; }); + }, + "./pages/index": function() { + return __webpack_require__.e("pages_index_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/index.tsx */ "./pages/index.tsx")); }; }); + }, + "./pages/checkout/[...slug]": function() { + return __webpack_require__.e("pages_checkout_slug_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/[...slug].tsx */ "./pages/checkout/[...slug].tsx")); }; }); + }, + "./pages/checkout/[pid]": function() { + return __webpack_require__.e("pages_checkout_pid_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/[pid].tsx */ "./pages/checkout/[pid].tsx")); }; }); + }, + "./pages/checkout/exposed-pages": function() { + return __webpack_require__.e("pages_checkout_exposed-pages_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/exposed-pages.tsx */ "./pages/checkout/exposed-pages.tsx")); }; }); + }, + "./pages/checkout/index": function() { + return __webpack_require__.e("pages_checkout_index_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/index.tsx */ "./pages/checkout/index.tsx")); }; }); + }, + "./pages/checkout/test-check-button": function() { + return __webpack_require__.e("pages_checkout_test-check-button_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/test-check-button.tsx */ "./pages/checkout/test-check-button.tsx")); }; }); + }, + "./pages/checkout/test-title": function() { + return __webpack_require__.e("pages_checkout_test-title_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/test-title.tsx */ "./pages/checkout/test-title.tsx")); }; }); + }, + "./pages/home/exposed-pages": function() { + return __webpack_require__.e("pages_home_exposed-pages_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/exposed-pages.tsx */ "./pages/home/exposed-pages.tsx")); }; }); + }, + "./pages/home/test-broken-remotes": function() { + return __webpack_require__.e("pages_home_test-broken-remotes_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-broken-remotes.tsx */ "./pages/home/test-broken-remotes.tsx")); }; }); + }, + "./pages/home/test-remote-hook": function() { + return __webpack_require__.e("pages_home_test-remote-hook_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-remote-hook.tsx */ "./pages/home/test-remote-hook.tsx")); }; }); + }, + "./pages/home/test-shared-nav": function() { + return __webpack_require__.e("pages_home_test-shared-nav_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-shared-nav.tsx */ "./pages/home/test-shared-nav.tsx")); }; }); + }, + "./pages/shop/exposed-pages": function() { + return __webpack_require__.e("pages_shop_exposed-pages_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/exposed-pages.js */ "./pages/shop/exposed-pages.js")); }; }); + }, + "./pages/shop/index": function() { + return __webpack_require__.e("pages_shop_index_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/index.js */ "./pages/shop/index.js")); }; }); + }, + "./pages/shop/test-webpack-png": function() { + return __webpack_require__.e("pages_shop_test-webpack-png_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/test-webpack-png.js */ "./pages/shop/test-webpack-png.js")); }; }); + }, + "./pages/shop/test-webpack-svg": function() { + return __webpack_require__.e("pages_shop_test-webpack-svg_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/test-webpack-svg.js */ "./pages/shop/test-webpack-svg.js")); }; }); + }, + "./pages/shop/products/[...slug]": function() { + return __webpack_require__.e("pages_shop_products_slug_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/products/[...slug].js */ "./pages/shop/products/[...slug].js")); }; }); + }, + "./SharedNav": function() { + return __webpack_require__.e("components_SharedNav_tsx").then(function() { return function() { return (__webpack_require__(/*! ./components/SharedNav */ "./components/SharedNav.tsx")); }; }); + }, + "./menu": function() { + return __webpack_require__.e("components_menu_tsx").then(function() { return function() { return (__webpack_require__(/*! ./components/menu */ "./components/menu.tsx")); }; }); + } +}; +var get = function(module, getScope) { + __webpack_require__.R = getScope; + getScope = ( + __webpack_require__.o(moduleMap, module) + ? moduleMap[module]() + : Promise.resolve().then(function() { + throw new Error('Module "' + module + '" does not exist in container.'); + }) + ); + __webpack_require__.R = undefined; + return getScope; +}; +var init = function(shareScope, initScope) { + if (!__webpack_require__.S) return; + var name = "default" + var oldScope = __webpack_require__.S[name]; + if(oldScope && oldScope !== shareScope) throw new Error("Container initialization failed as it has already been initialized with a different share scope"); + __webpack_require__.S[name] = shareScope; + return __webpack_require__.I(name, initScope); +}; + +// This exports getters to disallow modifications +__webpack_require__.d(exports, { + get: function() { return get; }, + init: function() { return init; } +}); + +/***/ }), + +/***/ "next/head": +/*!****************************!*\\ + !*** external "next/head" ***! + \\****************************/ +/***/ (function(module) { + +module.exports = require("next/head"); + +/***/ }), + +/***/ "next/router": +/*!******************************!*\\ + !*** external "next/router" ***! + \\******************************/ +/***/ (function(module) { + +module.exports = require("next/router"); + +/***/ }), + +/***/ "react": +/*!************************!*\\ + !*** external "react" ***! + \\************************/ +/***/ (function(module) { + +module.exports = require("react"); + +/***/ }), + +/***/ "react-dom": +/*!****************************!*\\ + !*** external "react-dom" ***! + \\****************************/ +/***/ (function(module) { + +module.exports = require("react-dom"); + +/***/ }), + +/***/ "react/jsx-dev-runtime": +/*!****************************************!*\\ + !*** external "react/jsx-dev-runtime" ***! + \\****************************************/ +/***/ (function(module) { + +module.exports = require("react/jsx-dev-runtime"); + +/***/ }), + +/***/ "buffer": +/*!*************************!*\\ + !*** external "buffer" ***! + \\*************************/ +/***/ (function(module) { + +module.exports = require("buffer"); + +/***/ }), + +/***/ "crypto": +/*!*************************!*\\ + !*** external "crypto" ***! + \\*************************/ +/***/ (function(module) { + +module.exports = require("crypto"); + +/***/ }), + +/***/ "http": +/*!***********************!*\\ + !*** external "http" ***! + \\***********************/ +/***/ (function(module) { + +module.exports = require("http"); + +/***/ }), + +/***/ "https": +/*!************************!*\\ + !*** external "https" ***! + \\************************/ +/***/ (function(module) { + +module.exports = require("https"); + +/***/ }), + +/***/ "punycode": +/*!***************************!*\\ + !*** external "punycode" ***! + \\***************************/ +/***/ (function(module) { + +module.exports = require("punycode"); + +/***/ }), + +/***/ "stream": +/*!*************************!*\\ + !*** external "stream" ***! + \\*************************/ +/***/ (function(module) { + +module.exports = require("stream"); + +/***/ }), + +/***/ "string_decoder": +/*!*********************************!*\\ + !*** external "string_decoder" ***! + \\*********************************/ +/***/ (function(module) { + +module.exports = require("string_decoder"); + +/***/ }), + +/***/ "url": +/*!**********************!*\\ + !*** external "url" ***! + \\**********************/ +/***/ (function(module) { + +module.exports = require("url"); + +/***/ }), + +/***/ "zlib": +/*!***********************!*\\ + !*** external "zlib" ***! + \\***********************/ +/***/ (function(module) { + +module.exports = require("zlib"); + +/***/ }), + +/***/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js": +/*!***********************************************************************************************************************************!*\\ + !*** ../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js ***! + \\***********************************************************************************************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var __resourceQuery = "?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js"; + +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { + const { importDelegatedModule } = await __webpack_require__.e(/*! import() */ "dist_packages_utilities_src_utils_common_js").then(__webpack_require__.bind(__webpack_require__, /*! @module-federation/utilities/src/utils/common */ "../../dist/packages/utilities/src/utils/common.js")); + // eslint-disable-next-line no-undef + const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); + const [global, url] = currentRequest.split('@'); + importDelegatedModule({ + global, + url: url + '?' + Date.now(), + }) + .then((remote) => { + resolve(remote); + }) + .catch((err) => reject(err)); +}); +//# sourceMappingURL=default-delegate.js.map + +/***/ }), + +/***/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js": +/*!*******************************************************************************************************************************!*\\ + !*** ../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js ***! + \\*******************************************************************************************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var __resourceQuery = "?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js"; + +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { + const { importDelegatedModule } = await __webpack_require__.e(/*! import() */ "dist_packages_utilities_src_utils_common_js").then(__webpack_require__.bind(__webpack_require__, /*! @module-federation/utilities/src/utils/common */ "../../dist/packages/utilities/src/utils/common.js")); + // eslint-disable-next-line no-undef + const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); + const [global, url] = currentRequest.split('@'); + importDelegatedModule({ + global, + url: url + '?' + Date.now(), + }) + .then((remote) => { + resolve(remote); + }) + .catch((err) => reject(err)); +}); +//# sourceMappingURL=default-delegate.js.map + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ id: moduleId, +/******/ loaded: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ var threw = true; +/******/ try { +/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ threw = false; +/******/ } finally { +/******/ if(threw) delete __webpack_module_cache__[moduleId]; +/******/ } +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = __webpack_modules__; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = __webpack_module_cache__; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/create fake namespace object */ +/******/ !function() { +/******/ var getProto = Object.getPrototypeOf ? function(obj) { return Object.getPrototypeOf(obj); } : function(obj) { return obj.__proto__; }; +/******/ var leafPrototypes; +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 16: return value when it's Promise-like +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = this(value); +/******/ if(mode & 8) return value; +/******/ if(typeof value === 'object' && value) { +/******/ if((mode & 4) && value.__esModule) return value; +/******/ if((mode & 16) && typeof value.then === 'function') return value; +/******/ } +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ var def = {}; +/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)]; +/******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) { +/******/ Object.getOwnPropertyNames(current).forEach(function(key) { def[key] = function() { return value[key]; }; }); +/******/ } +/******/ def['default'] = function() { return value; }; +/******/ __webpack_require__.d(ns, def); +/******/ return ns; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/ensure chunk */ +/******/ !function() { +/******/ __webpack_require__.f = {}; +/******/ // This file contains only the entry chunk. +/******/ // The chunk loading function for additional chunks +/******/ __webpack_require__.e = function(chunkId) { +/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) { +/******/ __webpack_require__.f[key](chunkId, promises); +/******/ return promises; +/******/ }, [])); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/get javascript chunk filename */ +/******/ !function() { +/******/ // This function allow to reference async chunks +/******/ __webpack_require__.u = function(chunkId) { +/******/ // return url for filenames based on template +/******/ return "" + chunkId + "." + {"dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_dist_packages_nextjs-mf_src_loaders_-50dce4":"b0222bcf399214ce","dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_v2_dist_packages_nextjs-mf_src_loade-8dd7f8":"6c51adaecae0ecd9","pages_dynamic-remote_js":"43dce907bc07a62a","pages_index_tsx":"eb32deceb20cf708","pages_checkout_slug_tsx":"9fc95859b513c47d","pages_checkout_pid_tsx":"fc6e1f39e1fb2b20","pages_checkout_exposed-pages_tsx":"c427553829547697","pages_checkout_index_tsx":"12ff80e79b855b50","pages_checkout_test-check-button_tsx":"27e47d9c82163286","pages_checkout_test-title_tsx":"e4f91667ab8b419b","pages_home_exposed-pages_tsx":"9fa1711f7f18a5ee","pages_home_test-broken-remotes_tsx":"9eaf7c44c79237ce","pages_home_test-remote-hook_tsx":"426f9a36561325aa","pages_home_test-shared-nav_tsx":"2ea34137c2dfcc10","pages_shop_exposed-pages_js":"851e41583cc25dca","pages_shop_index_js":"005f5c72caf7006f","pages_shop_test-webpack-png_js":"80f216354ec55c12","pages_shop_test-webpack-svg_js":"136a09b3439a339a","pages_shop_products_slug_js":"632d54759244a213","components_SharedNav_tsx":"a9e4f4646c622dac","components_menu_tsx":"29b60afaaf3c4268","node_modules_antd_lib_index_js":"f0aa773b434ca3a1","pages_dynamic-remote_js_hasBoundary":"4983b5f1d37e2ba3","pages_index_tsx_hasBoundary":"56b2a2cf727b3d26","pages_checkout_slug_tsx_hasBoundary":"1488473868a535ee","pages_checkout_pid_tsx_hasBoundary":"6331d4516d4aa25b","pages_checkout_exposed-pages_tsx_hasBoundary":"f1c1bc7ab0c51736","pages_checkout_index_tsx_hasBoundary":"e8b4f01146216368","pages_checkout_test-check-button_tsx_hasBoundary":"580130c93ab9590f","pages_checkout_test-title_tsx_hasBoundary":"bb66783ac7eb895e","pages_home_exposed-pages_tsx_hasBoundary":"dc4800efa068e571","pages_home_test-broken-remotes_tsx_hasBoundary":"5661d7ed4ba0684a","pages_home_test-remote-hook_tsx_hasBoundary":"1b395b00a9bb2836","pages_home_test-shared-nav_tsx_hasBoundary":"8d5c2fdb38ab31a6","pages_shop_exposed-pages_js_hasBoundary":"780473c61978dba3","pages_shop_index_js_hasBoundary":"8f28a0080e3651ab","pages_shop_test-webpack-png_js_hasBoundary":"3f6fe04a4908fe10","pages_shop_test-webpack-svg_js_hasBoundary":"2e3855b2bf359f58","pages_shop_products_slug_js_hasBoundary":"fac7e3dd6cbb66cb","webpack_container_remote_checkout_CheckoutTitle":"6568162a9bb34138","webpack_container_remote_checkout_ButtonOldAnt":"b7f1ea1ea9115221","webpack_container_remote_shop_WebpackSvg":"c3b32803d7ca349c","webpack_container_remote_shop_WebpackPng":"3c024093f0258f13","dist_packages_utilities_src_utils_common_js":"233f2235573ec801"}[chunkId] + ".js"; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ !function() { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/node module decorator */ +/******/ !function() { +/******/ __webpack_require__.nmd = function(module) { +/******/ module.paths = []; +/******/ if (!module.children) module.children = []; +/******/ return module; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/remotes loading */ +/******/ !function() { +/******/ var chunkMapping = { +/******/ "pages_checkout_slug_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/[...slug]" +/******/ ], +/******/ "pages_checkout_pid_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/[pid]" +/******/ ], +/******/ "pages_checkout_exposed-pages_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/exposed-pages" +/******/ ], +/******/ "pages_checkout_index_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/index" +/******/ ], +/******/ "pages_checkout_test-check-button_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/test-check-button" +/******/ ], +/******/ "pages_checkout_test-title_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/test-title" +/******/ ], +/******/ "pages_home_test-remote-hook_tsx_hasBoundary": [ +/******/ "webpack/container/remote/shop/useCustomRemoteHook" +/******/ ], +/******/ "pages_shop_exposed-pages_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/exposed-pages" +/******/ ], +/******/ "pages_shop_index_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/index" +/******/ ], +/******/ "pages_shop_test-webpack-png_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-png" +/******/ ], +/******/ "pages_shop_test-webpack-svg_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-svg" +/******/ ], +/******/ "pages_shop_products_slug_js_hasBoundary": [ +/******/ "webpack/container/remote/shop/pages/shop/products/[...slug]" +/******/ ], +/******/ "webpack_container_remote_checkout_CheckoutTitle": [ +/******/ "webpack/container/remote/checkout/CheckoutTitle" +/******/ ], +/******/ "webpack_container_remote_checkout_ButtonOldAnt": [ +/******/ "webpack/container/remote/checkout/ButtonOldAnt" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackSvg": [ +/******/ "webpack/container/remote/shop/WebpackSvg" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackPng": [ +/******/ "webpack/container/remote/shop/WebpackPng" +/******/ ] +/******/ }; +/******/ var idToExternalAndNameMapping = { +/******/ "webpack/container/remote/checkout/pages/checkout/[...slug]": [ +/******/ "default", +/******/ "./pages/checkout/[...slug]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/[pid]": [ +/******/ "default", +/******/ "./pages/checkout/[pid]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/exposed-pages": [ +/******/ "default", +/******/ "./pages/checkout/exposed-pages", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/index": [ +/******/ "default", +/******/ "./pages/checkout/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/test-check-button": [ +/******/ "default", +/******/ "./pages/checkout/test-check-button", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/pages/checkout/test-title": [ +/******/ "default", +/******/ "./pages/checkout/test-title", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/useCustomRemoteHook": [ +/******/ "default", +/******/ "./useCustomRemoteHook", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/exposed-pages": [ +/******/ "default", +/******/ "./pages/shop/exposed-pages", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/index": [ +/******/ "default", +/******/ "./pages/shop/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-png": [ +/******/ "default", +/******/ "./pages/shop/test-webpack-png", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/test-webpack-svg": [ +/******/ "default", +/******/ "./pages/shop/test-webpack-svg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/pages/shop/products/[...slug]": [ +/******/ "default", +/******/ "./pages/shop/products/[...slug]", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/CheckoutTitle": [ +/******/ "default", +/******/ "./CheckoutTitle", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/ButtonOldAnt": [ +/******/ "default", +/******/ "./ButtonOldAnt", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackSvg": [ +/******/ "default", +/******/ "./WebpackSvg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackPng": [ +/******/ "default", +/******/ "./WebpackPng", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ] +/******/ }; +/******/ __webpack_require__.f.remotes = function(chunkId, promises) { +/******/ if(__webpack_require__.o(chunkMapping, chunkId)) { +/******/ chunkMapping[chunkId].forEach(function(id) { +/******/ var getScope = __webpack_require__.R; +/******/ if(!getScope) getScope = []; +/******/ var data = idToExternalAndNameMapping[id]; +/******/ if(getScope.indexOf(data) >= 0) return; +/******/ getScope.push(data); +/******/ if(data.p) return promises.push(data.p); +/******/ var onError = function(error) { +/******/ if(!error) error = new Error("Container missing"); +/******/ if(typeof error.message === "string") +/******/ error.message += '\\nwhile loading "' + data[1] + '" from ' + data[2]; +/******/ __webpack_require__.m[id] = function() { +/******/ throw error; +/******/ } +/******/ data.p = 0; +/******/ }; +/******/ var handleFunction = function(fn, arg1, arg2, d, next, first) { +/******/ try { +/******/ var promise = fn(arg1, arg2); +/******/ if(promise && promise.then) { +/******/ var p = promise.then(function(result) { return next(result, d); }, onError); +/******/ if(first) promises.push(data.p = p); else return p; +/******/ } else { +/******/ return next(promise, d, first); +/******/ } +/******/ } catch(error) { +/******/ onError(error); +/******/ } +/******/ } +/******/ var onExternal = function(external, _, first) { return external ? handleFunction(__webpack_require__.I, data[0], 0, external, onInitialized, first) : onError(); }; +/******/ var onInitialized = function(_, external, first) { return handleFunction(external.get, data[1], getScope, 0, onFactory, first); }; +/******/ var onFactory = function(factory) { +/******/ data.p = 1; +/******/ __webpack_require__.m[id] = function(module) { +/******/ module.exports = factory(); +/******/ } +/******/ }; +/******/ handleFunction(__webpack_require__, data[2], 0, 0, onExternal, 1); +/******/ }); +/******/ } +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/sharing */ +/******/ !function() { +/******/ __webpack_require__.S = {}; +/******/ var initPromises = {}; +/******/ var initTokens = {}; +/******/ __webpack_require__.I = function(name, initScope) { +/******/ if(!initScope) initScope = []; +/******/ // handling circular init calls +/******/ var initToken = initTokens[name]; +/******/ if(!initToken) initToken = initTokens[name] = {}; +/******/ if(initScope.indexOf(initToken) >= 0) return; +/******/ initScope.push(initToken); +/******/ // only runs once +/******/ if(initPromises[name]) return initPromises[name]; +/******/ // creates a new share scope if needed +/******/ if(!__webpack_require__.o(__webpack_require__.S, name)) __webpack_require__.S[name] = {}; +/******/ // runs all init snippets from all modules reachable +/******/ var scope = __webpack_require__.S[name]; +/******/ var warn = function(msg) { return typeof console !== "undefined" && console.warn && console.warn(msg); }; +/******/ var uniqueName = "home_app"; +/******/ var register = function(name, version, factory, eager) { +/******/ var versions = scope[name] = scope[name] || {}; +/******/ var activeVersion = versions[version]; +/******/ if(!activeVersion || (!activeVersion.loaded && (!eager != !activeVersion.eager ? eager : uniqueName > activeVersion.from))) versions[version] = { get: factory, from: uniqueName, eager: !!eager }; +/******/ }; +/******/ var initExternal = function(id) { +/******/ var handleError = function(err) { warn("Initialization of sharing external failed: " + err); }; +/******/ try { +/******/ var module = __webpack_require__(id); +/******/ if(!module) return; +/******/ var initFn = function(module) { return module && module.init && module.init(__webpack_require__.S[name], initScope); } +/******/ if(module.then) return promises.push(module.then(initFn, handleError)); +/******/ var initResult = initFn(module); +/******/ if(initResult && initResult.then) return promises.push(initResult['catch'](handleError)); +/******/ } catch(err) { handleError(err); } +/******/ } +/******/ var promises = []; +/******/ switch(name) { +/******/ case "default": { +/******/ register("antd", "4.24.9", function() { return __webpack_require__.e("node_modules_antd_lib_index_js").then(function() { return function() { return __webpack_require__(/*! ../../node_modules/antd/lib/index.js */ "../../node_modules/antd/lib/index.js"); }; }); }); +/******/ initExternal("../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js"); +/******/ initExternal("../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js"); +/******/ } +/******/ break; +/******/ } +/******/ if(!promises.length) return initPromises[name] = 1; +/******/ return initPromises[name] = Promise.all(promises).then(function() { return initPromises[name] = 1; }); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/consumes */ +/******/ !function() { +/******/ var parseVersion = function(str) { +/******/ // see webpack/lib/util/semver.js for original code +/******/ var p=function(p){return p.split(".").map((function(p){return+p==p?+p:p}))},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r; +/******/ } +/******/ var versionLt = function(a, b) { +/******/ // see webpack/lib/util/semver.js for original code +/******/ a=parseVersion(a),b=parseVersion(b);for(var r=0;;){if(r>=a.length)return r=b.length)return"u"==n;var t=b[r],f=(typeof t)[0];if(n!=f)return"o"==n&&"n"==f||("s"==f||"u"==n);if("o"!=n&&"u"!=n&&e!=t)return e=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var e=1,a=1;a0?".":"")+(e=2,t)}return n}var g=[];for(a=1;a=version.length||"o"==(s=(typeof(f=version[n]))[0]))return!a||("u"==g?i>e&&!r:""==g!=r);if("u"==s){if(!a||"u"!=g)return!1}else if(a)if(g==s)if(i<=e){if(f!=range[i])return!1}else{if(r?f>range[i]:f { +/******/ e.target = {src: url}; +/******/ callback(e); +/******/ }); +/******/ } +/******/ executeLoad(url,callback,chunkId) +/******/ } +/******/ // ReadFile + VM.run chunk loading for javascript +/******/ __webpack_require__.f.readFileVm = function(chunkId, promises) { +/******/ +/******/ var installedChunkData = installedChunks[chunkId]; +/******/ if(installedChunkData !== 0) { // 0 means "already installed". +/******/ // array of [resolve, reject, promise] means "currently loading" +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ if(!/^webpack_container_remote_(checkout_(ButtonOldAnt|CheckoutTitle)|shop_Webpack(Pn|Sv)g)$/.test(chunkId)) { +/******/ // load the chunk and return promise to it +/******/ var promise = new Promise(async function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ var filename = require('path').join(__dirname, "" + __webpack_require__.u(chunkId)); +/******/ var fs = require('fs'); +/******/ if(fs.existsSync(filename)) { +/******/ fs.readFile(filename, 'utf-8', function(err, content) { +/******/ if(err) return reject(err); +/******/ var chunk = {}; +/******/ require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)(chunk, require, require('path').dirname(filename), filename); +/******/ installChunk(chunk); +/******/ }); +/******/ } else { +/******/ +/******/ function loadScript(url, cb, chunkID) { +/******/ if (global.webpackChunkLoad) { +/******/ global.webpackChunkLoad(url).then(function (resp) { +/******/ return resp.text(); +/******/ }).then(function (rawData) { +/******/ cb(null, rawData); +/******/ }).catch(function (err) { +/******/ console.error('Federated Chunk load failed', error); +/******/ return cb(error) +/******/ }); +/******/ } else { +/******/ //TODO https support +/******/ let request = (url.startsWith('https') ? require('https') : require('http')).get(url, function (resp) { +/******/ if (resp.statusCode === 200) { +/******/ let rawData = ''; +/******/ resp.setEncoding('utf8'); +/******/ resp.on('data', chunk => { +/******/ rawData += chunk; +/******/ }); +/******/ resp.on('end', () => { +/******/ cb(null, rawData); +/******/ }); +/******/ } else { +/******/ cb(resp); +/******/ } +/******/ }); +/******/ request.on('error', error => { +/******/ console.error('Federated Chunk load failed', error); +/******/ return cb(error) +/******/ }); +/******/ } +/******/ } +/******/ +/******/ +/******/ var remotes = {}; +/******/ Object.assign(global.__remote_scope__._config, remotes) +/******/ const remoteRegistry = global.__remote_scope__._config +/******/ +/******/ +/******/ +/******/ +/******/ +/******/ var requestedRemote = remoteRegistry["home_app"] +/******/ +/******/ if(typeof requestedRemote === 'function'){ +/******/ requestedRemote = await requestedRemote() +/******/ } +/******/ +/******/ var scriptUrl = new URL(requestedRemote); +/******/ +/******/ var chunkName = __webpack_require__.u(chunkId); +/******/ +/******/ var fileToReplace = require('path').basename(scriptUrl.pathname); +/******/ scriptUrl.pathname = scriptUrl.pathname.replace(fileToReplace, chunkName); +/******/ +/******/ loadScript(scriptUrl.toString(), function(err, content) { +/******/ +/******/ if(err) {console.error('error loading remote chunk', scriptUrl.toString(),'got',content,'with error', err); return reject(err);} +/******/ var chunk = {}; +/******/ try { +/******/ require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)(chunk, require, require('path').dirname(filename), filename); +/******/ } catch (e) { +/******/ console.error('runInThisContext threw', e) +/******/ } +/******/ installChunk(chunk); +/******/ }, chunkId); +/******/ } +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); +/******/ } else installedChunks[chunkId] = 0; +/******/ } +/******/ } +/******/ }; +/******/ +/******/ // no external install chunk +/******/ +/******/ // no HMR +/******/ +/******/ // no HMR manifest +/******/ }(); +/******/ +/************************************************************************/ +/******/ +/******/ // module cache are used so entry inlining is disabled +/******/ // startup +/******/ // Load entry module and return exports +/******/ var __webpack_exports__ = __webpack_require__("webpack/container/entry/home_app"); +/******/ module.exports.home_app = __webpack_exports__; +/******/ +/******/ })() +; +//# sourceMappingURL=remoteEntry.js.map" +`; + +exports[`Next.js build output server webpack-runtime 1`] = ` +"/******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "webpack/container/entry/home_app": +/*!***********************!*\\ + !*** container entry ***! + \\***********************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +var moduleMap = { + "./pages-map": function() { + return __webpack_require__.e("dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_dist_packages_nextjs-mf_src_loaders_-50dce4").then(function() { return function() { return (__webpack_require__(/*! ../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js */ "../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js")); }; }); + }, + "./pages-map-v2": function() { + return __webpack_require__.e("dist_packages_nextjs-mf_src_loaders_nextPageMapLoader_js_v2_dist_packages_nextjs-mf_src_loade-8dd7f8").then(function() { return function() { return (__webpack_require__(/*! ../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js?v2!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js */ "../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js?v2!../../dist/packages/nextjs-mf/src/loaders/nextPageMapLoader.js")); }; }); + }, + "./pages/dynamic-remote": function() { + return __webpack_require__.e("pages_dynamic-remote_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/dynamic-remote.js */ "./pages/dynamic-remote.js")); }; }); + }, + "./pages/index": function() { + return __webpack_require__.e("pages_index_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/index.tsx */ "./pages/index.tsx")); }; }); + }, + "./pages/checkout/[...slug]": function() { + return __webpack_require__.e("pages_checkout_slug_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/[...slug].tsx */ "./pages/checkout/[...slug].tsx")); }; }); + }, + "./pages/checkout/[pid]": function() { + return __webpack_require__.e("pages_checkout_pid_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/[pid].tsx */ "./pages/checkout/[pid].tsx")); }; }); + }, + "./pages/checkout/exposed-pages": function() { + return __webpack_require__.e("pages_checkout_exposed-pages_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/exposed-pages.tsx */ "./pages/checkout/exposed-pages.tsx")); }; }); + }, + "./pages/checkout/index": function() { + return __webpack_require__.e("pages_checkout_index_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/index.tsx */ "./pages/checkout/index.tsx")); }; }); + }, + "./pages/checkout/test-check-button": function() { + return __webpack_require__.e("pages_checkout_test-check-button_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/test-check-button.tsx */ "./pages/checkout/test-check-button.tsx")); }; }); + }, + "./pages/checkout/test-title": function() { + return __webpack_require__.e("pages_checkout_test-title_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/checkout/test-title.tsx */ "./pages/checkout/test-title.tsx")); }; }); + }, + "./pages/home/exposed-pages": function() { + return __webpack_require__.e("pages_home_exposed-pages_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/exposed-pages.tsx */ "./pages/home/exposed-pages.tsx")); }; }); + }, + "./pages/home/test-broken-remotes": function() { + return __webpack_require__.e("pages_home_test-broken-remotes_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-broken-remotes.tsx */ "./pages/home/test-broken-remotes.tsx")); }; }); + }, + "./pages/home/test-remote-hook": function() { + return __webpack_require__.e("pages_home_test-remote-hook_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-remote-hook.tsx */ "./pages/home/test-remote-hook.tsx")); }; }); + }, + "./pages/home/test-shared-nav": function() { + return __webpack_require__.e("pages_home_test-shared-nav_tsx").then(function() { return function() { return (__webpack_require__(/*! ./pages/home/test-shared-nav.tsx */ "./pages/home/test-shared-nav.tsx")); }; }); + }, + "./pages/shop/exposed-pages": function() { + return __webpack_require__.e("pages_shop_exposed-pages_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/exposed-pages.js */ "./pages/shop/exposed-pages.js")); }; }); + }, + "./pages/shop/index": function() { + return __webpack_require__.e("pages_shop_index_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/index.js */ "./pages/shop/index.js")); }; }); + }, + "./pages/shop/test-webpack-png": function() { + return __webpack_require__.e("pages_shop_test-webpack-png_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/test-webpack-png.js */ "./pages/shop/test-webpack-png.js")); }; }); + }, + "./pages/shop/test-webpack-svg": function() { + return __webpack_require__.e("pages_shop_test-webpack-svg_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/test-webpack-svg.js */ "./pages/shop/test-webpack-svg.js")); }; }); + }, + "./pages/shop/products/[...slug]": function() { + return __webpack_require__.e("pages_shop_products_slug_js").then(function() { return function() { return (__webpack_require__(/*! ./pages/shop/products/[...slug].js */ "./pages/shop/products/[...slug].js")); }; }); + }, + "./SharedNav": function() { + return __webpack_require__.e("components_SharedNav_tsx").then(function() { return function() { return (__webpack_require__(/*! ./components/SharedNav */ "./components/SharedNav.tsx")); }; }); + }, + "./menu": function() { + return __webpack_require__.e("components_menu_tsx").then(function() { return function() { return (__webpack_require__(/*! ./components/menu */ "./components/menu.tsx")); }; }); + } +}; +var get = function(module, getScope) { + __webpack_require__.R = getScope; + getScope = ( + __webpack_require__.o(moduleMap, module) + ? moduleMap[module]() + : Promise.resolve().then(function() { + throw new Error('Module "' + module + '" does not exist in container.'); + }) + ); + __webpack_require__.R = undefined; + return getScope; +}; +var init = function(shareScope, initScope) { + if (!__webpack_require__.S) return; + var name = "default" + var oldScope = __webpack_require__.S[name]; + if(oldScope && oldScope !== shareScope) throw new Error("Container initialization failed as it has already been initialized with a different share scope"); + __webpack_require__.S[name] = shareScope; + return __webpack_require__.I(name, initScope); +}; + +// This exports getters to disallow modifications +__webpack_require__.d(exports, { + get: function() { return get; }, + init: function() { return init; } +}); + +/***/ }), + +/***/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js": +/*!***********************************************************************************************************************************!*\\ + !*** ../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js ***! + \\***********************************************************************************************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var __resourceQuery = "?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js"; + +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { + const { importDelegatedModule } = await __webpack_require__.e(/*! import() */ "dist_packages_utilities_src_utils_common_js").then(__webpack_require__.bind(__webpack_require__, /*! @module-federation/utilities/src/utils/common */ "../../dist/packages/utilities/src/utils/common.js")); + // eslint-disable-next-line no-undef + const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); + const [global, url] = currentRequest.split('@'); + importDelegatedModule({ + global, + url: url + '?' + Date.now(), + }) + .then((remote) => { + resolve(remote); + }) + .catch((err) => reject(err)); +}); +//# sourceMappingURL=default-delegate.js.map + +/***/ }), + +/***/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js": +/*!*******************************************************************************************************************************!*\\ + !*** ../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js ***! + \\*******************************************************************************************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var __resourceQuery = "?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js"; + +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { + const { importDelegatedModule } = await __webpack_require__.e(/*! import() */ "dist_packages_utilities_src_utils_common_js").then(__webpack_require__.bind(__webpack_require__, /*! @module-federation/utilities/src/utils/common */ "../../dist/packages/utilities/src/utils/common.js")); + // eslint-disable-next-line no-undef + const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); + const [global, url] = currentRequest.split('@'); + importDelegatedModule({ + global, + url: url + '?' + Date.now(), + }) + .then((remote) => { + resolve(remote); + }) + .catch((err) => reject(err)); +}); +//# sourceMappingURL=default-delegate.js.map + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ id: moduleId, +/******/ loaded: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ var threw = true; +/******/ try { +/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ threw = false; +/******/ } finally { +/******/ if(threw) delete __webpack_module_cache__[moduleId]; +/******/ } +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = __webpack_modules__; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = __webpack_module_cache__; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/create fake namespace object */ +/******/ !function() { +/******/ var getProto = Object.getPrototypeOf ? function(obj) { return Object.getPrototypeOf(obj); } : function(obj) { return obj.__proto__; }; +/******/ var leafPrototypes; +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 16: return value when it's Promise-like +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = this(value); +/******/ if(mode & 8) return value; +/******/ if(typeof value === 'object' && value) { +/******/ if((mode & 4) && value.__esModule) return value; +/******/ if((mode & 16) && typeof value.then === 'function') return value; +/******/ } +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ var def = {}; +/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)]; +/******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) { +/******/ Object.getOwnPropertyNames(current).forEach(function(key) { def[key] = function() { return value[key]; }; }); +/******/ } +/******/ def['default'] = function() { return value; }; +/******/ __webpack_require__.d(ns, def); +/******/ return ns; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/ensure chunk */ +/******/ !function() { +/******/ __webpack_require__.f = {}; +/******/ // This file contains only the entry chunk. +/******/ // The chunk loading function for additional chunks +/******/ __webpack_require__.e = function(chunkId) { +/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) { +/******/ __webpack_require__.f[key](chunkId, promises); +/******/ return promises; +/******/ }, [])); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/get javascript chunk filename */ +/******/ !function() { +/******/ // This function allow to reference async chunks and sibling chunks for the entrypoint +/******/ __webpack_require__.u = function(chunkId) { +/******/ // return url for filenames based on template +/******/ return "" + chunkId + "." + {"node_modules_antd_lib_index_js":"f0aa773b434ca3a1","pages__app_tsx_hasBoundary":"0217cba3fea8fd66","dist_packages_utilities_src_utils_common_js":"233f2235573ec801","pages_index_tsx_hasBoundary":"56b2a2cf727b3d26","pages_checkout_index_tsx_hasBoundary":"e8b4f01146216368","pages_home_test-remote-hook_tsx_hasBoundary":"1b395b00a9bb2836","pages_home_test-broken-remotes_tsx_hasBoundary":"5661d7ed4ba0684a","webpack_container_remote_shop_menu":"e46d262796465990","webpack_container_remote_checkout_menu":"68ddd540c9d2f002","webpack_container_remote_checkout_CheckoutTitle":"6568162a9bb34138","webpack_container_remote_checkout_ButtonOldAnt":"b7f1ea1ea9115221","webpack_container_remote_shop_WebpackSvg":"c3b32803d7ca349c","webpack_container_remote_shop_WebpackPng":"3c024093f0258f13"}[chunkId] + ".js"; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ !function() { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/node module decorator */ +/******/ !function() { +/******/ __webpack_require__.nmd = function(module) { +/******/ module.paths = []; +/******/ if (!module.children) module.children = []; +/******/ return module; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/remotes loading */ +/******/ !function() { +/******/ var chunkMapping = { +/******/ "pages_checkout_index_tsx_hasBoundary": [ +/******/ "webpack/container/remote/checkout/pages/checkout/index" +/******/ ], +/******/ "pages_home_test-remote-hook_tsx_hasBoundary": [ +/******/ "webpack/container/remote/shop/useCustomRemoteHook" +/******/ ], +/******/ "webpack_container_remote_shop_menu": [ +/******/ "webpack/container/remote/shop/menu" +/******/ ], +/******/ "webpack_container_remote_checkout_menu": [ +/******/ "webpack/container/remote/checkout/menu" +/******/ ], +/******/ "webpack_container_remote_checkout_CheckoutTitle": [ +/******/ "webpack/container/remote/checkout/CheckoutTitle" +/******/ ], +/******/ "webpack_container_remote_checkout_ButtonOldAnt": [ +/******/ "webpack/container/remote/checkout/ButtonOldAnt" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackSvg": [ +/******/ "webpack/container/remote/shop/WebpackSvg" +/******/ ], +/******/ "webpack_container_remote_shop_WebpackPng": [ +/******/ "webpack/container/remote/shop/WebpackPng" +/******/ ] +/******/ }; +/******/ var idToExternalAndNameMapping = { +/******/ "webpack/container/remote/checkout/pages/checkout/index": [ +/******/ "default", +/******/ "./pages/checkout/index", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/useCustomRemoteHook": [ +/******/ "default", +/******/ "./useCustomRemoteHook", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/menu": [ +/******/ "default", +/******/ "./menu", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/menu": [ +/******/ "default", +/******/ "./menu", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/CheckoutTitle": [ +/******/ "default", +/******/ "./CheckoutTitle", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/checkout/ButtonOldAnt": [ +/******/ "default", +/******/ "./ButtonOldAnt", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackSvg": [ +/******/ "default", +/******/ "./WebpackSvg", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ], +/******/ "webpack/container/remote/shop/WebpackPng": [ +/******/ "default", +/******/ "./WebpackPng", +/******/ "../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js" +/******/ ] +/******/ }; +/******/ __webpack_require__.f.remotes = function(chunkId, promises) { +/******/ if(__webpack_require__.o(chunkMapping, chunkId)) { +/******/ chunkMapping[chunkId].forEach(function(id) { +/******/ var getScope = __webpack_require__.R; +/******/ if(!getScope) getScope = []; +/******/ var data = idToExternalAndNameMapping[id]; +/******/ if(getScope.indexOf(data) >= 0) return; +/******/ getScope.push(data); +/******/ if(data.p) return promises.push(data.p); +/******/ var onError = function(error) { +/******/ if(!error) error = new Error("Container missing"); +/******/ if(typeof error.message === "string") +/******/ error.message += '\\nwhile loading "' + data[1] + '" from ' + data[2]; +/******/ __webpack_require__.m[id] = function() { +/******/ throw error; +/******/ } +/******/ data.p = 0; +/******/ }; +/******/ var handleFunction = function(fn, arg1, arg2, d, next, first) { +/******/ try { +/******/ var promise = fn(arg1, arg2); +/******/ if(promise && promise.then) { +/******/ var p = promise.then(function(result) { return next(result, d); }, onError); +/******/ if(first) promises.push(data.p = p); else return p; +/******/ } else { +/******/ return next(promise, d, first); +/******/ } +/******/ } catch(error) { +/******/ onError(error); +/******/ } +/******/ } +/******/ var onExternal = function(external, _, first) { return external ? handleFunction(__webpack_require__.I, data[0], 0, external, onInitialized, first) : onError(); }; +/******/ var onInitialized = function(_, external, first) { return handleFunction(external.get, data[1], getScope, 0, onFactory, first); }; +/******/ var onFactory = function(factory) { +/******/ data.p = 1; +/******/ __webpack_require__.m[id] = function(module) { +/******/ module.exports = factory(); +/******/ } +/******/ }; +/******/ handleFunction(__webpack_require__, data[2], 0, 0, onExternal, 1); +/******/ }); +/******/ } +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/runtimeId */ +/******/ !function() { +/******/ __webpack_require__.j = "webpack-runtime"; +/******/ }(); +/******/ +/******/ /* webpack/runtime/sharing */ +/******/ !function() { +/******/ __webpack_require__.S = {}; +/******/ var initPromises = {}; +/******/ var initTokens = {}; +/******/ __webpack_require__.I = function(name, initScope) { +/******/ if(!initScope) initScope = []; +/******/ // handling circular init calls +/******/ var initToken = initTokens[name]; +/******/ if(!initToken) initToken = initTokens[name] = {}; +/******/ if(initScope.indexOf(initToken) >= 0) return; +/******/ initScope.push(initToken); +/******/ // only runs once +/******/ if(initPromises[name]) return initPromises[name]; +/******/ // creates a new share scope if needed +/******/ if(!__webpack_require__.o(__webpack_require__.S, name)) __webpack_require__.S[name] = {}; +/******/ // runs all init snippets from all modules reachable +/******/ var scope = __webpack_require__.S[name]; +/******/ var warn = function(msg) { return typeof console !== "undefined" && console.warn && console.warn(msg); }; +/******/ var uniqueName = "home_app"; +/******/ var register = function(name, version, factory, eager) { +/******/ var versions = scope[name] = scope[name] || {}; +/******/ var activeVersion = versions[version]; +/******/ if(!activeVersion || (!activeVersion.loaded && (!eager != !activeVersion.eager ? eager : uniqueName > activeVersion.from))) versions[version] = { get: factory, from: uniqueName, eager: !!eager }; +/******/ }; +/******/ var initExternal = function(id) { +/******/ var handleError = function(err) { warn("Initialization of sharing external failed: " + err); }; +/******/ try { +/******/ var module = __webpack_require__(id); +/******/ if(!module) return; +/******/ var initFn = function(module) { return module && module.init && module.init(__webpack_require__.S[name], initScope); } +/******/ if(module.then) return promises.push(module.then(initFn, handleError)); +/******/ var initResult = initFn(module); +/******/ if(initResult && initResult.then) return promises.push(initResult['catch'](handleError)); +/******/ } catch(err) { handleError(err); } +/******/ } +/******/ var promises = []; +/******/ switch(name) { +/******/ case "default": { +/******/ register("antd", "4.24.9", function() { return __webpack_require__.e("node_modules_antd_lib_index_js").then(function() { return function() { return __webpack_require__(/*! ../../node_modules/antd/lib/index.js */ "../../node_modules/antd/lib/index.js"); }; }); }); +/******/ initExternal("../../dist/packages/nextjs-mf/src/default-delegate.js?remote=checkout@http://localhost:3002/_next/static/ssr/remoteEntry.js"); +/******/ initExternal("../../dist/packages/nextjs-mf/src/default-delegate.js?remote=shop@http://localhost:3001/_next/static/ssr/remoteEntry.js"); +/******/ } +/******/ break; +/******/ } +/******/ if(!promises.length) return initPromises[name] = 1; +/******/ return initPromises[name] = Promise.all(promises).then(function() { return initPromises[name] = 1; }); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/startup entrypoint */ +/******/ !function() { +/******/ __webpack_require__.X = function(result, chunkIds, fn) { +/******/ var moduleId = chunkIds; +/******/ if(!fn) chunkIds = result, fn = function() { return __webpack_require__(__webpack_require__.s = moduleId); }; +/******/ return Promise.all(chunkIds.map(__webpack_require__.e, __webpack_require__)).then(function() { +/******/ var r = fn(); +/******/ return r === undefined ? result : r; +/******/ }) +/******/ } +/******/ }(); +/******/ +/******/ /* webpack/runtime/consumes */ +/******/ !function() { +/******/ var parseVersion = function(str) { +/******/ // see webpack/lib/util/semver.js for original code +/******/ var p=function(p){return p.split(".").map((function(p){return+p==p?+p:p}))},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r; +/******/ } +/******/ var versionLt = function(a, b) { +/******/ // see webpack/lib/util/semver.js for original code +/******/ a=parseVersion(a),b=parseVersion(b);for(var r=0;;){if(r>=a.length)return r=b.length)return"u"==n;var t=b[r],f=(typeof t)[0];if(n!=f)return"o"==n&&"n"==f||("s"==f||"u"==n);if("o"!=n&&"u"!=n&&e!=t)return e=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var e=1,a=1;a0?".":"")+(e=2,t)}return n}var g=[];for(a=1;a=version.length||"o"==(s=(typeof(f=version[n]))[0]))return!a||("u"==g?i>e&&!r:""==g!=r);if("u"==s){if(!a||"u"!=g)return!1}else if(a)if(g==s)if(i<=e){if(f!=range[i])return!1}else{if(r?f>range[i]:f { +/******/ e.target = {src: url}; +/******/ callback(e); +/******/ }); +/******/ } +/******/ executeLoad(url,callback,chunkId) +/******/ } +/******/ // ReadFile + VM.run chunk loading for javascript +/******/ __webpack_require__.f.readFileVm = function(chunkId, promises) { +/******/ +/******/ var installedChunkData = installedChunks[chunkId]; +/******/ if(installedChunkData !== 0) { // 0 means "already installed". +/******/ // array of [resolve, reject, promise] means "currently loading" +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ if(!/^webpack_container_remote_(checkout_(ButtonOldAnt|CheckoutTitle|menu)|shop_(Webpack(Pn|Sv)g|menu))$/.test(chunkId)) { +/******/ // load the chunk and return promise to it +/******/ var promise = new Promise(async function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ var filename = require('path').join(__dirname, "" + __webpack_require__.u(chunkId)); +/******/ var fs = require('fs'); +/******/ if(fs.existsSync(filename)) { +/******/ fs.readFile(filename, 'utf-8', function(err, content) { +/******/ if(err) return reject(err); +/******/ var chunk = {}; +/******/ require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)(chunk, require, require('path').dirname(filename), filename); +/******/ installChunk(chunk); +/******/ }); +/******/ } else { +/******/ +/******/ function loadScript(url, cb, chunkID) { +/******/ if (global.webpackChunkLoad) { +/******/ global.webpackChunkLoad(url).then(function (resp) { +/******/ return resp.text(); +/******/ }).then(function (rawData) { +/******/ cb(null, rawData); +/******/ }).catch(function (err) { +/******/ console.error('Federated Chunk load failed', error); +/******/ return cb(error) +/******/ }); +/******/ } else { +/******/ //TODO https support +/******/ let request = (url.startsWith('https') ? require('https') : require('http')).get(url, function (resp) { +/******/ if (resp.statusCode === 200) { +/******/ let rawData = ''; +/******/ resp.setEncoding('utf8'); +/******/ resp.on('data', chunk => { +/******/ rawData += chunk; +/******/ }); +/******/ resp.on('end', () => { +/******/ cb(null, rawData); +/******/ }); +/******/ } else { +/******/ cb(resp); +/******/ } +/******/ }); +/******/ request.on('error', error => { +/******/ console.error('Federated Chunk load failed', error); +/******/ return cb(error) +/******/ }); +/******/ } +/******/ } +/******/ +/******/ +/******/ var remotes = {}; +/******/ Object.assign(global.__remote_scope__._config, remotes) +/******/ const remoteRegistry = global.__remote_scope__._config +/******/ +/******/ +/******/ +/******/ +/******/ +/******/ var requestedRemote = remoteRegistry["home_app"] +/******/ +/******/ if(typeof requestedRemote === 'function'){ +/******/ requestedRemote = await requestedRemote() +/******/ } +/******/ +/******/ var scriptUrl = new URL(requestedRemote); +/******/ +/******/ var chunkName = __webpack_require__.u(chunkId); +/******/ +/******/ var fileToReplace = require('path').basename(scriptUrl.pathname); +/******/ scriptUrl.pathname = scriptUrl.pathname.replace(fileToReplace, chunkName); +/******/ +/******/ loadScript(scriptUrl.toString(), function(err, content) { +/******/ +/******/ if(err) {console.error('error loading remote chunk', scriptUrl.toString(),'got',content,'with error', err); return reject(err);} +/******/ var chunk = {}; +/******/ try { +/******/ require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)(chunk, require, require('path').dirname(filename), filename); +/******/ } catch (e) { +/******/ console.error('runInThisContext threw', e) +/******/ } +/******/ installChunk(chunk); +/******/ }, chunkId); +/******/ } +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); +/******/ } else installedChunks[chunkId] = 0; +/******/ } +/******/ } +/******/ }; +/******/ +/******/ module.exports = __webpack_require__; +/******/ __webpack_require__.C = installChunk; +/******/ +/******/ // no HMR +/******/ +/******/ // no HMR manifest +/******/ }(); +/******/ +/************************************************************************/ +/******/ +/******/ // module factories are used so entry inlining is disabled +/******/ +/******/ })() +; +//# sourceMappingURL=webpack-runtime.js.map" +`; diff --git a/packages/nextjs-mf/chunk-intergration.test.ts b/packages/nextjs-mf/chunk-intergration.test.ts new file mode 100644 index 00000000000..de82584c297 --- /dev/null +++ b/packages/nextjs-mf/chunk-intergration.test.ts @@ -0,0 +1,155 @@ +// __tests__/build.test.ts +import { execSync } from 'child_process'; +import * as fs from 'fs'; +import * as path from 'path'; + +xdescribe('Next.js build output', () => { + beforeAll(() => { + // Run the build programmatically + // console.log('buildOutputDir', buildOutputDir); + // execSync('nx build', { stdio: 'inherit', cwd: '../../' }); + //execSync("cd " + JSON.stringify(__dirname) +'; yarn build', { stdio: 'inherit', cwd: __dirname }); + }); + afterEach(() => { + if (global.self) { + //@ts-ignore + delete global.self.webpackChunkhome_app; + } + }); + describe('client', () => { + const buildOutputDir = path.join( + __dirname, + '../../', + 'dist/apps/3000-home/.next/static/chunks' + ); + it('remoteEntry.js', () => { + const buildOutput = findFileInDirectory('remoteEntry', buildOutputDir); + expect(buildOutput).toMatchSnapshot(); + }); + it('partial remote', () => { + const buildOutput = findFileInDirectory('home_app', buildOutputDir); + expect(buildOutput).toMatchSnapshot(); + }); + it('webpack-runtime', () => { + const buildOutput = findFileInDirectory('webpack', buildOutputDir); + expect(buildOutput).toMatchSnapshot(); + }); + describe('modules', () => { + it('main chunk should have react', () => { + const buildOutput = findModulesInChunk('main', buildOutputDir); + const hasReact = buildOutput?.some((module) => + module.includes('node_modules/react/') + ); + expect(hasReact).toBe(true); + }); + it('main chunk should have delegate hoist', () => { + const buildOutput = findModulesInChunk('main', buildOutputDir); + const hasReact = buildOutput?.some((module) => + module.includes('internal-delegate-hoist') + ); + expect(hasReact).toBe(true); + }); + + it('main chunk should have styled-jsx', () => { + const buildOutput = findModulesInChunk('main', buildOutputDir); + const hasReact = buildOutput?.some((module) => + module.includes('node_modules/styled-jsx/') + ); + expect(hasReact).toBe(true); + }); + it('main chunk should NOT have delegate modules', () => { + const buildOutput = findModulesInChunk('main', buildOutputDir); + const hasReact = buildOutput?.some((module) => + module.includes('remote=') + ); + expect(hasReact).toBe(false); + }); + + it('main chunk', () => { + const buildOutput = findModulesInChunk('main', buildOutputDir); + expect(buildOutput).toMatchSnapshot(); + }); + }); + }); + describe('server', () => { + const buildOutputDir = path.join( + __dirname, + '../../', + 'dist/apps/3000-home/.next/server' + ); + it('remoteEntry.js', () => { + const buildOutput = findFileInDirectory('remoteEntry', buildOutputDir); + expect(buildOutput).toMatchSnapshot(); + }); + xit('partial remote', () => { + const buildOutput = findFileInDirectory('home_app', buildOutputDir); + expect(buildOutput).toMatchSnapshot(); + }); + it('webpack-runtime', () => { + const buildOutput = findFileInDirectory('webpack-', buildOutputDir); + expect(buildOutput).toMatchSnapshot(); + }); + describe('modules', () => { + xit('page partial doesnt contain react', () => { + const buildOutput = findModulesInChunk('pages_', buildOutputDir); + const hasReact = buildOutput?.some( + (module) => + module.includes('node_modules/react/') || module === 'react' + ); + expect(hasReact).toBe(false); + }); + + xit('main chunk', () => { + const buildOutput = findModulesInChunk('main-', buildOutputDir); + expect(buildOutput).toMatchSnapshot(); + }); + + it('doesnt have shared modules in main chunks', () => { + // @ant-design + const buildOutput = findModulesInChunk('pages__app', buildOutputDir); + const hasReact = buildOutput?.some( + (module) => module.includes('/@ant-design/') || module === 'react' + ); + expect(hasReact).toBe(false); + }); + }); + }); +}); + +function findFileInDirectory( + filename: string, + directory: string +): string | null { + const files = fs.readdirSync(directory); + for (const file of files) { + const filePath = path.join(directory, file); + const fileStat = fs.statSync(filePath); + if (fileStat.isDirectory()) { + const result = findFileInDirectory(filename, filePath); + if (result) { + return result; + } + } else if (file.startsWith(filename) && file.endsWith('.js')) { + return fs.readFileSync(filePath, 'utf-8'); + } + } + return null; +} + +function findModulesInChunk(filename: string, directory: string) { + //@ts-ignore + global.self = { webpackChunkhome_app: [] }; + const chunk = findFileInDirectory(filename, directory); + if (chunk) { + const evaledChunk = eval(chunk); + if (typeof evaledChunk === 'object') { + return Object.keys(evaledChunk); + } + console.log(evaledChunk); + //@ts-ignore + const moduleMaps = globalThis.self['webpackChunkhome_app'][0][1]; + + return Object.keys(moduleMaps); + } + return null; +} diff --git a/packages/nextjs-mf/jest.config.js b/packages/nextjs-mf/jest.config.js index a49f2fde903..a2da2ba1a3e 100644 --- a/packages/nextjs-mf/jest.config.js +++ b/packages/nextjs-mf/jest.config.js @@ -1,6 +1,6 @@ /* eslint-disable */ module.exports = { - displayName: 'nextjs-mf-js', + displayName: 'nextjs-mf', preset: '../../jest.preset.js', globals: {}, testEnvironment: 'node', @@ -13,5 +13,5 @@ module.exports = { ], }, moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/packages/nextjs-mf-js', + coverageDirectory: '../../coverage/packages/nextjs-mf', }; diff --git a/packages/nextjs-mf/package.json b/packages/nextjs-mf/package.json index 8ad709aa764..033c17cbf5f 100644 --- a/packages/nextjs-mf/package.json +++ b/packages/nextjs-mf/package.json @@ -1,6 +1,6 @@ { "name": "@module-federation/nextjs-mf", - "version": "6.7.1", + "version": "6.7.2-rc.1", "license": "MIT", "main": "src/index.js", "types": "src/index.d.ts", diff --git a/packages/nextjs-mf/src/default-delegate.ts b/packages/nextjs-mf/src/default-delegate.ts new file mode 100644 index 00000000000..d1a5d9d5f47 --- /dev/null +++ b/packages/nextjs-mf/src/default-delegate.ts @@ -0,0 +1,22 @@ +// eslint-disable-next-line no-async-promise-executor +module.exports = new Promise(async (resolve, reject) => { + // @ts-ignore + const { importDelegatedModule } = await import( + // @ts-ignore + '@module-federation/utilities/src/utils/importDelegatedModule' + ); + // eslint-disable-next-line no-undef + const currentRequest = new URLSearchParams(__resourceQuery).get('remote'); + // @ts-ignore + const [global, url] = currentRequest.split('@'); + importDelegatedModule({ + global, + url: url + '?' + Date.now(), + }) + // @ts-ignore + .then((remote) => { + resolve(remote); + }) + // @ts-ignore + .catch((err) => reject(err)); +}); diff --git a/packages/nextjs-mf/src/delegate-hoist-container.ts b/packages/nextjs-mf/src/delegate-hoist-container.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/nextjs-mf/src/federation-noop.ts b/packages/nextjs-mf/src/federation-noop.ts new file mode 100644 index 00000000000..f053ebf7976 --- /dev/null +++ b/packages/nextjs-mf/src/federation-noop.ts @@ -0,0 +1 @@ +module.exports = {}; diff --git a/packages/nextjs-mf/src/include-defaults.ts b/packages/nextjs-mf/src/include-defaults.ts deleted file mode 100644 index 15387bdf488..00000000000 --- a/packages/nextjs-mf/src/include-defaults.ts +++ /dev/null @@ -1,17 +0,0 @@ -"use client" -// this is needed to ensure webpack does not attempt to tree shake unused modules. Since these should always come from host -require('react'); -require('react-dom'); -require('next/link'); -require('next/router'); -require('next/head'); -require('next/script'); -require('next/dynamic'); -require('styled-jsx'); -require('styled-jsx/style'); - -if (process.env['NODE_ENV'] === 'development') { - require('react/jsx-dev-runtime'); -} - -module.exports = {}; diff --git a/packages/nextjs-mf/src/index.ts b/packages/nextjs-mf/src/index.ts index e280efc3bfc..bb88a042f02 100644 --- a/packages/nextjs-mf/src/index.ts +++ b/packages/nextjs-mf/src/index.ts @@ -1,4 +1,4 @@ -import { NextFederationPlugin } from './plugins/NextFederationPlugin'; +import NextFederationPlugin from "./plugins/NextFederationPlugin"; export { NextFederationPlugin }; export default NextFederationPlugin; diff --git a/packages/nextjs-mf/src/internal-delegate-hoist.ts b/packages/nextjs-mf/src/internal-delegate-hoist.ts index 00d78bd6012..3ab4b3df602 100644 --- a/packages/nextjs-mf/src/internal-delegate-hoist.ts +++ b/packages/nextjs-mf/src/internal-delegate-hoist.ts @@ -1 +1,2 @@ // placeholder file for delegate module injection +// placeholder for module hoist injection, precursor to startup inversion diff --git a/packages/nextjs-mf/src/internal.ts b/packages/nextjs-mf/src/internal.ts index f1fe7715388..225cd878622 100644 --- a/packages/nextjs-mf/src/internal.ts +++ b/packages/nextjs-mf/src/internal.ts @@ -1,318 +1,186 @@ -import type { Compiler } from 'webpack'; import type { ModuleFederationPluginOptions, - Shared, SharedConfig, SharedObject, } from '@module-federation/utilities'; - -import path from 'path'; +import { createDelegatedModule } from '@module-federation/utilities'; import { isRequiredVersion } from 'webpack/lib/sharing/utils'; import { parseOptions } from 'webpack/lib/container/options'; -import { - extractUrlAndGlobal, - createDelegatedModule, -} from '@module-federation/utilities'; - -// the share scope we attach by default -// in hosts we re-key them to prevent webpack moving the modules into their own chunks (cause eager error) -// in remote these are marked as import:false as we always expect the host to prove them +/** + * @typedef SharedObject + * @type {object} + * @property {object} [key] - The key representing the shared object's package name. + * @property {boolean} key.singleton - Whether the shared object should be a singleton. + * @property {boolean} key.requiredVersion - Whether a specific version of the shared object is required. + * @property {boolean} key.eager - Whether the shared object should be eagerly loaded. + * @property {boolean} key.import - Whether the shared object should be imported or not. + */ export const DEFAULT_SHARE_SCOPE: SharedObject = { - react: { - singleton: true, + 'next/dynamic': { + eager: false, requiredVersion: false, - }, - 'react/jsx-runtime': { singleton: true, - requiredVersion: false, + import: undefined, }, - 'react/jsx-dev-runtime': { - singleton: true, + 'next/head': { + eager: false, requiredVersion: false, - }, - 'react-dom': { singleton: true, - requiredVersion: false, + import: undefined, }, - 'next/dynamic': { + 'next/link': { + eager: true, requiredVersion: false, singleton: true, + import: undefined, }, - 'styled-jsx': { + 'next/router': { requiredVersion: false, singleton: true, + import: false, + eager: false, }, - 'styled-jsx/style': { + 'next/script': { requiredVersion: false, singleton: true, + import: undefined, + eager: false, }, - 'next/link': { + react: { + singleton: true, requiredVersion: false, + eager: false, + import: false, + }, + 'react-dom': { singleton: true, + requiredVersion: false, + eager: false, + import: false, }, - 'next/router': { + 'react/jsx-dev-runtime': { + singleton: true, requiredVersion: false, + import: undefined, + eager: false, + }, + 'react/jsx-runtime': { singleton: true, + requiredVersion: false, + eager: false, + import: false, }, - 'next/script': { + 'styled-jsx': { requiredVersion: false, singleton: true, + import: undefined, + eager: false, }, - 'next/head': { + 'styled-jsx/style': { requiredVersion: false, singleton: true, + import: undefined, + eager: false, }, }; -// put host in-front of any shared module key, so "hostreact" -export const reKeyHostShared = ( - options: Shared = {} -): Record => { - const shared = { - // ...options, causes multiple copies of a package to be loaded into a graph, dangerous for singletons - ...DEFAULT_SHARE_SCOPE, - } as Record; - - const reKeyedInternalModules = Object.entries(shared).reduce((acc, item) => { - const [itemKey, shareOptions] = item; - - const shareKey = `host${(item as any).shareKey || itemKey}`; - acc[shareKey] = shareOptions; - - if (!shareOptions.import) { - acc[shareKey].import = itemKey; - } - - if (!shareOptions.shareKey) { - acc[shareKey].shareKey = itemKey; - } - - if (DEFAULT_SHARE_SCOPE[itemKey]) { - acc[shareKey].packageName = itemKey; - } - - return acc; - }, {} as Record); - - return { - ...options, // pass through undoctored shared modules from the user config - ...reKeyedInternalModules, - } as Record; -}; - -// browser template to convert remote into promise new promise and use require.loadChunk to load the chunk -export const generateRemoteTemplate = ( - url: string, - global: any -) => `new Promise(function (resolve, reject) { - var url = new URL(${JSON.stringify(url)}); - url.searchParams.set('t', Date.now()); - var __webpack_error__ = new Error(); - if(!window.remoteLoading) { - window.remoteLoading = {}; - }; - - if(window.remoteLoading[${JSON.stringify(global)}]) { - return resolve(window.remoteLoading[${JSON.stringify(global)}]) - } +/** + * A default share scope for the browser environment. + * It takes the DEFAULT_SHARE_SCOPE and sets eager to true for all entries. + * The module hoisting system relocates these modules into the right runtime and out of the remote + * + * @type {SharedObject} + */ - var res, rej; - window.remoteLoading[${JSON.stringify( - global - )}] = new Promise(function(rs,rj){ - res = rs; - rej = rj; - }) - - if (typeof window[${JSON.stringify(global)}] !== 'undefined') { - res(window[${JSON.stringify(global)}]); - return resolve(window[${JSON.stringify(global)}]); - } - - __webpack_require__.l( - url.href, - function (event) { - if (typeof window[${JSON.stringify(global)}] !== 'undefined') { - res(window[${JSON.stringify(global)}]); - return resolve(window[${JSON.stringify(global)}]); - } - var errorType = event && (event.type === 'load' ? 'missing' : event.type); - var realSrc = event && event.target && event.target.src; - __webpack_error__.message = - 'Loading script failed.\\n(' + errorType + ': ' + realSrc + ')'; - __webpack_error__.name = 'ScriptExternalLoadError'; - __webpack_error__.type = errorType; - __webpack_error__.request = realSrc; - rej(__webpack_error__); - reject(__webpack_error__); - }, - ${JSON.stringify(global)} - ); - }).then(function () { - const proxy = { - get: ${global}.get, - init: function(shareScope, initToken) { - - const handler = { - get(target, prop) { - if (target[prop]) { - Object.values(target[prop]).forEach(function(o) { - if(o.from === '_N_E') { - o.loaded = 1 - } - }) - } - return target[prop] - }, - set(target, property, value, receiver) { - if (target[property]) { - return target[property] - } - target[property] = value - return true - } - } - try { - ${global}.init(new Proxy(shareScope, handler), initToken) - } catch (e) { - - } - ${global}.__initialized = true - } - } - if (!${global}.__initialized) { - proxy.init(__webpack_require__.S.default) - } - return proxy - })`; - -// shared packages must be compiled into webpack bundle, not require() pass through -export const internalizeSharedPackages = ( - options: ModuleFederationPluginOptions, - compiler: Compiler -) => { - //TODO: should use this util for other areas where we read MF options from userland - if (!options.shared) { - return; - } - const sharedOptions = parseShareOptions(options); - // get share keys from user, filter out ones that need to be external - const internalizableKeys = Object.keys(sharedOptions).filter((key) => { - if (!DEFAULT_SHARE_SCOPE[key]) { - return true; - } - - const index = sharedOptions[key].import; - - if (index && !DEFAULT_SHARE_SCOPE[index]) { - return true; - } - - return false; - }); - - if (Array.isArray(compiler.options.externals)) { - // take original externals regex - const backupExternals = compiler.options.externals[0]; - // if externals is a function (like when you're not running in serverless mode or creating a single build) - if (typeof backupExternals === 'function') { - // replace externals function with short-circuit, or fall back to original algo - compiler.options.externals[0] = (mod, callback) => { - if (!internalizableKeys.some((v) => mod.request?.includes(v))) { - return backupExternals(mod, callback); - } - // bundle it - return Promise.resolve(); - }; - } - } -}; - -export const externalizedShares: SharedObject = Object.entries( +export const DEFAULT_SHARE_SCOPE_BROWSER: SharedObject = Object.entries( DEFAULT_SHARE_SCOPE ).reduce((acc, item) => { const [key, value] = item as [string, SharedConfig]; - acc[key] = { ...value, import: false }; + acc[key] = { ...value, eager: undefined, import: undefined }; - if (key === 'react/jsx-runtime') { - delete (acc[key] as SharedConfig).import; + if ( + key === 'react' || + key === 'react-dom' || + key === 'next/router' || + key === 'next/link' + ) { + //@ts-ignore + acc[key].eager = true; } - return acc; }, {} as SharedObject); - -// determine output base path, derives .next folder location -export const getOutputPath = (compiler: Compiler) => { - const isServer = compiler.options.target !== 'client'; - let outputPath: string | string[] | undefined = - compiler.options.output.path?.split(path.sep); - - const foundIndex = outputPath?.lastIndexOf(isServer ? 'server' : 'static'); - - outputPath = outputPath - ?.slice(0, foundIndex && foundIndex > 0 ? foundIndex : outputPath.length) - .join(path.sep); - - return outputPath as string; +/** + * Checks if the remote value is an internal or promise delegate module reference. + * + * @param {string} value - The remote value to check. + * @returns {boolean} - True if the value is an internal or promise delegate module reference, false otherwise. + */ +const isInternalOrPromise = (value: string): boolean => { + return value.startsWith('internal ') || value.startsWith('promise '); }; -export const removePlugins = [ - 'NextJsRequireCacheHotReloader', - 'BuildManifestPlugin', - 'WellKnownErrorsPlugin', - 'WebpackBuildEventsPlugin', - 'HotModuleReplacementPlugin', - 'NextMiniCssExtractPlugin', - 'NextFederationPlugin', - 'CopyFilePlugin', - 'ProfilingPlugin', - 'DropClientPage', - 'ReactFreshWebpackPlugin', - 'NextMedusaPlugin', -]; - -/* - This code is checking if the remote is a string and that it includes an symbol If - both of these conditions are met then we extract the url and global from the remote - */ -export const parseRemoteSyntax = (remote: string) => { - if ( - typeof remote === 'string' && - remote.includes('@') && - !remote.startsWith('internal ') - ) { - const [url, global] = extractUrlAndGlobal(remote); - return generateRemoteTemplate(url, global); - } - - return remote; +/** + * Checks if the remote value is using the standard remote syntax. + * + * @param {string} value - The remote value to check. + * @returns {boolean} - True if the value is using the standard remote syntax, false otherwise. + */ +const isStandardRemoteSyntax = (value: string): boolean => { + return value.includes('@'); }; -/* - This code is doing the following It\'s iterating over all remotes and checking if - they are using a custom promise template or not If it\'s a custom promise template - we\'re parsing the remote syntax to get the module name and version number - */ -export const parseRemotes = (remotes: Record) => - Object.entries(remotes).reduce((acc, [key, value]) => { - // check if user is passing a internal "delegate module" reference - if (value.startsWith('internal ')) { + +/** + * Parses the remotes object, checking if they are using a custom promise template or not. + * If it's a custom promise template, the remote syntax is parsed to get the module name and version number. + * + * @param {Record} remotes - The remotes object to be parsed. + * @returns {Record} - The parsed remotes object. + */ +export const parseRemotes = ( + remotes: Record +): Record => { + return Object.entries(remotes).reduce((acc, [key, value]) => { + if (isInternalOrPromise(value)) { return { ...acc, [key]: value }; } - // check if user is passing custom promise template - if (!value.startsWith('promise ') && value.includes('@')) { - return { ...acc, [key]: `promise ${parseRemoteSyntax(value)}` }; + + if (isStandardRemoteSyntax(value)) { + return { + ...acc, + [key]: createDelegatedModule(require.resolve('./default-delegate'), { + remote: value, + }), + }; } - // return standard template otherwise + return { ...acc, [key]: value }; }, {} as Record); +}; + +/** + * Checks if the remote value is an internal delegate module reference. + * + * @param {string} value - The remote value to check. + * @returns {boolean} - True if the value is an internal delegate module reference, false otherwise. + */ +const isInternalDelegate = (value: string): boolean => { + return value.startsWith('internal '); +}; -export const getDelegates = (remotes: Record) => { +/** + * Gets the delegate modules from the remotes object. + * + * @param {Record} remotes - The remotes object containing delegates. + * @returns {Record} - The delegate modules from the remotes object. + */ +export const getDelegates = ( + remotes: Record +): Record => { return Object.entries(remotes).reduce((acc, [key, value]) => { - // check if user is passing a internal "delegate module" reference - if (value.startsWith('internal ')) { + if (isInternalDelegate(value)) { return { ...acc, [key]: value }; } @@ -320,31 +188,41 @@ export const getDelegates = (remotes: Record) => { }, {} as Record); }; -/* - This code is parsing the options shared object and creating a new object with all - of the shared configs Then it is iterating over each key in this new object and - assigning them to an array that will be returned by this function This array contains - objects that are used as values for the shared property of Module Federation Plugin - Options The first thing we do here is check if the item passed into shared was a - string or not if it\'s an array If it wasn\'t then throw an error because there should - only be strings in there Otherwise continue on with our code below - */ +/** + * Validates the shared item type and returns the shared config object based on the item and key. + * + * @param {string} item - The shared item. + * @param {string} key - The key for the shared item. + * @returns {object} - The shared config object. + * @throws {Error} - If the item type is not a string. + */ +const getSharedConfig = (item: string, key: string) => { + if (typeof item !== 'string') { + throw new Error('Unexpected array in shared'); + } + + return item === key || !isRequiredVersion(item) + ? { + import: item, + } + : { + import: key, + requiredVersion: item, + }; +}; + +/** + * Parses the share options in ModuleFederationPluginOptions and creates a new object with all + * of the shared configs. This object is then used as the value for the shared property + * of Module Federation Plugin Options. + * + * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions object. + * @returns {Record} - The parsed share options object. + */ const parseShareOptions = (options: ModuleFederationPluginOptions) => { const sharedOptions: [string, SharedConfig][] = parseOptions( options.shared, - (item: string, key: string) => { - if (typeof item !== 'string') - throw new Error('Unexpected array in shared'); - - return item === key || !isRequiredVersion(item) - ? { - import: item, - } - : { - import: key, - requiredVersion: item, - }; - }, + getSharedConfig, (item: any) => item ); @@ -363,13 +241,27 @@ const parseShareOptions = (options: ModuleFederationPluginOptions) => { }, {} as Record); }; -export const toDisplayErrors = (err: Error[]) => - err - .map((error) => { - let { message } = error; - if (error.stack) { - message += `\n${error.stack}`; - } - return message; - }) - .join('\n'); +/** + * Formats an error object into a displayable string. + * + * @param {Error} error - The error object to format. + * @returns {string} - The formatted error string. + */ +const formatError = (error: Error): string => { + let { message } = error; + if (error.stack) { + message += `\n${error.stack}`; + } + return message; +}; + +/** + * Converts an array of Error objects into a single string with formatted error messages, + * separated by newline characters. + * + * @param {Error[]} err - The array of Error objects. + * @returns {string} - The combined formatted error messages as a single string. + */ +export const toDisplayErrors = (err: Error[]): string => { + return err.map(formatError).join('\n'); +}; diff --git a/packages/nextjs-mf/src/loaders/async-boundary-loader.ts b/packages/nextjs-mf/src/loaders/async-boundary-loader.ts deleted file mode 100644 index be4dc27ae28..00000000000 --- a/packages/nextjs-mf/src/loaders/async-boundary-loader.ts +++ /dev/null @@ -1,90 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Zack Jackson @ScriptedAlchemy -*/ - -import type { LoaderContext, NormalModule } from 'webpack'; - -const pageTemplate = (request: string) => - ` - import dynamic from "next/dynamic" - const AsyncBoundary = dynamic(() => import("${request}"), {suspense:true}); - export default AsyncBoundary; - `; - -const getInitialPropsTemplate = (request: string) => - ` - AsyncBoundary.getInitialProps = async (ctx) => { - return import("${request}").then((mod) => { - const page = mod.default || mod; - return page.getInitialProps(ctx) - }) - } - `; - -const getStaticPropsTemplate = (request: string) => - ` - export const getStaticProps = async (ctx) => { - return import("${request}").then((mod) => { - return mod.getStaticProps(ctx) - }) - } - `; - -const getServerSidePropsTemplate = (request: string) => - ` - export const getServerSideProps = async (ctx) => { - return import("${request}").then((mod) => { - return mod.getServerSideProps(ctx) - }) - } - `; - -const getStaticPathsTemplate = (request: string) => - ` - export const getStaticPaths = async (ctx) => { - return import("${request}").then((mod) => { - return mod.getStaticPaths(ctx) - }) - } - `; - -export default function ( - this: LoaderContext>, - source: string, - sourceMap: string -) { - this.cacheable && this.cacheable(); - const callback = this.async(); - - if (this._compilation && this._compilation.name === 'ChildFederationPlugin') { - callback(null, source, sourceMap); - return; - } - const hasGIP = source.includes('getInitialProps'); - const hasGSP = source.includes('getStaticProps'); - const hasGSSP = source.includes('getServerSideProps'); - const hasGSPT = source.includes('getStaticPaths'); - - const relativeResource = this.utils.contextify(this.context, this.resource); - - const result = [pageTemplate(`${relativeResource}?hasBoundary`)]; - - if (hasGIP) { - result.push(getInitialPropsTemplate(`${relativeResource}?hasBoundary`)); - } - - if (hasGSP) { - result.push(getStaticPropsTemplate(`${relativeResource}?hasBoundary`)); - } - - if (hasGSSP) { - result.push(getServerSidePropsTemplate(`${relativeResource}?hasBoundary`)); - } - - if (hasGSPT) { - result.push(getStaticPathsTemplate(`${relativeResource}?hasBoundary`)); - } - - callback(null, result.join('\n')); -} diff --git a/packages/nextjs-mf/src/loaders/delegateLoader.ts b/packages/nextjs-mf/src/loaders/delegateLoader.ts index e6f5f27fb50..10490a67721 100644 --- a/packages/nextjs-mf/src/loaders/delegateLoader.ts +++ b/packages/nextjs-mf/src/loaders/delegateLoader.ts @@ -1,6 +1,4 @@ import type { LoaderContext } from 'webpack'; -import path from 'path'; - /** * * Requires either the default delegate module or a custom one @@ -15,7 +13,7 @@ export default function patchDefaultSharedLoader( const resolvedDelegates = Object.values(delegates).map((delegate) => { const [request, query] = delegate.replace('internal ', '').split('?'); if (query) { - let queries = []; + const queries = []; for (const [key, value] of new URLSearchParams(query).entries()) { queries.push(`${key}=${value}`); } @@ -35,10 +33,7 @@ export default function patchDefaultSharedLoader( } }); - if ( - content.includes('hasDelegateMarkers') - // || (this._compilation && this._compilation.name === 'ChildFederationPlugin') - ) { + if (content.includes('hasDelegateMarkers')) { return content; } diff --git a/packages/nextjs-mf/src/loaders/fixImageLoader.ts b/packages/nextjs-mf/src/loaders/fixImageLoader.ts index 295052bbe91..2ae42e4fee5 100644 --- a/packages/nextjs-mf/src/loaders/fixImageLoader.ts +++ b/packages/nextjs-mf/src/loaders/fixImageLoader.ts @@ -42,7 +42,7 @@ export async function fixImageLoader( Template.asString([ 'try {', Template.indent([ - 'const remoteEntry = global.__remote_scope__ && global.remoteEntryName && global.__remote_scope__._config[global.remoteEntryName];', + 'const remoteEntry = globalThis.__remote_scope__ && globalThis.__remote_scope__._config[__webpack_runtime_id__];', `if (remoteEntry) {`, Template.indent([ `const splitted = remoteEntry.split('/_next')`, @@ -69,7 +69,7 @@ export async function fixImageLoader( Template.indent( `return ${publicPath} && ${publicPath}.indexOf('://') > 0 ? new URL(${publicPath}).origin : ''` ), - `const path = document.currentScript && document.currentScript.src;`, + `const path = (document.currentScript && document.currentScript.src) || new URL(${publicPath}).origin;`, `const splitted = path.split('/_next')`, `return splitted.length === 2 ? splitted[0] : '';`, ]), diff --git a/packages/nextjs-mf/src/loaders/inject-hoist.ts b/packages/nextjs-mf/src/loaders/inject-hoist.ts new file mode 100644 index 00000000000..263e6aacb23 --- /dev/null +++ b/packages/nextjs-mf/src/loaders/inject-hoist.ts @@ -0,0 +1,14 @@ +// injectTopLoader.ts +import type { LoaderContext } from 'webpack'; + +function injectTopLoader( + this: LoaderContext>, + source: string +): string { + const delegateModuleHoistImport = + "require('@module-federation/nextjs-mf/src/internal-delegate-hoist');\n"; + + return `${delegateModuleHoistImport}${source}`; +} + +export default injectTopLoader; diff --git a/packages/nextjs-mf/src/loaders/nextPageMapLoader.ts b/packages/nextjs-mf/src/loaders/nextPageMapLoader.ts index 62fbc8c671a..6047c33c992 100644 --- a/packages/nextjs-mf/src/loaders/nextPageMapLoader.ts +++ b/packages/nextjs-mf/src/loaders/nextPageMapLoader.ts @@ -173,6 +173,3 @@ function preparePageMapV2(pages: string[]) { return result; } - -// module.exports = nextPageMapLoader; -// module.exports.exposeNextjsPages = exposeNextjsPages; diff --git a/packages/nextjs-mf/src/loaders/patchDefaultSharedLoader.ts b/packages/nextjs-mf/src/loaders/patchDefaultSharedLoader.ts index 44d37b7d47e..4621bb4a797 100644 --- a/packages/nextjs-mf/src/loaders/patchDefaultSharedLoader.ts +++ b/packages/nextjs-mf/src/loaders/patchDefaultSharedLoader.ts @@ -1,31 +1,34 @@ import type { LoaderContext } from 'webpack'; - +import fs from 'fs'; import path from 'path'; -/** - * - * Requires `include-defaults.js` with required shared libs - * - */ export default function patchDefaultSharedLoader( this: LoaderContext>, content: string ) { - if (content.includes('include-defaults')) { + if (content.includes('placeholderModuleEnsure')) { // If already patched, return return content; } - // avoid absolute paths as they break hashing when the root for the project is moved - // @see https://webpack.js.org/contribute/writing-a-loader/#absolute-paths - const pathIncludeDefaults = path.relative( - this.context, - path.resolve(__dirname, '../include-defaults') - ); - - return [ - '', - `require(${JSON.stringify('./' + pathIncludeDefaults)});`, - content, - ].join('\n'); + const patch = ` + "use client"; +(globalThis || self).placeholderModuleEnsure = () => { +throw new Error('should not exec'); + import('react'); + import('react-dom'); + import('next/link'); + import('next/router'); + import('next/head'); + import('next/script'); + import('next/dynamic'); + import('styled-jsx'); + import('styled-jsx/style'); + if (process.env['NODE_ENV'] === 'development') { + import('react/jsx-dev-runtime'); + } else { + import('react/jsx-runtime'); + } +};`; + return ['', patch, content].join('\n'); } diff --git a/packages/nextjs-mf/src/plugins/ChildFederationPlugin.ts b/packages/nextjs-mf/src/plugins/ChildFederationPlugin.ts deleted file mode 100644 index cd1bb4fa3d7..00000000000 --- a/packages/nextjs-mf/src/plugins/ChildFederationPlugin.ts +++ /dev/null @@ -1,417 +0,0 @@ -import type { - Compiler, - Stats, - WebpackError, - WebpackPluginInstance, -} from 'webpack'; -import { Compilation } from 'webpack'; -import type { WatchOptions } from '../types'; -import { ChunkCorrelationPlugin } from '@module-federation/node'; -import type { - ModuleFederationPluginOptions, - NextFederationPluginExtraOptions, -} from '@module-federation/utilities'; - -import path from 'path'; -import fs from 'fs'; - -import { exposeNextjsPages } from '../loaders/nextPageMapLoader'; -import { hasLoader, injectRuleLoader } from '../loaders/helpers'; - -import { - DEFAULT_SHARE_SCOPE, - getOutputPath, - externalizedShares, - removePlugins, - toDisplayErrors, -} from '../internal'; -import { createRuntimeVariables } from '@module-federation/utilities'; - -import { computeRemoteFilename } from '../../utils/build-utils'; - -import ChildFriendlyModuleFederationPlugin from './ModuleFederationPlugin'; -import RemoveRRRuntimePlugin from './RemoveRRRuntimePlugin'; -import AddRuntimeRequirementToPromiseExternal from './AddRuntimeRequirementToPromiseExternalPlugin'; - -const CHILD_PLUGIN_NAME = 'ChildFederationPlugin'; -const childCompilers = {} as Record; - -export class ChildFederationPlugin { - private _options: ModuleFederationPluginOptions; - private _extraOptions: NextFederationPluginExtraOptions; - private watching?: boolean; - private initalRun: boolean; - - constructor( - options: ModuleFederationPluginOptions, - extraOptions: NextFederationPluginExtraOptions - ) { - this._options = options; - this._extraOptions = extraOptions; - this.initalRun = false; - } - - apply(compiler: Compiler) { - const webpack = compiler.webpack; - const LibraryPlugin = webpack.library.EnableLibraryPlugin; - const LoaderTargetPlugin = webpack.LoaderTargetPlugin; - const library = compiler.options.output.library; - const isServer = compiler.options.name === 'server'; - const isDev = compiler.options.mode === 'development'; - let outputPath: string; - - if (isDev && isServer) { - outputPath = path.join(getOutputPath(compiler), 'static/ssr'); - } else { - if (isServer) { - outputPath = path.join(getOutputPath(compiler), 'static/ssr'); - } else { - outputPath = compiler.options.output.path as string; - } - } - - compiler.hooks.thisCompilation.tap(CHILD_PLUGIN_NAME, (compilation) => { - let plugins = [] as WebpackPluginInstance[]; - const buildName = this._options.name; - // using ModuleFederationPlugin does not work, i had to fork because of afterPlugins hook on containerPlugin. - const FederationPlugin = ChildFriendlyModuleFederationPlugin; - - const MedusaPlugin = compiler.options.plugins.find((p) => { - return p.constructor.name === 'NextMedusaPlugin'; - }); - - let uniqueName = buildName; - if (MedusaPlugin && compiler.options.output.uniqueName !== '_N_E') { - uniqueName = compiler.options.output.uniqueName; - } - - const childOutput = { - ...compiler.options.output, - path: outputPath, - // path: deriveOutputPath(isServer, compiler.options.output.path), - name: 'child-' + compiler.options.name, - publicPath: 'auto', - chunkLoadingGlobal: uniqueName + 'chunkLoader', - uniqueName: uniqueName, - library: { - name: buildName, - type: library?.type as string, - }, - // chunkFilename: ( - // compiler.options.output.chunkFilename as string - // )?.replace('.js', isDev ? '-fed.js' : '[contenthash]-fed.js'), - // filename: (compiler.options.output.filename as string)?.replace( - // '.js', - // isDev ? '-fed.js' : '[contenthash]-fed.js' - // ), - //TODO: find a better solution for dev mode thats not as slow as hashing the chunks. - chunkFilename: ( - compiler.options.output.chunkFilename as string - )?.replace('.js', '-[contenthash]-fed.js'), - filename: (compiler.options.output.filename as string)?.replace( - '.js', - '-[contenthash]-fed.js' - ), - }; - - const federationPluginOptions: ModuleFederationPluginOptions = { - // library: {type: 'var', name: buildName}, - ...this._options, - name: MedusaPlugin - ? '__REMOTE_VERSION__' + this._options.name - : this._options.name, - library: { - type: this._options.library?.type as string, - name: MedusaPlugin - ? '__REMOTE_VERSION__' + this._options.name - : this._options.name, - }, - filename: computeRemoteFilename( - isServer, - this._options.filename as string - ), - exposes: { - // in development we do not hash chunks, so we need some way to cache bust the server container when remote changes - // in prod we hash the chunk so we can use [contenthash] which changes the overall hash of the remote container - // doesnt work as intended for dev mode - ...this._options.exposes, - ...(this._extraOptions.exposePages - ? exposeNextjsPages(compiler.options.context as string) - : {}), - }, - runtime: false, - shared: { - ...(this._extraOptions.skipSharingNextInternals - ? {} - : externalizedShares), - ...this._options.shared, - }, - }; - if (compiler.options.name === 'client') { - plugins = [ - new webpack.EntryPlugin( - compiler.context, - require.resolve('../internal-delegate-hoist'), - federationPluginOptions.name - ), - new FederationPlugin(federationPluginOptions), - new webpack.web.JsonpTemplatePlugin(), - new LoaderTargetPlugin('web'), - new LibraryPlugin(this._options.library?.type as string), - new webpack.DefinePlugin({ - 'process.env.REMOTES': createRuntimeVariables( - this._options.remotes - ), - 'process.env.CURRENT_HOST': JSON.stringify(this._options.name), - }), - new AddRuntimeRequirementToPromiseExternal(), - ]; - } else if (compiler.options.name === 'server') { - const { - StreamingTargetPlugin, - NodeFederationPlugin, - } = require('@module-federation/node'); - - plugins = [ - new webpack.EntryPlugin( - compiler.context, - require.resolve('../internal-delegate-hoist'), - federationPluginOptions.name - ), - new NodeFederationPlugin(federationPluginOptions, { - ModuleFederationPlugin: FederationPlugin, - }), - new webpack.node.NodeTemplatePlugin(childOutput), - //TODO: Externals function needs to internalize any shared module for host and remote build - new webpack.ExternalsPlugin(compiler.options.externalsType, [ - // next dynamic needs to be within webpack, cannot be externalized - ...Object.keys(DEFAULT_SHARE_SCOPE).filter( - (k) => - k !== 'next/dynamic' && k !== 'next/link' && k !== 'next/script' - ), - 'react/jsx-runtime', - 'react/jsx-dev-runtime', - ]), - // new LoaderTargetPlugin('async-node'), - new StreamingTargetPlugin(federationPluginOptions, { - ModuleFederationPlugin: webpack.container.ModuleFederationPlugin, - }), - new LibraryPlugin(federationPluginOptions.library?.type as string), - // new webpack.DefinePlugin({ - // 'process.env.REMOTES': JSON.stringify(this._options.remotes), - // 'process.env.CURRENT_HOST': JSON.stringify(this._options.name), - // }), - new AddRuntimeRequirementToPromiseExternal(), - ]; - } - - const childCompiler = compilation.createChildCompiler( - CHILD_PLUGIN_NAME, - childOutput, - plugins - ); - - if (!isServer) { - new ChunkCorrelationPlugin({ - filename: 'static/ssr/federated-stats.json', - }).apply(childCompiler); - } - - childCompiler.outputPath = outputPath; - childCompiler.options.module.rules.forEach((rule) => { - // next-image-loader fix which adds remote's hostname to the assets url - if ( - this._extraOptions.enableImageLoaderFix && - hasLoader(rule, 'next-image-loader') - ) { - // childCompiler.options.module.parser.javascript?.url = 'relative'; - injectRuleLoader(rule, { - loader: require.resolve('../loaders/fixImageLoader'), - }); - } - - // url-loader fix for which adds remote's hostname to the assets url - if ( - this._extraOptions.enableUrlLoaderFix && - hasLoader(rule, 'url-loader') - ) { - injectRuleLoader({ - loader: path.resolve(__dirname, '../loaders/fixUrlLoader'), - }); - } - }); - - (childCompiler.options.experiments.lazyCompilation as any) = false; - childCompiler.options.optimization.runtimeChunk = false; - childCompiler.outputFileSystem = fs; - - // no custom chunk splitting should be derived from host (next) - delete childCompiler.options.optimization.splitChunks; - - if ( - compiler.options.optimization.minimize && - compiler.options.optimization.minimizer - ) { - for (const minimizer of compiler.options.optimization.minimizer) { - if (typeof minimizer === 'function') { - (minimizer as any).call(childCompiler, childCompiler); - } else if (minimizer !== '...') { - minimizer.apply(childCompiler); - } - } - } - - new RemoveRRRuntimePlugin().apply(childCompiler); - - // TODO: Provide better types for MiniCss Plugin for ChildCompiler in ChildFederationPlugin - const MiniCss = childCompiler.options.plugins.find((p) => { - return p.constructor.name === 'NextMiniCssExtractPlugin'; - }) as any; - - if (MedusaPlugin) { - //@ts-ignore - new MedusaPlugin.constructor({ - //@ts-ignore - ...MedusaPlugin._options, - filename: compiler.options.name + '-dashboard-child.json', - }).apply(childCompiler); - } - - childCompiler.options.plugins = childCompiler.options.plugins.filter( - (plugin) => !removePlugins.includes(plugin.constructor.name) - ); - - if (MiniCss) { - // grab mini-css and reconfigure it to avoid conflicts with host - new MiniCss.constructor({ - ...MiniCss.options, - filename: MiniCss.options.filename.replace('.css', '-fed.css'), - chunkFilename: MiniCss.options.chunkFilename.replace( - '.css', - '-fed.css' - ), - }).apply(childCompiler); - } - - // cache the serer compiler instance, we will run the server child compiler during the client main compilation - // we need to do this because i need access to data from the client build to inject into the server build - // in prod builds, server build runs first, followed by client build - // in dev, client build runs first, followed by server build - if (compiler.options.name) { - childCompilers[compiler.options.name] = childCompiler; - } - - if (isDev) { - const compilerWithCallback = ( - watchOptions: WatchOptions, - callback: any - ) => { - if (childCompiler.watch && isServer) { - if (!this.watching) { - this.watching = true; - childCompiler.watch(watchOptions, callback); - } - } else { - childCompiler.run(callback); - } - }; - - const compilerCallback = ( - err: Error | null | undefined, - stats: Stats | undefined - ) => { - //workaround due to watch mode not running unless youve hit a page on the remote itself - if (isServer && isDev && childCompilers['client']) { - childCompilers['client'].run((err, stats) => { - if (err) { - compilation.errors.push(err as WebpackError); - } - if (stats && stats.hasErrors()) { - compilation.errors.push( - new Error( - toDisplayErrors(stats.compilation.errors) - ) as WebpackError - ); - } - }); - } - if (err) { - compilation.errors.push(err as WebpackError); - } - if (stats && stats.hasErrors()) { - compilation.errors.push( - new Error( - toDisplayErrors(stats.compilation.errors) - ) as WebpackError - ); - } - }; - - compilerWithCallback(compiler.options.watchOptions, compilerCallback); - - // in prod, if client - } else if (!isServer) { - // if ssr enabled and server in compiler cache - if (childCompilers['server']) { - //wrong hook for this - // add hook for additional assets to prevent compile from sealing. - compilation.hooks.processAssets.tapPromise( - { - name: CHILD_PLUGIN_NAME, - stage: Compilation.PROCESS_ASSETS_STAGE_REPORT, - }, - () => { - return new Promise((res, rej) => { - // run server child compilation during client main compilation - childCompilers['server'].run((err, stats) => { - if (err) { - compilation.errors.push(err as WebpackError); - rej(); - } - if (stats && stats.hasWarnings()) { - compilation.warnings.push( - new Error( - toDisplayErrors(stats.compilation.warnings) - ) as WebpackError - ); - } - if (stats && stats.hasErrors()) { - compilation.errors.push( - new Error( - toDisplayErrors(stats.compilation.errors) - ) as WebpackError - ); - rej(); - } - res(); - }); - }); - } - ); - } - // run client child compiler like normal - childCompiler.run((err, stats) => { - if (err) { - compilation.errors.push(err as WebpackError); - } - if (stats && stats.hasWarnings()) { - compilation.warnings.push( - new Error( - toDisplayErrors(stats.compilation.warnings) - ) as WebpackError - ); - } - if (stats && stats.hasErrors()) { - compilation.errors.push( - new Error( - toDisplayErrors(stats.compilation.errors) - ) as WebpackError - ); - } - }); - } - }); - } -} - -export default ChildFederationPlugin; diff --git a/packages/nextjs-mf/src/plugins/CopyFederationPlugin.ts b/packages/nextjs-mf/src/plugins/CopyFederationPlugin.ts new file mode 100644 index 00000000000..f5c71a94207 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/CopyFederationPlugin.ts @@ -0,0 +1,62 @@ +import fs from 'fs'; +import path from 'path'; +import { Compilation, Compiler } from 'webpack'; + +class CopyBuildOutputPlugin { + private isServer: boolean; + + constructor(isServer: boolean) { + this.isServer = isServer; + } + + apply(compiler: Compiler): void { + const copyFiles = (source: string, destination: string): void => { + const files = fs.readdirSync(source); + + files.forEach((file) => { + const sourcePath = path.join(source, file); + const destinationPath = path.join(destination, file); + + if (fs.lstatSync(sourcePath).isDirectory()) { + if (!fs.existsSync(destinationPath)) { + fs.mkdirSync(destinationPath); + } + copyFiles(sourcePath, destinationPath); + } else { + fs.copyFileSync(sourcePath, destinationPath); + } + }); + }; + + compiler.hooks.afterEmit.tapAsync( + 'CopyBuildOutputPlugin', + (compilation: Compilation, callback: () => void) => { + const { outputPath } = compiler; + const outputString = outputPath.split('server')[0]; + const isProd = compiler.options.mode === 'production'; + + if (!isProd && !this.isServer) { + return callback(); + } + + const serverLoc = path.join( + outputString, + this.isServer && isProd ? '/ssr' : '/static/ssr' + ); + const servingLoc = path.join(outputPath, 'ssr'); + + if (!fs.existsSync(serverLoc)) { + fs.mkdirSync(serverLoc, { recursive: true }); + } + + const sourcePath = this.isServer ? outputPath : servingLoc; + if (fs.existsSync(sourcePath)) { + copyFiles(sourcePath, serverLoc); + } + callback(); + } + ); + } +} + +export default CopyBuildOutputPlugin; diff --git a/packages/nextjs-mf/src/plugins/JsonpChunkLoading.ts b/packages/nextjs-mf/src/plugins/JsonpChunkLoading.ts new file mode 100644 index 00000000000..ad887da3f6e --- /dev/null +++ b/packages/nextjs-mf/src/plugins/JsonpChunkLoading.ts @@ -0,0 +1,73 @@ +// CustomWebpackPlugin.ts +import type { + Chunk, + Compilation, + Compiler, + Module, + RuntimeModule, +} from 'webpack'; +import { ConcatSource } from 'webpack-sources'; +// @ts-ignore +import JsonpChunkLoadingRuntimeModule from 'webpack/lib/web/JsonpChunkLoadingRuntimeModule'; +import Template from '../../utils/Template'; +import template from './container/custom-jsonp'; + +function getCustomJsonpCode( + chunkLoadingGlobal: string, + RuntimeGlobals: any +): string { + const code = [ + 'var chunkQueue = [];', + 'var chunkTracker = [];', + `var chunkLoadingGlobal = self[${JSON.stringify( + chunkLoadingGlobal + )}] || [];`, + 'var asyncQueue = [];', + template, + ]; + return Template.asString(code); +} + +class CustomWebpackPlugin { + private options: any; + + constructor(options?: any) { + this.options = options || {}; + } + + apply(compiler: Compiler): void { + compiler.hooks.compilation.tap( + 'CustomWebpackPlugin', + (compilation: Compilation) => { + compilation.hooks.runtimeModule.tap( + 'CustomWebpackPlugin', + (runtimeModule: RuntimeModule, chunk: any) => { + if (this.options.server && chunk.name === 'webpack-runtime') { + // if server runtime module + } + + if ( + runtimeModule.constructor.name === + 'JsonpChunkLoadingRuntimeModule' && + chunk.name === 'webpack' + ) { + const originalSource = runtimeModule.getGeneratedCode(); + const modifiedSource = new ConcatSource( + originalSource, + '\n', + getCustomJsonpCode( + //@ts-ignore + compilation.outputOptions.chunkLoadingGlobal, + compiler.webpack.RuntimeGlobals + ) + ); + runtimeModule.getGeneratedCode = () => modifiedSource.source(); + } + } + ); + } + ); + } +} + +export default CustomWebpackPlugin; diff --git a/packages/nextjs-mf/src/plugins/ModuleFederationPlugin.ts b/packages/nextjs-mf/src/plugins/ModuleFederationPlugin.ts deleted file mode 100644 index 1184447c5ce..00000000000 --- a/packages/nextjs-mf/src/plugins/ModuleFederationPlugin.ts +++ /dev/null @@ -1,63 +0,0 @@ -import type { Compiler } from 'webpack'; -import type { - ModuleFederationPluginOptions, - ExternalsType, -} from '@module-federation/utilities'; - -export default class ModuleFederationPlugin { - private _options!: ModuleFederationPluginOptions; - - constructor(options: ModuleFederationPluginOptions) { - this._options = options; - } - apply(compiler: Compiler) { - const { _options: options } = this; - const webpack = compiler.webpack; - const { ContainerPlugin, ContainerReferencePlugin } = webpack.container; - const { SharePlugin } = webpack.sharing; - const library = options.library || { type: 'var', name: options.name }; - const remoteType = - options.remoteType || - (options.library && (options.library.type as ExternalsType)) || - 'script'; - - if ( - library && - !compiler.options.output.enabledLibraryTypes?.includes(library.type) - ) { - compiler.options.output.enabledLibraryTypes?.push(library.type); - } - - if ( - options.exposes && - (Array.isArray(options.exposes) - ? options.exposes.length > 0 - : Object.keys(options.exposes).length > 0) - ) { - new ContainerPlugin({ - name: options.name as string, - library, - filename: options.filename, - runtime: options.runtime, - exposes: options.exposes, - }).apply(compiler); - } - if ( - options.remotes && - (Array.isArray(options.remotes) - ? options.remotes.length > 0 - : Object.keys(options.remotes).length > 0) - ) { - new ContainerReferencePlugin({ - remoteType, - remotes: options.remotes, - }).apply(compiler); - } - if (options.shared) { - new SharePlugin({ - shared: options.shared, - shareScope: options.shareScope, - }).apply(compiler); - } - } -} diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin.ts deleted file mode 100644 index d61ae93e463..00000000000 --- a/packages/nextjs-mf/src/plugins/NextFederationPlugin.ts +++ /dev/null @@ -1,299 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Zackary Jackson @ScriptedAlchemy -*/ -'use strict'; - -import type { - ModuleFederationPluginOptions, - NextFederationPluginExtraOptions, - NextFederationPluginOptions, -} from '@module-federation/utilities'; -import { createRuntimeVariables } from '@module-federation/utilities'; - -import type { Compiler } from 'webpack'; -import path from 'path'; - -import { - internalizeSharedPackages, - parseRemotes, - reKeyHostShared, - getDelegates, -} from '../internal'; -import AddRuntimeRequirementToPromiseExternal from './AddRuntimeRequirementToPromiseExternalPlugin'; -import ChildFederationPlugin from './ChildFederationPlugin'; - -import DevHmrFixInvalidPongPlugin from './DevHmrFixInvalidPongPlugin'; - -// @ts-ignore -const regexEqual = (x, y) => { - return ( - x instanceof RegExp && - y instanceof RegExp && - x.source === y.source && - x.global === y.global && - x.ignoreCase === y.ignoreCase && - x.multiline === y.multiline - ); -}; - -export class NextFederationPlugin { - private _options: ModuleFederationPluginOptions; - private _extraOptions: NextFederationPluginExtraOptions; - - constructor(options: NextFederationPluginOptions) { - const { extraOptions, ...mainOpts } = options; - this._options = mainOpts; - this._extraOptions = { - automaticPageStitching: false, - enableImageLoaderFix: false, - enableUrlLoaderFix: false, - skipSharingNextInternals: false, - automaticAsyncBoundary: false, - ...extraOptions, - }; - } - - apply(compiler: Compiler) { - if (!compiler.options.name) { - throw new Error('name is not defined in Compiler options'); - } - - if (!this._options.filename) { - throw new Error('filename is not defined in NextFederation options'); - } - - if (!['server', 'client'].includes(compiler.options.name)) { - return; - } - - const isServer = compiler.options.name === 'server'; - const { webpack } = compiler; - - if (isServer) { - // target false because we use our own target for node env - compiler.options.target = false; - const { StreamingTargetPlugin } = require('@module-federation/node'); - - new StreamingTargetPlugin(this._options, { - ModuleFederationPlugin: webpack.container.ModuleFederationPlugin, - }).apply(compiler); - - this._options.library = { - type: 'commonjs-module', - name: this._options.name, - }; - // output remote to ssr if server - this._options.filename = path.basename(this._options.filename); - - // should this be a plugin that we apply to the compiler? - internalizeSharedPackages(this._options, compiler); - - // module-federation/utilities uses internal webpack methods and must be bundled into runtime code. - if (Array.isArray(compiler.options.externals)) { - const originalExternals = compiler.options.externals[0]; - compiler.options.externals[0] = function (ctx, callback) { - if ( - ctx.request && - (ctx.request.includes('@module-federation/utilities') || - ctx.request.includes('@module-federation/dashboard-plugin')) - ) { - return callback(); - } - // @ts-ignore - return originalExternals(ctx, callback); - }; - } - } else { - new webpack.EntryPlugin( - compiler.context, - require.resolve('../internal-delegate-hoist'), - 'main' - ).apply(compiler); - - if (this._extraOptions.automaticPageStitching) { - compiler.options.module.rules.push({ - test: /next[\\/]dist[\\/]client[\\/]page-loader\.js$/, - loader: path.resolve( - __dirname, - '../loaders/patchNextClientPageLoader' - ), - }); - } - - if (this._options.remotes) { - this._options.remotes = parseRemotes(this._options.remotes); - } - - if (this._options.library) { - console.error('[mf] you cannot set custom library'); - } - - this._options.library = { - // assign remote name to object to avoid SWC mangling top level variable - type: 'window', - name: this._options.name, - }; - } - - const allowedPaths = ['pages/', 'app/', 'src/pages/', 'src/app/']; - - //patch next - compiler.options.module.rules.push({ - test(req: string) { - if (isServer) return false; - if ( - allowedPaths.some((p) => req.includes(path.join(compiler.context, p))) - ) { - return /\.(js|jsx|ts|tsx|md|mdx|mjs)$/i.test(req); - } - return false; - }, - include: compiler.context, - exclude: [ - /node_modules/, - /_middleware/, - /pages[\\/]middleware/, - /pages[\\/]api/, - ], - loader: require.resolve('../loaders/patchDefaultSharedLoader'), - }); - - if (this._options.remotes) { - const delegates = getDelegates(this._options.remotes); - // only apply loader if delegates are present - if (delegates && Object.keys(delegates).length > 0) { - compiler.options.module.rules.push({ - test(req: string) { - if (isServer) { - // server has no common chunk or entry to hoist into - if ( - allowedPaths.some((p) => - req.includes(path.join(compiler.context, p)) - ) - ) { - return /\.(js|jsx|ts|tsx|md|mdx|mjs)$/i.test(req); - } - } - if (req.includes('internal-delegate-hoist')) { - return true; - } - return false; - }, - resourceQuery: this._extraOptions.automaticAsyncBoundary - ? (query) => !query.includes('hasBoundary') - : undefined, - include: [compiler.context, /internal-delegate-hoist/], - exclude: (request: string) => { - if (request.includes('internal-delegate-hoist')) { - return false; - } - return /node_modules/.test(request); - }, - loader: require.resolve('../loaders/delegateLoader'), - options: { - delegates, - }, - }); - } - } - - if (this._extraOptions.automaticAsyncBoundary) { - const jsRules = compiler.options.module.rules.find((r) => { - //@ts-ignore - return r && r.oneOf; - }); - - //@ts-ignore - if (jsRules && jsRules.oneOf) { - //@ts-ignore - const foundJsLayer = jsRules.oneOf.find((r) => { - return ( - regexEqual(r.test, /\.(tsx|ts|js|cjs|mjs|jsx)$/) && !r.issuerLayer - ); - }); - - if (foundJsLayer) { - let loaderChain = []; - if (Array.isArray(foundJsLayer.use)) { - loaderChain = [...foundJsLayer.use]; - } else { - loaderChain = [foundJsLayer.use]; - } - //@ts-ignore - jsRules.oneOf.unshift({ - test: (request: string) => { - if ( - allowedPaths.some((p) => - request.includes(path.join(compiler.context, p)) - ) - ) { - return /\.(js|jsx|ts|tsx|md|mdx|mjs)$/i.test(request); - } - return false; - }, - exclude: [ - /node_modules/, - /_document/, - /_middleware/, - /pages[\\/]middleware/, - /pages[\\/]api/, - ], - resourceQuery: (query: string) => !query.includes('hasBoundary'), - use: [ - ...loaderChain, - { - loader: require.resolve('../loaders/async-boundary-loader'), - }, - ], - }); - } - } - } - - //todo runtime variable creation needs to be applied for server as well. this is just for client - // TODO: this needs to be refactored into something more comprehensive. this is just a quick fix - new webpack.DefinePlugin({ - 'process.env.REMOTES': createRuntimeVariables(this._options.remotes), - 'process.env.CURRENT_HOST': JSON.stringify(this._options.name), - }).apply(compiler); - - const ModuleFederationPlugin = isServer - ? require('@module-federation/node').NodeFederationPlugin - : webpack.container.ModuleFederationPlugin; - - // ignore edge runtime and middleware builds - if (!ModuleFederationPlugin) { - return; - } - const internalShare = reKeyHostShared(this._options.shared); - const hostFederationPluginOptions: ModuleFederationPluginOptions = { - ...this._options, - exposes: {}, - shared: { - noop: { - import: 'data:text/javascript,module.exports = {};', - requiredVersion: false, - eager: true, - version: '0', - }, - ...internalShare, - }, - }; - - new ModuleFederationPlugin(hostFederationPluginOptions, { - ModuleFederationPlugin, - }).apply(compiler); - - new ChildFederationPlugin(this._options, this._extraOptions).apply( - compiler - ); - new AddRuntimeRequirementToPromiseExternal().apply(compiler); - - if (compiler.options.mode === 'development') { - new DevHmrFixInvalidPongPlugin().apply(compiler); - } - } -} - -export default NextFederationPlugin; diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/apply-client-plugins.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/apply-client-plugins.ts new file mode 100644 index 00000000000..5a20083c20a --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/apply-client-plugins.ts @@ -0,0 +1,88 @@ +import { Compiler } from 'webpack'; +import { + ModuleFederationPluginOptions, + NextFederationPluginExtraOptions, +} from '@module-federation/utilities'; +import DelegateModulesPlugin from '@module-federation/utilities/src/plugins/DelegateModulesPlugin'; +import { DEFAULT_SHARE_SCOPE_BROWSER } from '../../internal'; +import { ChunkCorrelationPlugin } from '@module-federation/node'; +import InvertedContainerPlugin from '../container/InvertedContainerPlugin'; +import JsonpChunkLoading from '../JsonpChunkLoading'; +/** + * Applies client-specific plugins. + * + * @param compiler - The Webpack compiler instance. + * @param options - The ModuleFederationPluginOptions instance. + * @param extraOptions - The NextFederationPluginExtraOptions instance. + * + * @remarks + * This function applies plugins to the Webpack compiler instance that are specific to the client build of + * a Next.js application with Module Federation enabled. These plugins include the following: + * + * - AddModulesPlugin: Adds modules to the webpack container runtime that can be streamed to other runtimes. + * - EntryPlugin: Creates an entry point for the application that delegates module loading to the container runtime. + * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes. + * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its + * own remote interface at startup. + * + * If automatic page stitching is enabled, a loader is added to process the `next/dist/client/page-loader.js` + * file. If a custom library is specified in the options, an error is thrown. The options.library property is + * also set to `{ type: 'window', name: options.name }`. + */ +export function applyClientPlugins( + compiler: Compiler, + options: ModuleFederationPluginOptions, + extraOptions: NextFederationPluginExtraOptions +): void { + const { webpack } = compiler; + const { remotes, name } = options; + //@ts-ignore + compiler.options.output.publicPath = 'auto'; + // Build will hang without this. Likely something in my plugin + compiler.options.optimization.splitChunks = undefined; + + // Add a new plugin to hoist modules into remote runtime + new JsonpChunkLoading({ debug: extraOptions.debug }).apply(compiler); + new DelegateModulesPlugin({ + container: name, + runtime: 'webpack', + remotes, + debug: extraOptions.debug, + }).apply(compiler); + + // If automatic page stitching is enabled, add a new rule to the compiler's module rules + if (extraOptions.automaticPageStitching) { + console.warn('[nextjs-mf]', 'automatic page stitching is disabled in v7'); + // compiler.options.module.rules.push({ + // test: /next[\\/]dist[\\/]client[\\/]page-loader\.js$/, + // loader: path.resolve( + // __dirname, + // '../../loaders/patchNextClientPageLoader' + // ), + // }); + } + + // If a custom library is set, log an error message + if (options.library) { + console.error('[nextjs-mf] you cannot set custom library'); + } + + // Set the library option to be a window object with the name of the module federation plugin + options.library = { + type: 'window', + name, + }; + + // Add a new chunk correlation plugin to the compiler + new ChunkCorrelationPlugin({ + filename: 'static/chunks/federated-stats.json', + }).apply(compiler); + + // Add a new commonjs chunk loading plugin to the compiler + new InvertedContainerPlugin({ + runtime: 'webpack', + container: options.name, + remotes: options.remotes as Record, + debug: extraOptions.debug, + }).apply(compiler); +} diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/apply-server-plugins.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/apply-server-plugins.ts new file mode 100644 index 00000000000..ea6b5a3b506 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/apply-server-plugins.ts @@ -0,0 +1,185 @@ +import { Compiler } from 'webpack'; +import { ModuleFederationPluginOptions } from '@module-federation/utilities'; +import DelegatesModulePlugin from '@module-federation/utilities/src/plugins/DelegateModulesPlugin'; +import path from 'path'; +import InvertedContainerPlugin from '../container/InvertedContainerPlugin'; +import JsonpChunkLoading from '../JsonpChunkLoading'; + +/** + * Applies server-specific plugins. + * + * @param compiler - The Webpack compiler instance. + * @param options - The ModuleFederationPluginOptions instance. + * + */ +export function applyServerPlugins( + compiler: Compiler, + options: ModuleFederationPluginOptions +): void { + // Import the StreamingTargetPlugin from @module-federation/node + const { StreamingTargetPlugin } = require('@module-federation/node'); + new JsonpChunkLoading({ server: true }).apply(compiler); + + new DelegatesModulePlugin({ + runtime: 'webpack-runtime', + remotes: options.remotes, + container: options.name, + }).apply(compiler); + + // Add the StreamingTargetPlugin with the ModuleFederationPlugin from the webpack container + new StreamingTargetPlugin(options, { + ModuleFederationPlugin: compiler.webpack.container.ModuleFederationPlugin, + }).apply(compiler); + + // Add a new commonjs chunk loading plugin to the compiler + new InvertedContainerPlugin({ + runtime: 'webpack-runtime', + container: options.name, + remotes: options.remotes as Record, + debug: false, + }).apply(compiler); +} + +/** + * Configures server-specific library and filename options. + * + * @param options - The ModuleFederationPluginOptions instance. + * + * @remarks + * This function configures the library and filename options for server builds. The library option is + * set to the commonjs-module format for chunks and the container, which allows them to be streamed over + * to hosts with the NodeFederationPlugin. The filename option is set to the basename of the current + * filename. + */ +export function configureServerLibraryAndFilename( + options: ModuleFederationPluginOptions +): void { + // Configure the library option with type "commonjs-module" and the name from the options + options.library = { + type: 'commonjs-module', + name: options.name, + }; + + // Set the filename option to the basename of the current filename + options.filename = path.basename(options.filename as string); +} + +/** + * Patches Next.js' default externals function to make sure shared modules are bundled and not treated as external. + * + * @param compiler - The Webpack compiler instance. + * @param options - The ModuleFederationPluginOptions instance. + * + * @remarks + * In server builds, all node modules are treated as external, which prevents them from being shared + * via module federation. To work around this limitation, we mark shared modules as internalizable + * modules that webpack puts into chunks that can be streamed to other runtimes as needed. + * + * This function replaces Next.js' default externals function with a new asynchronous function that + * checks whether a module should be treated as external. If the module should not be treated as + * external, the function returns without calling the original externals function. Otherwise, the + * function calls the original externals function and retrieves the result. If the result is null, + * the function returns without further processing. If the module is from Next.js or React, the + * function returns the original result. Otherwise, the function returns null. + */ +export function handleServerExternals( + compiler: Compiler, + options: ModuleFederationPluginOptions +): void { + // Check if the compiler has an `externals` array + if ( + Array.isArray(compiler.options.externals) && + compiler.options.externals[0] + ) { + // Retrieve the original externals function + const originalExternals = compiler.options.externals[0]; + + // Replace the original externals function with a new asynchronous function + compiler.options.externals[0] = async function (ctx, callback) { + // Check if the module should not be treated as external + if ( + ctx.request && + (ctx.request.includes('@module-federation/utilities') || + ctx.request.includes('internal-delegate-hoist') || + Object.keys(options.shared || {}).some((key) => { + return ( + //@ts-ignore + options.shared?.[key]?.import !== false && + ctx?.request?.includes(key) + ); + }) || + ctx.request.includes('@module-federation/dashboard-plugin')) + ) { + // If the module should not be treated as external, return without calling the original externals function + return; + } + + // seems to cause build issues at lululemon + // nobody else seems to run into this issue + // #JobSecurity + if (ctx.request && ctx.request.includes('react/jsx-runtime')) { + return 'commonjs ' + ctx.request; + } + + // Call the original externals function and retrieve the result + // @ts-ignore + const fromNext = await originalExternals(ctx, callback); + + // If the result is null, return without further processing + if (!fromNext) { + return; + } + + // If the module is from Next.js or React, return the original result + const req = fromNext.split(' ')[1]; + if ( + req.startsWith('next') || + // make sure we dont screw up package names that start with react + // like react-carousel or react-spring + req.startsWith('react/') || + req.startsWith('react-dom/') || + req === 'react' || + req === 'react-dom' + ) { + return fromNext; + } + // Otherwise, return (null) to treat the module as internalizable + return; + }; + } +} + +/** + * Configures server-specific compiler options. + * + * @param compiler - The Webpack compiler instance. + * + * @remarks + * This function configures the compiler options for server builds. It turns off the compiler target on node + * builds because it adds its own chunk loading runtime module with NodeFederationPlugin and StreamingTargetPlugin. + * It also disables split chunks to prevent conflicts from occurring in the graph. + * + */ +export function configureServerCompilerOptions(compiler: Compiler): void { + // Turn off the compiler target on node builds because we add our own chunk loading runtime module + // with NodeFederationPlugin and StreamingTargetPlugin + compiler.options.target = false; + compiler.options.node = { + ...compiler.options.node, + global: false, + }; + compiler.options.resolve.conditionNames = [ + 'node', + 'import', + 'require', + 'default', + ]; + // no custom chunk rules + compiler.options.optimization.splitChunks = undefined; + + // solves strange issues where next doesnt create a runtime chunk + // might be related to if an api route exists or not + compiler.options.optimization.runtimeChunk = { + name: 'webpack-runtime', + }; +} diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts new file mode 100644 index 00000000000..628aa54b5f0 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts @@ -0,0 +1,176 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Zackary Jackson @ScriptedAlchemy +*/ +'use strict'; + +import type { + ModuleFederationPluginOptions, + NextFederationPluginExtraOptions, + NextFederationPluginOptions, + SharedObject, +} from '@module-federation/utilities'; +import { createRuntimeVariables } from '@module-federation/utilities'; +import type { Compiler, container } from 'webpack'; +import CopyFederationPlugin from '../CopyFederationPlugin'; +import { + applyRemoteDelegates, + getModuleFederationPluginConstructor, + retrieveDefaultShared, + applyPathFixes, +} from './next-fragments'; + +import { parseRemotes } from '../../internal'; +import AddRuntimeRequirementToPromiseExternal from '../AddRuntimeRequirementToPromiseExternalPlugin'; +import { exposeNextjsPages } from '../../loaders/nextPageMapLoader'; +import { removeUnnecessarySharedKeys } from './remove-unnecessary-shared-keys'; +import { setOptions } from './set-options'; +import { + validateCompilerOptions, + validatePluginOptions, +} from './validate-options'; +import { + applyServerPlugins, + configureServerCompilerOptions, + configureServerLibraryAndFilename, + handleServerExternals, +} from './apply-server-plugins'; +import { applyClientPlugins } from './apply-client-plugins'; + +/** + * NextFederationPlugin is a webpack plugin that handles Next.js application + * federation using Module Federation. + */ +export class NextFederationPlugin { + _options: ModuleFederationPluginOptions; + _extraOptions: NextFederationPluginExtraOptions; + + /** + * Constructs the NextFederationPlugin with the provided options. + * + * @param options The options to configure the plugin. + */ + constructor(options: NextFederationPluginOptions) { + const { mainOptions, extraOptions } = setOptions(options); + this._options = mainOptions; + this._extraOptions = extraOptions; + } + + apply(compiler: Compiler) { + // Validate the compiler options + const validCompile = validateCompilerOptions(compiler); + if (!validCompile) return; + // Validate the NextFederationPlugin options + validatePluginOptions(this._options); + + // Check if the compiler is for the server or client + const isServer = compiler.options.name === 'server'; + const { webpack } = compiler; + + // Apply the CopyFederationPlugin + new CopyFederationPlugin(isServer).apply(compiler); + + // If remotes are provided, parse them + if (this._options.remotes) { + // @ts-ignore + this._options.remotes = parseRemotes(this._options.remotes); + } + + // If shared modules are provided, remove unnecessary shared keys from the default share scope + if (this._options.shared) { + removeUnnecessarySharedKeys(this._options.shared as SharedObject); + } + + const ModuleFederationPlugin: container.ModuleFederationPlugin = + getModuleFederationPluginConstructor(isServer, compiler); + + const defaultShared = retrieveDefaultShared(isServer); + if (isServer) { + // Refactored server condition + configureServerCompilerOptions(compiler); + configureServerLibraryAndFilename(this._options); + + applyServerPlugins(compiler, this._options); + handleServerExternals(compiler, { + ...this._options, + shared: { ...defaultShared, ...this._options.shared }, + }); + } else { + applyClientPlugins(compiler, this._options, this._extraOptions); + } + + applyPathFixes(compiler, this._extraOptions); + + // @ts-ignore + const hostFederationPluginOptions: ModuleFederationPluginOptions = { + ...this._options, + runtime: false, + exposes: { + //something must be exposed in order to generate a remote entry, which is needed to kickstart runtime + './noop': require.resolve('../../federation-noop'), + ...(this._extraOptions.exposePages + ? exposeNextjsPages(compiler.options.context as string) + : {}), + ...this._options.exposes, + }, + remotes: { + //@ts-ignore + ...this._options.remotes, + }, + shared: { + ...defaultShared, + ...this._options.shared, + }, + }; + + if (this._extraOptions.debug) { + compiler.options.devtool = false; + } + compiler.options.output.uniqueName = this._options.name; + + // inject module hoisting system + applyRemoteDelegates(this._options, compiler); + //@ts-ignore + if (this._extraOptions.automaticAsyncBoundary) { + console.warn('[nextjs-mf]: automaticAsyncBoundary is deprecated'); + } + + //todo runtime variable creation needs to be applied for server as well. this is just for client + // TODO: this needs to be refactored into something more comprehensive. this is just a quick fix + new webpack.DefinePlugin({ + 'process.env.REMOTES': createRuntimeVariables(this._options.remotes), + 'process.env.CURRENT_HOST': JSON.stringify(this._options.name), + }).apply(compiler); + + // @ts-ignore + new ModuleFederationPlugin(hostFederationPluginOptions).apply(compiler); + if ( + Object.keys(this._options?.remotes || {}).length > 0 || + Object.keys(this._options?.exposes || {}).length > 0 + ) { + const commonOptions = { + ...hostFederationPluginOptions, + name: 'host_inner_ctn', + runtime: isServer ? 'webpack-runtime' : 'webpack', + filename: `host_inner_ctn.js`, + library: { + ...hostFederationPluginOptions.library, + name: this._options.name, + }, + shared: { + ...hostFederationPluginOptions.shared, + ...defaultShared, + }, + }; + + // @ts-ignore + new ModuleFederationPlugin({ + ...commonOptions, + }).apply(compiler); + } + + new AddRuntimeRequirementToPromiseExternal().apply(compiler); + } +} + +export default NextFederationPlugin; diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/next-fragments.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/next-fragments.ts new file mode 100644 index 00000000000..ab96f69fcee --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/next-fragments.ts @@ -0,0 +1,116 @@ +import type { Compiler } from 'webpack'; +import { container } from 'webpack'; +import path from 'path'; +import type { + ModuleFederationPluginOptions, + SharedObject, +} from '@module-federation/utilities'; +import { + DEFAULT_SHARE_SCOPE, + DEFAULT_SHARE_SCOPE_BROWSER, + getDelegates, +} from '../../internal'; +import { hasLoader, injectRuleLoader } from '../../loaders/helpers'; + +type ConstructableModuleFederationPlugin = new ( + options: ModuleFederationPluginOptions +) => container.ModuleFederationPlugin; + +/** + * Gets the appropriate ModuleFederationPlugin based on the environment. + * @param {boolean} isServer - A flag to indicate if the environment is server-side or not. + * @param {Compiler} compiler - The Webpack compiler instance. + * @returns {ModuleFederationPlugin | undefined} The ModuleFederationPlugin or undefined if not applicable. + */ +export function getModuleFederationPluginConstructor( + isServer: boolean, + compiler: Compiler +): ConstructableModuleFederationPlugin { + if (isServer) { + return require('@module-federation/node') + .NodeFederationPlugin as ConstructableModuleFederationPlugin; + } + return compiler.webpack.container + .ModuleFederationPlugin as unknown as ConstructableModuleFederationPlugin; +} + +/** + + Set up default shared values based on the environment. + @param isServer - Boolean indicating if the code is running on the server. + @returns The default share scope based on the environment. + */ +export const retrieveDefaultShared = (isServer: boolean): SharedObject => { + // If the code is running on the server, treat some Next.js internals as import false to make them external + // This is because they will be provided by the server environment and not by the remote container + if (isServer) { + return DEFAULT_SHARE_SCOPE; + } + // If the code is running on the client/browser, always bundle Next.js internals + return DEFAULT_SHARE_SCOPE_BROWSER; +}; + +/** + + Apply remote delegates. + + This function adds the remote delegates feature by configuring and injecting the appropriate loader that will look + for internal delegate hoist or delegate hoist container and load it using a custom delegateLoader. + Once loaded, it will then look for the available delegates that will be used to configure the remote + that the hoisted module will be dependent upon. + + @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance. + + @param {Compiler} compiler - The Webpack compiler instance. + */ +export function applyRemoteDelegates( + options: ModuleFederationPluginOptions, + compiler: Compiler +) { + if (options.remotes) { + // Get the available delegates + const delegates = getDelegates(options.remotes); + compiler.options.module.rules.push({ + enforce: 'pre', + test: [/_app/], + loader: require.resolve('../../loaders/patchDefaultSharedLoader'), + }); + // Add the delegate loader for hoist and container to the module rules + compiler.options.module.rules.push({ + enforce: 'pre', + test: [/internal-delegate-hoist/, /delegate-hoist-container/], + include: [ + compiler.context, + /internal-delegate-hoist/, + /delegate-hoist-container/, + //eslint-disable-next-line + /next[\/]dist/, + ], + loader: require.resolve('../../loaders/delegateLoader'), + options: { + delegates, + }, + }); + } +} + +// @ts-ignore +export const applyPathFixes = (compiler, options) => { + //@ts-ignore + compiler.options.module.rules.forEach((rule) => { + // next-image-loader fix which adds remote's hostname to the assets url + if (options.enableImageLoaderFix && hasLoader(rule, 'next-image-loader')) { + // childCompiler.options.module.parser.javascript?.url = 'relative'; + injectRuleLoader(rule, { + loader: require.resolve('../../loaders/fixImageLoader'), + }); + } + + // url-loader fix for which adds remote's hostname to the assets url + if (options.enableUrlLoaderFix && hasLoader(rule, 'url-loader')) { + injectRuleLoader({ + loader: require.resolve('../../loaders/fixUrlLoader'), + }); + } + }); +}; diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/regex-equal.test.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/regex-equal.test.ts new file mode 100644 index 00000000000..ea98b3ad1e7 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/regex-equal.test.ts @@ -0,0 +1,48 @@ +import { regexEqual } from './regex-equal'; + +describe('regexEqual', () => { + it('should return true for equal regex patterns', () => { + const regex1 = /abc/i; + const regex2 = /abc/i; + + const result = regexEqual(regex1, regex2); + + expect(result).toBe(true); + }); + + it('should return false for different regex patterns', () => { + const regex1 = /abc/i; + const regex2 = /def/i; + + const result = regexEqual(regex1, regex2); + + expect(result).toBe(false); + }); + + it('should return false for regex patterns with different flags', () => { + const regex1 = /abc/i; + const regex2 = /abc/g; + + const result = regexEqual(regex1, regex2); + + expect(result).toBe(false); + }); + + it('should return false for non-RegExp parameters', () => { + const regex1 = 'abc'; + const regex2 = /abc/i; + + const result = regexEqual(regex1, regex2); + + expect(result).toBe(false); + }); + + it('should return false for undefined parameters', () => { + const regex1 = undefined; + const regex2 = /abc/i; + + const result = regexEqual(regex1, regex2); + + expect(result).toBe(false); + }); +}); diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/regex-equal.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/regex-equal.ts new file mode 100644 index 00000000000..c73a59d9894 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/regex-equal.ts @@ -0,0 +1,32 @@ +import { RuleSetConditionAbsolute } from "webpack"; + +/** + * Compares two regular expressions to see if they are equal. + * + * @param x - The first regular expression to compare. + * @param y - The second regular expression to compare. + * @returns True if the regular expressions are equal, false otherwise. + * + * @remarks + * This function compares two regular expressions to see if they are equal in terms of their source, + * global, ignoreCase, and multiline properties. It is used to check if two regular expressions match + * the same pattern. + */ +export const regexEqual = ( + x: + | string + | RegExp + | ((value: string) => boolean) + | RuleSetConditionAbsolute[] + | undefined, + y: RegExp +): boolean => { + return ( + x instanceof RegExp && + y instanceof RegExp && + x.source === y.source && + x.global === y.global && + x.ignoreCase === y.ignoreCase && + x.multiline === y.multiline + ); +}; diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.test.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.test.ts new file mode 100644 index 00000000000..4d16f4e23c2 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.test.ts @@ -0,0 +1,45 @@ +import { removeUnnecessarySharedKeys } from './remove-unnecessary-shared-keys'; + +describe('removeUnnecessarySharedKeys', () => { + beforeEach(() => { + jest.spyOn(console, 'warn').mockImplementation(() => {}); + }); + + afterEach(() => { + jest.restoreAllMocks(); + }); + + it('should remove unnecessary shared keys from the given object', () => { + const shared: Record = { + react: '17.0.0', + 'react-dom': '17.0.0', + lodash: '4.17.21', + }; + + removeUnnecessarySharedKeys(shared); + + expect(shared).toEqual({ lodash: '4.17.21' }); + expect(console.warn).toHaveBeenCalled(); + }); + + it('should not remove keys that are not in the default share scope', () => { + const shared: Record = { + lodash: '4.17.21', + axios: '0.21.1', + }; + + removeUnnecessarySharedKeys(shared); + + expect(shared).toEqual({ lodash: '4.17.21', axios: '0.21.1' }); + expect(console.warn).not.toHaveBeenCalled(); + }); + + it('should not remove keys from an empty object', () => { + const shared: Record = {}; + + removeUnnecessarySharedKeys(shared); + + expect(shared).toEqual({}); + expect(console.warn).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.ts new file mode 100644 index 00000000000..96c8ef59f3a --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.ts @@ -0,0 +1,24 @@ +// Utility function to remove unnecessary shared keys from the default share scope +import { DEFAULT_SHARE_SCOPE } from "../../internal"; + +export function removeUnnecessarySharedKeys( + shared: Record +): void { + const warnings: string[] = Object.keys(shared).reduce( + (acc: string[], key: string) => { + if (DEFAULT_SHARE_SCOPE[key]) { + acc.push( + `[nextjs-mf] You are sharing ${key} from the default share scope. This is not necessary and can be removed.` + ); + // Use a type assertion to inform TypeScript that 'key' can be used as an index for the 'shared' object + delete (shared as { [key: string]: unknown })[key]; + } + return acc; + }, + [] + ); + + if (warnings.length > 0) { + console.warn('%c' + warnings.join('\n'), 'color: red'); + } +} diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/set-options.test.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/set-options.test.ts new file mode 100644 index 00000000000..99bd9bc6c76 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/set-options.test.ts @@ -0,0 +1,73 @@ +import { setOptions } from './set-options'; +import { + ModuleFederationPluginOptions, + NextFederationPluginExtraOptions, + NextFederationPluginOptions, +} from '@module-federation/utilities'; + +describe('setOptions', () => { + it('should set main and extra options with default values', () => { + const options: NextFederationPluginOptions = { + name: 'mockApp', + library: { type: 'var', name: 'mockApp' }, + filename: 'remoteEntry.js', + exposes: {}, + shared: {}, + extraOptions: {}, + }; + + const { mainOptions, extraOptions } = setOptions(options); + + const expectedMainOptions: ModuleFederationPluginOptions = { + ...mainOptions, + }; + + const expectedExtraOptions: NextFederationPluginExtraOptions = { + automaticPageStitching: false, + enableImageLoaderFix: false, + enableUrlLoaderFix: false, + skipSharingNextInternals: false, + debug: false + }; + + expect(mainOptions).toEqual(expectedMainOptions); + expect(extraOptions).toEqual(expectedExtraOptions); + }); + + it('should set main and extra options with provided values', () => { + const options: NextFederationPluginOptions = { + name: 'mockApp', + library: { type: 'var', name: 'mockApp' }, + filename: 'remoteEntry.js', + exposes: {}, + shared: {}, + extraOptions: { + automaticPageStitching: true, + enableImageLoaderFix: true, + enableUrlLoaderFix: true, + skipSharingNextInternals: true, + }, + }; + + const { mainOptions, extraOptions } = setOptions(options); + + const expectedMainOptions: ModuleFederationPluginOptions = { + name: 'mockApp', + library: { type: 'var', name: 'mockApp' }, + filename: 'remoteEntry.js', + exposes: {}, + shared: {}, + }; + + const expectedExtraOptions: NextFederationPluginExtraOptions = { + automaticPageStitching: true, + enableImageLoaderFix: true, + enableUrlLoaderFix: true, + skipSharingNextInternals: true, + debug:false + }; + + expect(mainOptions).toEqual(expectedMainOptions); + expect(extraOptions).toEqual(expectedExtraOptions); + }); +}); diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/set-options.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/set-options.ts new file mode 100644 index 00000000000..c17198408f9 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/set-options.ts @@ -0,0 +1,40 @@ +import { + ModuleFederationPluginOptions, + NextFederationPluginExtraOptions, + NextFederationPluginOptions, +} from '@module-federation/utilities'; + +/** + * Utility function to set the main and extra options. + * + * @param options - The NextFederationPluginOptions instance. + * @returns An object containing the main options and extra options. + * + * @remarks + * This function sets the main and extra options for NextFederationPlugin. It splits the options object into + * the main options and extra options, and sets default values for any options that are not defined. The default + * extra options are: + * - automaticPageStitching: false + * - enableImageLoaderFix: false + * - enableUrlLoaderFix: false + * - skipSharingNextInternals: false + */ +export function setOptions(options: NextFederationPluginOptions): { + mainOptions: ModuleFederationPluginOptions; + extraOptions: NextFederationPluginExtraOptions; +} { + const { extraOptions, ...mainOpts } = options; + + const defaultExtraOptions: NextFederationPluginExtraOptions = { + automaticPageStitching: false, + enableImageLoaderFix: false, + enableUrlLoaderFix: false, + skipSharingNextInternals: false, + debug: false, + }; + + return { + mainOptions: mainOpts, + extraOptions: { ...defaultExtraOptions, ...extraOptions }, + }; +} diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/validate-options.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/validate-options.ts new file mode 100644 index 00000000000..59761293807 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/validate-options.ts @@ -0,0 +1,48 @@ +import { Compiler } from "webpack"; +import { ModuleFederationPluginOptions } from "@module-federation/utilities"; + +/** + * Utility function to validate compiler options. + * + * @param compiler - The Webpack compiler instance. + * @returns True if the compiler options are valid, false otherwise. + * + * @remarks + * This function validates the options passed to the Webpack compiler. It throws an error if the name + * option is not defined in the options. It also checks if the name option is set to either "server" or + * "client", as Module Federation is only applied to the main server and client builds in Next.js. + */ +export function validateCompilerOptions(compiler: Compiler): boolean { + // Throw an error if the name option is not defined in the options + if (!compiler.options.name) { + throw new Error("name is not defined in Compiler options"); + } + + // Only apply Module Federation to the main server and client builds in Next.js + return ["server", "client"].includes(compiler.options.name); +} + +/** + * Utility function to validate NextFederationPlugin options. + * + * @param options - The ModuleFederationPluginOptions instance. + * + * @remarks + * This function validates the options passed to NextFederationPlugin. It throws an error if the filename + * option is not defined in the options. + * + * A requirement for using Module Federation is that a name must be specified. + */ +export function validatePluginOptions( + options: ModuleFederationPluginOptions +): void { + // Throw an error if the filename option is not defined in the options + if (!options.filename) { + throw new Error("filename is not defined in NextFederation options"); + } + + // A requirement for using Module Federation is that a name must be specified + if (!options.name) { + throw new Error("Module federation \"name\" option must be specified"); + } +} diff --git a/packages/nextjs-mf/src/plugins/RemoveRRRuntimePlugin.ts b/packages/nextjs-mf/src/plugins/RemoveRRRuntimePlugin.ts deleted file mode 100644 index 35609186102..00000000000 --- a/packages/nextjs-mf/src/plugins/RemoveRRRuntimePlugin.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Compilation, Compiler } from 'webpack'; - -export class RemoveRRRuntimePlugin { - apply(compiler: Compiler) { - const { webpack } = compiler; - - // only impacts dev mode - dont waste the memory during prod build - if (compiler.options.mode === 'development') { - compiler.hooks.thisCompilation.tap( - 'RemoveRRRuntimePlugin', - (compilation) => { - compilation.hooks.processAssets.tap( - { - name: 'RemoveRRRuntimePlugin', - // FIXME: Is this state or stage? - // Webpack docs mentions it as 'stage'. - stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE, - }, - (assets) => { - //can this be improved? I need react refresh not to cause global collision in dev mode - Object.keys(assets).forEach((filename) => { - if (!(filename.endsWith('.js') || filename.endsWith('.mjs'))) { - return; - } - const asset = compilation.getAsset(filename); - // easiest way to solve it is to prevent react refresh helpers from running when its a federated module chunk - const newSource = (asset?.source.source() as string).replace( - /RefreshHelpers/g, - 'NoExist' - ); - const updatedAsset = new webpack.sources.RawSource(newSource); - - if (asset) { - compilation.updateAsset(filename, updatedAsset); - } else { - compilation.emitAsset(filename, updatedAsset); - } - }); - } - ); - } - ); - } - } -} - -export default RemoveRRRuntimePlugin; diff --git a/packages/nextjs-mf/src/plugins/container/InvertedContainerPlugin.ts b/packages/nextjs-mf/src/plugins/container/InvertedContainerPlugin.ts new file mode 100644 index 00000000000..64e7a7ac570 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/container/InvertedContainerPlugin.ts @@ -0,0 +1,256 @@ +import type { Chunk, Compiler, Module } from 'webpack'; +import { RawSource } from 'webpack-sources'; +//@ts-ignore +import type { ModuleFederationPluginOptions } from '../types'; +import InvertedContainerRuntimeModule from './InvertedContainerRuntimeModule'; +import { RuntimeGlobals, Compilation } from 'webpack'; +import Template from '../../../utils/Template'; +import RemoveEagerModulesFromRuntimePlugin from './RemoveEagerModulesFromRuntimePlugin'; +/** + * This interface includes additional fields specific to the plugin's behavior. + */ +interface InvertedContainerOptions extends ModuleFederationPluginOptions { + container?: string; + remotes: Record; // A map of remote modules to their URLs. + runtime: string; // The name of the current module. + debug?: boolean | undefined; // A flag to enable debug logging. +} + +/** + * InvertedContainerPlugin is a Webpack plugin that handles loading of chunks in a federated module. + */ +class InvertedContainerPlugin { + private options: InvertedContainerOptions; + + /** + * Constructor for the InvertedContainerPlugin. + * @param {InvertedContainerOptions} options - Plugin configuration options. + */ + constructor(options: { + container: string | undefined; + runtime: string; + remotes: Record; + debug: boolean | undefined + }) { + this.options = options || ({} as InvertedContainerOptions); + } + + /** + * Resolves the container module for the given compilation. + * @param {Compilation} compilation - Webpack compilation instance. + * @returns {Module | undefined} - The container module or undefined if not found. + */ + resolveContainerModule(compilation: Compilation) { + if (!this.options.container) { + return undefined; + } + const container = compilation.entrypoints + .get(this.options.container as string) + ?.getRuntimeChunk?.(); + if (!container) return undefined; + const entrymodule = + compilation.chunkGraph.getChunkEntryModulesIterable(container); + for (const module of entrymodule) { + return module; + } + return undefined; + } + + /** + * Apply method for the Webpack plugin, handling the plugin logic and hooks. + * @param {Compiler} compiler - Webpack compiler instance. + */ + apply(compiler: Compiler) { + new RemoveEagerModulesFromRuntimePlugin({ + container: this.options.container, + debug: this.options.debug, + }).apply(compiler); + const { Template, javascript } = compiler.webpack; + // Hook into the compilation process. + compiler.hooks.thisCompilation.tap( + 'InvertedContainerPlugin', + (compilation) => { + // Create a WeakSet to store chunks that have already been processed. + const onceForChunkSet = new WeakSet(); + + // Define a handler function to be called for each chunk in the compilation. + const handler = (chunk: Chunk, set: Set) => { + // If the chunk has already been processed, skip it. + if (onceForChunkSet.has(chunk)) return; + set.add(RuntimeGlobals.onChunksLoaded); + + // Mark the chunk as processed by adding it to the WeakSet. + onceForChunkSet.add(chunk); + + if (chunk.hasRuntime()) { + // Add an InvertedContainerRuntimeModule to the chunk, which handles + // the runtime logic for loading remote modules. + compilation.addRuntimeModule( + chunk, + new InvertedContainerRuntimeModule(set, this.options, { + webpack: compiler.webpack, + debug: this.options.debug, + }) + ); + } + }; + + compilation.hooks.additionalChunkRuntimeRequirements.tap( + 'InvertedContainerPlugin', + handler + ); + + compilation.hooks.optimizeChunks.tap( + 'InvertedContainerPlugin', + (chunks) => { + const containerEntryModule = + this.resolveContainerModule(compilation); + + if (!containerEntryModule) return; + for (const chunk of chunks) { + if ( + !compilation.chunkGraph.isModuleInChunk( + containerEntryModule, + chunk + ) && + chunk.hasRuntime() + ) { + compilation.chunkGraph.connectChunkAndModule( + chunk, + containerEntryModule + ); + } + } + } + ); + + const hooks = + javascript.JavascriptModulesPlugin.getCompilationHooks(compilation); + + compilation.hooks.processAssets.tap( + { + name: 'InvertedContainerPlugin', + stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS, + }, + (assets) => { + for (const chunk of compilation.chunks) { + for (const file of chunk.files) { + const asset = compilation.getAsset(file); + if (asset) { + let source = asset.source.source(); + const chunkID = + typeof chunk.id === 'string' + ? JSON.stringify(chunk.id) + : chunk.id; + // Inject the chunk name at the beginning of the file + source = source + .toString() + //@ts-ignore + .replace('__INSERT_CH_ID__MF__', chunkID); + const updatedSource = new RawSource(source); + + //@ts-ignore + compilation.updateAsset(file, updatedSource); + } + } + } + } + ); + + hooks.renderStartup.tap( + 'InvertedContainerPlugin', + //@ts-ignore + (source, renderContext) => { + if ( + !renderContext || + //@ts-ignore + renderContext?._name || + !renderContext?.debugId || + !compilation.chunkGraph.isEntryModule(renderContext) || + //@ts-ignore + renderContext?.rawRequest?.includes('pages/api') + ) { + // skip empty modules, container entry, and anything that doesnt have a moduleid or is not an entrypoint module. + return source; + } + + const { runtimeTemplate } = compilation; + + const replaceSource = source.source().toString().split('\n'); + + const searchString = '__webpack_exec__'; + const replaceString = '__webpack_exec_proxy__'; + + const originalExec = replaceSource.findIndex((s: string) => + s.includes(searchString) + ); + + if (originalExec === -1) { + return source; + } + + const firstHalf = replaceSource.slice(0, originalExec + 1); + const secondHalf = replaceSource.slice( + originalExec + 1, + replaceSource.length + ); + + const originalRuntimeCode = firstHalf + .join('\n') + .replace(searchString, replaceString); + + const fancyTemplate = Template.asString([ + runtimeTemplate.returningFunction( + Template.asString( + [ + '__webpack_require__.own_remote.then(', + runtimeTemplate.returningFunction( + Template.asString([ + 'Promise.all([', + Template.indent( + [ + 'Promise.all(__webpack_require__.initRemotes)', + 'Promise.all(__webpack_require__.initConsumes)', + ].join(',\n') + ), + '])', + ]) + ), + ').then(', + runtimeTemplate.returningFunction( + Template.asString([`${replaceString}(moduleId)`]) + ), + ')', + ].join('') + ), + 'moduleId' + ), + ]); + + const wholeTem = Template.asString([ + `var ${searchString} =`, + fancyTemplate, + ]); + + return Template.asString([ + '', + 'var currentChunkId = __INSERT_CH_ID__MF__;', + `if(currentChunkId) {`, + Template.indent([ + `if(__webpack_require__.getEagerSharedForChunkId) {__webpack_require__.getEagerSharedForChunkId(currentChunkId,__webpack_require__.initConsumes)}`, + `if(__webpack_require__.getEagerRemotesForChunkId) {__webpack_require__.getEagerRemotesForChunkId(currentChunkId,__webpack_require__.initRemotes)}`, + ]), + '}', + originalRuntimeCode, + wholeTem, + ...secondHalf, + '', + ]); + } + ); + } + ); + } +} + +export default InvertedContainerPlugin; diff --git a/packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.test.ts b/packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.test.ts new file mode 100644 index 00000000000..dd9a300c86f --- /dev/null +++ b/packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.test.ts @@ -0,0 +1,85 @@ +import type { Compiler, Compilation } from 'webpack'; +import InvertedContainerRuntimeModule from './InvertedContainerRuntimeModule'; + +describe('InvertedContainerRuntimeModule', () => { + let compiler: Compiler; + let compilation: Compilation; + let runtimeModule: InvertedContainerRuntimeModule; + + beforeEach(() => { + // Create a mock compiler object + compiler = { + webpack: { + RuntimeGlobals: { + global: 'global', + }, + javascript: { + JavascriptModulesPlugin: { + chunkHasJs: jest.fn(), + }, + }, + }, + } as unknown as Compiler; + + // Rest of the setup... + // Create a mock compilation object + compilation = { + entrypoints: new Map(), + options: { + node: { + global: true, + }, + }, + } as unknown as Compilation; + + // Initialize the runtime module with some options + runtimeModule = new InvertedContainerRuntimeModule( + new Set(), + { + container: 'testContainer', + runtime: 'testRuntime', + remotes: { testRemote: 'http://localhost/testRemote' }, + }, + { + webpack: compiler.webpack, + } + ); + + // Assign compilation and chunkGraph to runtimeModule for testing purposes + runtimeModule.compilation = compilation; + runtimeModule.chunkGraph = { + getChunkConditionMap: jest.fn(), + } as unknown as any; + runtimeModule.chunk = {} as any; + }); + + it('should be defined', () => { + expect(runtimeModule).toBeDefined(); + }); + //TODO: fix this test + xit('should generate runtime code for container module', () => { + const containerChunk = { + name: 'testContainer', + }; + + const containerEntryModule = { + _name: 'testEntryModule', + id: 123, + }; + + compilation.entrypoints.set('testContainer', { + //@ts-ignore + getRuntimeChunk: () => containerChunk, + }); + //@ts-ignore + containerChunk.entryModule = containerEntryModule; + //@ts-ignore + runtimeModule.options.runtime = 'testContainer'; + + const generatedCode = runtimeModule.generate(); + + expect(generatedCode).toContain('__remote_scope__'); + expect(generatedCode).toContain('testEntryModule'); + expect(generatedCode).toContain('123'); + }); +}); diff --git a/packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.ts b/packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.ts new file mode 100644 index 00000000000..e01a4809096 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.ts @@ -0,0 +1,769 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* + MIT License http://www.opensource.org/licenses/mit-license.php +*/ + +'use strict'; + +import type { Chunk, Compiler, Module } from 'webpack'; +import { RuntimeModule } from 'webpack'; +import { + parseVersionRuntimeCode, + versionLtRuntimeCode, + rangeToStringRuntimeCode, + satisfyRuntimeCode, + //@ts-ignore +} from 'webpack/lib/util/semver'; +/** + * Interface for InvertedContainerRuntimeModuleOptions, containing + * options for the InvertedContainerRuntimeModule class. + */ +interface InvertedContainerRuntimeModuleOptions { + runtime: string; + remotes: Record; // A map of remote modules to their URLs. + name?: string; // The name of the current module. + debug?: boolean; // A flag to enable verbose logging. + container?: string; // The name of the container module. +} + +/** + * Interface for ChunkLoadingContext, containing Webpack-related properties. + */ +interface ChunkLoadingContext { + webpack: Compiler['webpack']; + debug?: boolean; +} + +/** + * InvertedContainerRuntimeModule is a Webpack runtime module that generates + * the runtime code needed for loading federated modules in an inverted container. + */ +class InvertedContainerRuntimeModule extends RuntimeModule { + private runtimeRequirements: Set; + private options: InvertedContainerRuntimeModuleOptions; + private chunkLoadingContext: ChunkLoadingContext; + + /** + * Constructor for the InvertedContainerRuntimeModule. + * @param {Set} runtimeRequirements - A set of runtime requirement strings. + * @param {InvertedContainerRuntimeModuleOptions} options - Runtime module options. + * @param {ChunkLoadingContext} chunkLoadingContext - Chunk loading context. + */ + constructor( + runtimeRequirements: Set, + options: InvertedContainerRuntimeModuleOptions, + chunkLoadingContext: ChunkLoadingContext + ) { + super('inverted container startup', RuntimeModule.STAGE_ATTACH); + this.runtimeRequirements = runtimeRequirements; + + this.options = options; + this.chunkLoadingContext = chunkLoadingContext; + } + + resolveContainerModule() { + const container = this.compilation.entrypoints + .get(this.options.container as string) + ?.getRuntimeChunk?.(); + if (!container) return; + const entryModules = + this.compilation.chunkGraph.getChunkEntryModulesIterable(container); + + let entryModule; + for (const module of entryModules) { + entryModule = module; + break; + } + + return entryModule; + } + + mapShared() { + const { + runtimeTemplate, + chunkGraph, + codeGenerationResults, + entrypoints, + compiler, + } = this.compilation; + const { RuntimeGlobals, Template } = compiler.webpack; + const chunkToModuleMapping = {}; + /** @type {Map} */ + const moduleIdToSourceMapping = new Map(); + const moduleIdToSourceChunkID = new Map(); + // @ts-ignore + const initialConsumes = []; + + /** + * + * @param {Iterable} modules modules + * @param {Chunk} chunk the chunk + * @param {(string | number)[]} list list of ids + */ + //@ts-ignore + const addShared = (modules, chunk, list) => { + for (const m of modules) { + const module = /** @type {ConsumeSharedModule} */ m; + const id = chunkGraph.getModuleId(module); + list.push(id); + moduleIdToSourceMapping.set( + id, + codeGenerationResults.getSource( + module, + chunk.runtime, + 'consume-shared' + ) + ); + } + }; + // @ts-ignore + const addModules = (modules, chunk, list) => { + for (const m of modules) { + const module = /** @type {ConsumeSharedModule} */ m; + const id = chunkGraph.getModuleId(module); + list.push(id); + const moduleOrigin = module.options.importResolved; + const filter = chunkGraph.getChunkModuleIdMap( + chunk, + (module) => { + // @ts-ignore + return module?.resource === moduleOrigin; + }, + true + ); + + moduleIdToSourceChunkID.set(id, filter); + } + }; + + for (const entrypointModule of entrypoints.values()) { + const entrypoint = entrypointModule.getEntrypointChunk(); + if (entrypoint.hasRuntime()) continue; + + // for (const entryChunks of entrypoint.getAllInitialChunks()) {} + // @ts-ignore + for (const chunk of entrypoint.getAllAsyncChunks()) { + //if(chunk.hasEntryModule()) continue + const modules = chunkGraph.getChunkModulesIterableBySourceType( + chunk, + 'consume-shared' + ); + if (!modules) continue; + + //@ts-ignore + // addModules(modules, chunk, (chunkToModuleMapping[chunk.id] = [])); + } + // @ts-ignore + for (const chunk of entrypoint.getAllInitialChunks()) { + // if(chunk.hasEntryModule()) continue + const modules = chunkGraph.getChunkModulesIterableBySourceType( + chunk, + 'consume-shared' + ); + if (!modules) continue; + // @ts-ignore + addModules(modules, chunk, (chunkToModuleMapping[chunk.id] = [])); + //@ts-ignore + addShared(modules, chunk, initialConsumes); + } + } + + if ( + moduleIdToSourceMapping.size === 0 || + moduleIdToSourceChunkID.size === 0 + ) { + return ''; + } + return Template.asString([ + parseVersionRuntimeCode(runtimeTemplate), + versionLtRuntimeCode(runtimeTemplate), + rangeToStringRuntimeCode(runtimeTemplate), + satisfyRuntimeCode(runtimeTemplate), + `var ensureExistence = ${runtimeTemplate.basicFunction('scopeName, key', [ + `var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`, + `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) throw new Error("Shared module " + key + " doesn't exist in shared scope " + scopeName);`, + 'return scope;', + ])};`, + `var findVersion = ${runtimeTemplate.basicFunction('scope, key', [ + 'var versions = scope[key];', + `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction( + 'a, b', + ['return !a || versionLt(a, b) ? b : a;'] + )}, 0);`, + 'return key && versions[key]', + ])};`, + `var findSingletonVersionKey = ${runtimeTemplate.basicFunction( + 'scope, key', + [ + 'var versions = scope[key];', + `return Object.keys(versions).reduce(${runtimeTemplate.basicFunction( + 'a, b', + ['return !a || (!versions[a].loaded && versionLt(a, b)) ? b : a;'] + )}, 0);`, + ] + )};`, + `var getInvalidSingletonVersionMessage = ${runtimeTemplate.basicFunction( + 'scope, key, version, requiredVersion', + [ + `return "Unsatisfied version " + version + " from " + (version && scope[key][version].from) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"`, + ] + )};`, + `var getSingleton = ${runtimeTemplate.basicFunction( + 'scope, scopeName, key, requiredVersion', + [ + 'var version = findSingletonVersionKey(scope, key);', + 'return get(scope[key][version]);', + ] + )};`, + `var getSingletonVersion = ${runtimeTemplate.basicFunction( + 'scope, scopeName, key, requiredVersion', + [ + 'var version = findSingletonVersionKey(scope, key);', + 'if (!satisfy(requiredVersion, version)) ' + + 'typeof console !== "undefined" && console.warn && console.warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));', + 'return get(scope[key][version]);', + ] + )};`, + `var getStrictSingletonVersion = ${runtimeTemplate.basicFunction( + 'scope, scopeName, key, requiredVersion', + [ + 'var version = findSingletonVersionKey(scope, key);', + 'if (!satisfy(requiredVersion, version)) ' + + 'throw new Error(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));', + 'return get(scope[key][version]);', + ] + )};`, + `var findValidVersion = ${runtimeTemplate.basicFunction( + 'scope, key, requiredVersion', + [ + 'var versions = scope[key];', + `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction( + 'a, b', + [ + 'if (!satisfy(requiredVersion, b)) return a;', + 'return !a || versionLt(a, b) ? b : a;', + ] + )}, 0);`, + 'return key && versions[key]', + ] + )};`, + `var getInvalidVersionMessage = ${runtimeTemplate.basicFunction( + 'scope, scopeName, key, requiredVersion', + [ + 'var versions = scope[key];', + 'return "No satisfying version (" + rangeToString(requiredVersion) + ") of shared module " + key + " found in shared scope " + scopeName + ".\\n" +', + `"Available versions: " + Object.keys(versions).map(${runtimeTemplate.basicFunction( + 'key', + ['return key + " from " + versions[key].from;'] + )}).join(", ");`, + ] + )};`, + `var getValidVersion = ${runtimeTemplate.basicFunction( + 'scope, scopeName, key, requiredVersion', + [ + 'var entry = findValidVersion(scope, key, requiredVersion);', + 'if(entry) return get(entry);', + 'throw new Error(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));', + ] + )};`, + `var warnInvalidVersion = ${runtimeTemplate.basicFunction( + 'scope, scopeName, key, requiredVersion', + [ + 'typeof console !== "undefined" && console.warn && console.warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));', + ] + )};`, + `var get = ${runtimeTemplate.basicFunction('entry', [ + 'entry.loaded = 1;', + 'return entry.get()', + ])};`, + `var init = ${runtimeTemplate.returningFunction( + Template.asString([ + 'function(scopeName, a, b, c) {', + Template.indent([ + `var promise = ${RuntimeGlobals.initializeSharing}(scopeName);`, + `if (promise && promise.then) return promise.then(fn.bind(fn, scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c));`, + `return fn(scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c);`, + ]), + '}', + ]), + 'fn' + )};`, + '', + `var load = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key', + [ + 'ensureExistence(scopeName, key);', + 'return get(findVersion(scope, key));', + ] + )});`, + `var loadFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key, fallback', + [ + `return scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) ? get(findVersion(scope, key)) : fallback();`, + ] + )});`, + `var loadVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key, version', + [ + 'ensureExistence(scopeName, key);', + 'return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));', + ] + )});`, + `var loadSingleton = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key', + [ + 'ensureExistence(scopeName, key);', + 'return getSingleton(scope, scopeName, key);', + ] + )});`, + `var loadSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key, version', + [ + 'ensureExistence(scopeName, key);', + 'return getSingletonVersion(scope, scopeName, key, version);', + ] + )});`, + `var loadStrictVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key, version', + [ + 'ensureExistence(scopeName, key);', + 'return getValidVersion(scope, scopeName, key, version);', + ] + )});`, + `var loadStrictSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key, version', + [ + 'ensureExistence(scopeName, key);', + 'return getStrictSingletonVersion(scope, scopeName, key, version);', + ] + )});`, + `var loadVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key, version, fallback', + [ + `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`, + 'return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));', + ] + )});`, + `var loadSingletonFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key, fallback', + [ + `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`, + 'return getSingleton(scope, scopeName, key);', + ] + )});`, + `var loadSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key, version, fallback', + [ + `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`, + 'return getSingletonVersion(scope, scopeName, key, version);', + ] + )});`, + `var loadStrictVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key, version, fallback', + [ + `var entry = scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) && findValidVersion(scope, key, version);`, + `return entry ? get(entry) : fallback();`, + ] + )});`, + `var loadStrictSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction( + 'scopeName, scope, key, version, fallback', + [ + `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`, + 'return getStrictSingletonVersion(scope, scopeName, key, version);', + ] + )});`, + 'var installedModules = __webpack_require__.installedModules', + 'var moduleToHandlerMapping = {', + Template.indent( + Array.from( + moduleIdToSourceMapping, + ([key, source]) => `${JSON.stringify(key)}: ${source.source()}` + ).join(',\n') + ), + '};', + 'var listOfInitialIds = {', + Template.indent( + Array.from(moduleIdToSourceChunkID, ([key, chunkIds]) => { + return `${JSON.stringify(key)}: ${JSON.stringify( + Object.keys(chunkIds) + )}`; + }).join(',\n') + ), + '};', + + initialConsumes.length > 0 + ? Template.asString([ + //@ts-ignore + `var initialConsumes = ${JSON.stringify( + //@ts-ignore + Array.from(new Set(initialConsumes)) + )};`, + // `initialConsumes.forEach(${runtimeTemplate.basicFunction('id', [ + // `${ + // RuntimeGlobals.moduleFactories + // }[id] = ${runtimeTemplate.basicFunction('module', [ + // '// Handle case when module is used sync', + // 'installedModules[id] = 0;', + // `delete ${RuntimeGlobals.moduleCache}[id];`, + // 'var factory = moduleToHandlerMapping[id]();', + // 'if(typeof factory !== "function") throw new Error("Shared module is not available for eager consumption: " + id);', + // `module.exports = factory();`, + // ])}`, + // ])});`, + ]) + : '// no consumes in initial chunks', + // this._runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers) + Template.asString([ + `var chunkMapping = ${JSON.stringify(chunkToModuleMapping, null, '')};`, + `__webpack_require__.getEagerSharedForChunkId = ${runtimeTemplate.basicFunction( + 'chunkId, promises', + [ + `if(${RuntimeGlobals.hasOwnProperty}(chunkMapping, chunkId)) {`, + Template.indent([ + `chunkMapping[chunkId].forEach(${runtimeTemplate.basicFunction( + 'id', + [ + `if(${RuntimeGlobals.hasOwnProperty}(installedModules, id)) return promises.push(installedModules[id]);`, + `if(typeof ${RuntimeGlobals.moduleCache}[id] === 'object') { + ${RuntimeGlobals.moduleCache}[id].hot.removeDisposeHandler() + ${RuntimeGlobals.moduleCache}[id].hot.addDisposeHandler(function (args){ + + delete ${RuntimeGlobals.moduleCache}[id] + + + ${RuntimeGlobals.moduleFactories}[id] = function(module) { + return module.exports = globalThis.factoryTracker[id] + } + }) + + }`, + `var onFactory = ${runtimeTemplate.basicFunction('factory', [ + 'installedModules[id] = 0;', + `${ + RuntimeGlobals.moduleFactories + }[id] = ${runtimeTemplate.basicFunction('module', [ + `delete ${RuntimeGlobals.moduleCache}[id];`, + 'globalThis.factoryTracker[id] = module.exports = factory();', + ])}`, + ])};`, + `var onError = ${runtimeTemplate.basicFunction('error', [ + 'delete installedModules[id];', + this.options.debug + ? "console.error('on error',id, error)" + : '', + `${ + RuntimeGlobals.moduleFactories + }[id] = ${runtimeTemplate.basicFunction('module', [ + `delete ${RuntimeGlobals.moduleCache}[id];`, + 'throw error;', + ])}`, + ])};`, + 'try {', + Template.indent([ + 'var promise = moduleToHandlerMapping[id]();', + 'if(promise.then) {', + Template.indent( + "promises.push(installedModules[id] = promise.then(onFactory)['catch'](onError));" + ), + '} else onFactory(promise);', + ]), + '} catch(e) { onError(e); }', + ] + )});`, + ]), + '}', + ] + )}`, + ]), + ]); + } + //@ts-ignore + mapChunks() { + // @ts-ignore + const { chunkGraph, compilation } = this; + const { runtimeTemplate, moduleGraph, entrypoints, compiler } = compilation; + const { RuntimeGlobals, Template } = compiler.webpack; + const chunkToRemotesMapping: { [key: string]: number[] } = {}; + const idToExternalAndNameMapping: { + [key: string]: [string, string, number]; + } = {}; + + //@ts-ignore + for (const entrypointModule of entrypoints.values()) { + const entrypoint = entrypointModule.getEntrypointChunk(); + if (entrypoint.hasRuntime()) continue; + + for (const chunk of entrypoint.getAllInitialChunks()) { + const modules = chunkGraph.getChunkModulesIterableBySourceType( + chunk, + 'remote' + ) as Module[]; + if (!modules) continue; + + const remotes: (string | number)[] = (chunkToRemotesMapping[ + chunk.id || chunk.name + ] = []); + //@ts-ignore + for (const m of modules) { + const module = m; + //@ts-ignore + const name = module.internalRequest; + + const id = chunkGraph.getModuleId(module); + //@ts-ignore + const shareScope = module.shareScope; + const dep = module.dependencies[0]; + const externalModule = moduleGraph.getModule(dep); + const externalModuleId = + externalModule && chunkGraph.getModuleId(externalModule); + remotes.push(id); + //@ts-ignore + idToExternalAndNameMapping[id] = [shareScope, name, externalModuleId]; + } + } + } + + return Template.asString([ + `var remoteMapping = ${JSON.stringify(chunkToRemotesMapping, null, '')};`, + `var idToExternalAndNameMapping = ${JSON.stringify( + idToExternalAndNameMapping, + null, + '' + )};`, + 'globalThis.factoryTracker = globalThis.factoryTracker || {}', + `__webpack_require__.getEagerRemotesForChunkId = ${runtimeTemplate.basicFunction( + 'chunkId, promises', + [ + ` + if(${RuntimeGlobals.hasOwnProperty}(remoteMapping, chunkId)) {`, + Template.indent([ + `remoteMapping[chunkId].forEach(${runtimeTemplate.basicFunction( + 'id', + [ + `if(typeof ${RuntimeGlobals.moduleCache}[id] === 'object') { + ${RuntimeGlobals.moduleCache}[id].hot.removeDisposeHandler() + ${RuntimeGlobals.moduleCache}[id].hot.addDisposeHandler(function (args){ + + ${RuntimeGlobals.moduleCache}[id] = globalThis.factoryTracker[id]; + ${RuntimeGlobals.moduleFactories}[id] = function(module) { + return module.exports = globalThis.factoryTracker[id] + } + }) + + }`, + `var getScope = ${RuntimeGlobals.currentRemoteGetScope};`, + 'if(!getScope) getScope = [];', + 'var data = idToExternalAndNameMapping[id];', + 'if(getScope.indexOf(data) >= 0) return;', + 'getScope.push(data);', + `if(data.p) return promises.push(data.p);`, + `var onError = ${runtimeTemplate.basicFunction('error', [ + 'if(!error) error = new Error("Container missing");', + 'if(typeof error.message === "string")', + Template.indent( + `error.message += '\\nwhile loading "' + data[1] + '" from ' + data[2];` + ), + `${ + RuntimeGlobals.moduleFactories + }[id] = ${runtimeTemplate.basicFunction('', [ + 'throw error;', + ])}`, + 'data.p = 0;', + ])};`, + `var handleFunction = ${runtimeTemplate.basicFunction( + 'fn, arg1, arg2, d, next, first', + [ + 'try {', + Template.indent([ + 'var promise = fn(arg1, arg2);', + 'if(promise && promise.then) {', + Template.indent([ + `var p = promise.then(${runtimeTemplate.returningFunction( + 'next(result, d)', + 'result' + )}, onError);`, + `if(first) promises.push(data.p = p); else return p;`, + ]), + '} else {', + Template.indent(['return next(promise, d, first);']), + '}', + ]), + '} catch(error) {', + Template.indent(['onError(error);']), + '}', + ] + )}`, + `var onExternal = ${runtimeTemplate.basicFunction( + ['external', '_', 'first'], + ` + return external ? handleFunction(${RuntimeGlobals.initializeSharing}, data[0], 0, external, onInitialized, first) : onError()` + )};`, + `var onInitialized = ${runtimeTemplate.returningFunction( + `handleFunction(external.get, data[1], getScope, 0, onFactory, first)`, + '_, external, first' + )};`, + `var onFactory = ${runtimeTemplate.basicFunction('factory', [ + 'data.p = 1;', + `${ + RuntimeGlobals.moduleFactories + }[id] = ${runtimeTemplate.basicFunction('module', [ + 'globalThis.factoryTracker[id] = module.exports = (globalThis.factoryTracker[id] || factory());', + ])}`, + ])};`, + 'handleFunction(__webpack_require__, data[2], 0, 0, onExternal, 1);', + ] + )});`, + ]), + '}', + ] + )}`, + ]); + } + /** + * Generate method for the runtime module, producing the runtime code. + * @returns {string} runtime code + */ + override generate() { + const { name } = this.options; + const { chunkGraph, compilation, chunk } = this; + const { runtimeTemplate, moduleGraph, entrypoints, compiler } = compilation; + const { RuntimeGlobals, Template, javascript } = compiler.webpack || {}; + const chunkHasJs = + (javascript && javascript.JavascriptModulesPlugin.chunkHasJs) || + require('webpack/lib/javascript/JavascriptModulesPlugin').chunkHasJs; + + const containerEntryModule = this.resolveContainerModule(); + //server runtime is always called webpack-runtime + const isServer = chunk.name === 'webpack-runtime'; + const isApi = chunk.name === 'webpack-api-runtime'; + const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs); + // const hasJsMatcher = compileBooleanMatcher(conditionMap); + // find the main webpack runtime, skip all other chunks + if (chunk.name !== 'webpack-runtime' && chunk.name !== 'webpack') { + return Template.asString(''); + } + + const containerEntry = [containerEntryModule].map((module) => { + //@ts-ignore + const containerName = module?._name || name; + const containerModuleId = module?.id || module?.debugId; + + if (!(containerName && containerName)) { + return ''; + } + + // const globalRef = this.compilation.options.output?.globalObject; + //@ts-ignore + const nodeGlobal = this.compilation.options?.node?.global; + + const globalObject = nodeGlobal + ? RuntimeGlobals.global || 'global' + : 'global'; + + const containerScope = + isServer || isApi + ? [globalObject, "['__remote_scope__']"].join('') + : 'window'; + const runtimeId = chunk.id; + const serverContainerKickstart = Template.asString([ + '__webpack_require__.own_remote = new Promise(function(resolve,reject){', + Template.indent([ + // attachOnMount, + `__webpack_require__.O(0, [${JSON.stringify( + runtimeId + )}], function() {`, + // attachOnMount, + `if(!__webpack_require__.m[${JSON.stringify(containerModuleId)}]) {`, + `console.error('container does not exist in host runtime graph', ${JSON.stringify( + containerModuleId + )});`, + `} else { `, + this.options.debug + ? `console.debug('SHOULD ATTACH CONTAINER'); ` + : '', + 'attachRemote(resolve)', + `} `, + '},0)', + ]), + '})', + ]); + + const checkForAsyncChunkRequirements = Template.asString([ + `__webpack_require__.checkAsyncReqs = function() {`, + Template.indent([ + `self[${JSON.stringify( + this.compilation.outputOptions.chunkLoadingGlobal + )}].forEach(function(chunkId) {`, + Template.indent([ + `if(__webpack_require__.getEagerSharedForChunkId) {__webpack_require__.getEagerSharedForChunkId(chunkId[0],__webpack_require__.initConsumes)}`, + `if(__webpack_require__.getEagerRemotesForChunkId) {__webpack_require__.getEagerRemotesForChunkId(chunkId[0],__webpack_require__.initRemotes)}`, + ]), + '});', + ]), + '}', + ]); + + const browserContainerKickstart = Template.asString([ + '__webpack_require__.own_remote = new Promise(function(resolve,reject){', + this.options.debug + ? 'console.debug("O keys",Object.keys(__webpack_require__.O))' + : '', + `__webpack_require__.O(0, [${JSON.stringify(runtimeId)}], function() {`, + this.options.debug + ? "console.debug('runtime loaded, replaying all installed chunk requirements');" + : '', + '__webpack_require__.checkAsyncReqs();', + 'attachRemote(resolve)', + '},0)', + '})', + ]); + + // __webpack_require__.O(0, ["webpack-runtime"], function() { + return Template.asString([ + 'globalThis.usedChunks = globalThis.usedChunks || new Set();', + 'globalThis.backupScope = globalThis.backupScope || {};', + '__webpack_require__.S = globalThis.backupScope;', + '__webpack_require__.initConsumes = __webpack_require__.initConsumes || [];', + '__webpack_require__.initRemotes = __webpack_require__.initRemotes || [];', + '__webpack_require__.installedModules = {};', + this.options.debug + ? "console.debug('share scope', __webpack_require__.S);" + : '', + `if(${containerScope} === undefined) {`, + this.options.debug + ? `console.debug('container scope is empty, initializing');` + : '', + `${containerScope} = {_config: {}} + };`, + checkForAsyncChunkRequirements, + Template.asString([ + 'function attachRemote (resolve) {', + Template.indent([ + `const innerRemote = __webpack_require__(${JSON.stringify( + containerModuleId + )});`, + `${containerScope}[${JSON.stringify( + containerName + )}] = innerRemote;`, + "__webpack_require__.I('default',[globalThis.backupScope]);", + this.options.debug + ? "console.debug('remote attached', innerRemote);" + : '', + 'if(resolve) resolve(innerRemote)', + ]), + '}', + ]), + 'try {', + isServer ? serverContainerKickstart : browserContainerKickstart, + '} catch (e) {', + "console.error('host runtime was unable to initialize its own remote', e);", + '}', + this.mapChunks(), + this.mapShared(), + ]); + }); + return Template.asString(containerEntry); + } +} + +export default InvertedContainerRuntimeModule; diff --git a/packages/nextjs-mf/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.ts b/packages/nextjs-mf/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.ts new file mode 100644 index 00000000000..5ca1b9001e4 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.ts @@ -0,0 +1,148 @@ +import { Compiler, Compilation, Chunk, Module } from 'webpack'; + +class RemoveEagerModulesFromRuntimePlugin { + private container: string | undefined; + private debug: boolean; + private dependentModules: Set; + private visitedModules: Set; + + constructor(options: { container?: string; debug?: boolean }) { + this.container = options.container; + this.debug = options.debug || false; + this.dependentModules = new Set(); + this.visitedModules = new Set(); + } + + apply(compiler: Compiler) { + if (!this.container) { + console.warn( + '[nextjs-mf]:', + 'RemoveEagerModulesFromRuntimePlugin container is not defined:', + this.container + ); + return; + } + //return + compiler.hooks.thisCompilation.tap( + 'RemoveEagerModulesFromRuntimePlugin', + (compilation: Compilation) => { + compilation.hooks.optimizeChunkModules.tap( + 'RemoveEagerModulesFromRuntimePlugin', + (chunks: Iterable, modules: Iterable) => { + for (const chunk of chunks) { + if (chunk.hasRuntime() && chunk.name === this.container) { + const eagerModulesInRemote = this.getEagerModulesInRemote( + compilation, + chunk + ); + this.processModules( + compilation, + chunk, + modules, + eagerModulesInRemote + ); + this.removeDependentModules(compilation, chunk); + } + } + } + ); + } + ); + } + + private traverseModuleGraph(module: Module, compilation: Compilation) { + // Check if module has been visited before + if (this.visitedModules.has(module)) { + return; // Skip traversal if module has been visited + } + + this.visitedModules.add(module); // Mark module as visited + + // Skip traversal for certain module types + if ( + module.constructor.name === 'ExternalModule' || + module.type === 'provide-module' || + module.type === 'consume-shared-module' + ) { + return; + } + + this.dependentModules.add(module); // Add module to dependent modules set + + module.dependencies.forEach((dependency) => { + // Get the dependent module using moduleGraph + const dependentModule = compilation.moduleGraph.getModule(dependency); + + // If dependent module exists and is not already in dependentModules set, traverse it + if (dependentModule && !this.dependentModules.has(dependentModule)) { + this.traverseModuleGraph(dependentModule, compilation); + } + }); + } + + private getEagerModulesInRemote(compilation: Compilation, chunk: Chunk) { + const eagerModulesInRemote: Set = new Set(); + const iterableModules = + compilation.chunkGraph.getChunkModulesIterableBySourceType( + chunk, + 'share-init' + ) || []; + + for (const module of iterableModules) { + if ((module as any)._eager) { + //@ts-ignore + eagerModulesInRemote.add((module as any)._request); + } + + if ( + (module as any)?._eager || + (module as any)?._name?.startsWith('next') + ) { + compilation.chunkGraph.disconnectChunkAndModule(chunk, module); + } + } + return eagerModulesInRemote; + } + + private processModules( + compilation: Compilation, + chunk: Chunk, + modules: Iterable, + eagerModulesInRemote: Set + ) { + for (const module of modules) { + if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) { + continue; + } + + if ( + module.constructor.name === 'NormalModule' && + eagerModulesInRemote.has((module as any).resource) + ) { + this.traverseModuleGraph(module, compilation); + } + } + } + + private removeDependentModules(compilation: Compilation, chunk: Chunk) { + for (const moduleToRemove of this.dependentModules) { + if (this.debug) { + //@ts-ignore + console.log( + 'removing', + (moduleToRemove as any)?.resource, + //@ts-ignore + moduleToRemove?.request, + chunk.name, + moduleToRemove.constructor.name + ); + } + + if (compilation.chunkGraph.isModuleInChunk(moduleToRemove, chunk)) { + compilation.chunkGraph.disconnectChunkAndModule(chunk, moduleToRemove); + } + } + } +} + +export default RemoveEagerModulesFromRuntimePlugin; diff --git a/packages/nextjs-mf/src/plugins/container/custom-jsonp.ts b/packages/nextjs-mf/src/plugins/container/custom-jsonp.ts new file mode 100644 index 00000000000..73a3f7bd932 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/container/custom-jsonp.ts @@ -0,0 +1,87 @@ +export default ` +function promiseState(p) { + var t = {}; + return Promise.race([p, t]).then(function (v) { + return v === t ? "pending" : "fulfilled"; + }, function () { + return "rejected"; + }); +} +function cleanInitArrays(array) { + array.forEach(function (item, index) { + promiseState(item).then(function (status) { + if (status === 'fulfilled') { + array.splice(index, 1); + } + }); + }); +} + +function asyncOperation(originalPush) { + __webpack_require__.checkAsyncReqs(); + return Promise.all(__webpack_require__.initConsumes).then(function(){ + return Promise.all(__webpack_require__.initRemotes) + }).then(function () { + for (let q in chunkQueue) { + if(__webpack_require__.getEagerSharedForChunkId) {__webpack_require__.getEagerSharedForChunkId(chunkQueue[q][0],__webpack_require__.initConsumes)} + if(__webpack_require__.getEagerRemotesForChunkId) {__webpack_require__.getEagerRemotesForChunkId(chunkQueue[q][0],__webpack_require__.initRemotes)} + } + + return Promise.all([ + Promise.all((function () { + return __webpack_require__.initConsumes; + })()), + Promise.all((function () { + return __webpack_require__.initRemotes; + })()) + ]); + + }) + .then(function () { + function runCallback(queueArgs) { + Promise.all(__webpack_require__.initConsumes).then(function() { + webpackJsonpCallback.apply(null, [null].concat(Array.prototype.slice.call([queueArgs]))); + originalPush.apply(originalPush, [queueArgs]); + }); + } + + while (chunkQueue.length > 0) { + runCallback(chunkQueue.shift()); + } + }); +} + +asyncOperation(chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); + +chunkLoadingGlobal.push = (function (originalPush) { + return function () { + var chunkID = arguments[0][0]; + if(__webpack_require__.getEagerSharedForChunkId) {__webpack_require__.getEagerSharedForChunkId(chunkID,__webpack_require__.initConsumes)} + if(__webpack_require__.getEagerRemotesForChunkId) {__webpack_require__.getEagerRemotesForChunkId(chunkID,__webpack_require__.initRemotes)} + + __webpack_require__.O(null, ['webpack'], function () { + if(__webpack_require__.getEagerSharedForChunkId) {__webpack_require__.getEagerSharedForChunkId(chunkID,__webpack_require__.initConsumes)} + if(__webpack_require__.getEagerRemotesForChunkId) {__webpack_require__.getEagerRemotesForChunkId(chunkID,__webpack_require__.initRemotes)} + },0); + + __webpack_require__.O(null, [chunkID], function () { + if(__webpack_require__.getEagerSharedForChunkId) {__webpack_require__.getEagerSharedForChunkId(chunkID,__webpack_require__.initConsumes)} + if(__webpack_require__.getEagerRemotesForChunkId) {__webpack_require__.getEagerRemotesForChunkId(chunkID,__webpack_require__.initRemotes)} + cleanInitArrays(__webpack_require__.initConsumes); + cleanInitArrays(__webpack_require__.initRemotes); + },0); + + if (typeof arguments[0][2] === 'function') { + chunkTracker = Array.prototype.concat.apply(chunkTracker, arguments[0][0]); + var pushEvent = Array.prototype.push.apply(chunkQueue, arguments); + return asyncOperation(originalPush); + } + + webpackJsonpCallback.apply( + null, + [null].concat(Array.prototype.slice.call(arguments)) + ); + return originalPush.apply(chunkLoadingGlobal, arguments); + }; +})(chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); +`; diff --git a/packages/nextjs-mf/src/plugins/container/types.ts b/packages/nextjs-mf/src/plugins/container/types.ts new file mode 100644 index 00000000000..f33a9add2b6 --- /dev/null +++ b/packages/nextjs-mf/src/plugins/container/types.ts @@ -0,0 +1,5 @@ +import type { container } from "webpack"; + +export type ModuleFederationPluginOptions = ConstructorParameters< + typeof container.ModuleFederationPlugin +>['0']; diff --git a/packages/nextjs-mf/tsconfig.json b/packages/nextjs-mf/tsconfig.json index 6e9755175a2..591a2c52f52 100644 --- a/packages/nextjs-mf/tsconfig.json +++ b/packages/nextjs-mf/tsconfig.json @@ -2,14 +2,19 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "module": "commonjs", + "target": "es2021", "allowJs": true, + "moduleResolution": "Node16", "forceConsistentCasingInFileNames": true, "strict": true, "noImplicitOverride": true, "noPropertyAccessFromIndexSignature": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "esModuleInterop": true + "esModuleInterop": true, + "declaration": true, + "sourceMap": true, + "isolatedModules": true, }, "files": [], "include": [], diff --git a/packages/nextjs-mf/utils/Template.ts b/packages/nextjs-mf/utils/Template.ts index 5a762f718be..3de4ba760f0 100644 --- a/packages/nextjs-mf/utils/Template.ts +++ b/packages/nextjs-mf/utils/Template.ts @@ -5,7 +5,7 @@ 'use strict'; -import { ConcatSource, PrefixSource } from 'webpack-sources'; +import { ConcatSource, PrefixSource } from "webpack-sources"; /** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */ /** @typedef {import("webpack-sources").Source} Source */ @@ -297,7 +297,7 @@ class Template { prefix = '' ) { const { chunkGraph } = renderContext; - var source = new ConcatSource(); + const source = new ConcatSource(); if (modules.length === 0) { return null; } diff --git a/packages/nextjs-mf/utils/build-utils.ts b/packages/nextjs-mf/utils/build-utils.ts index 63e1fcdce1d..0488b660280 100644 --- a/packages/nextjs-mf/utils/build-utils.ts +++ b/packages/nextjs-mf/utils/build-utils.ts @@ -1,291 +1,8 @@ -import Template from './Template'; -import { parseRemoteSyntax } from '../src/internal'; -import { WebpackRemoteContainer } from '@module-federation/utilities'; import path from 'path'; -const transformInput = (code: string) => { - let swc; - try { - swc = require('@swc/core'); - } catch (e) { - return code; - } - return swc.transformSync(code, { - // Some options cannot be specified in .swcrc - sourceMaps: false, - // Input files are treated as module by default. - isModule: false, - // All options below can be configured via .swcrc - jsc: { - loose: false, - target: 'es5', - externalHelpers: false, - parser: { - syntax: 'ecmascript', - }, - transform: {}, - }, - }).code; -}; - export const computeRemoteFilename = (isServer: boolean, filename: string) => { if (isServer && filename) { return path.basename(filename); } return filename; }; - -// // To satisfy Typescript. -declare const urlAndGlobal: string; -//remote is defined in the template wrapper - -const IsomorphicRemoteTemplate = function () { - const index = urlAndGlobal.indexOf('@'); - - if (index <= 0 || index === urlAndGlobal.length - 1) { - throw new Error(`Invalid request "${urlAndGlobal}"`); - } - const remote = { - url: urlAndGlobal.substring(index + 1), - global: urlAndGlobal.substring(0, index) as unknown as number, // this casting to satisfy TS - }; - - return new Promise(function (resolve, reject) { - const __webpack_error__ = new Error() as Error & { - type: string; - request: string | null; - }; - - if (typeof window !== 'undefined') { - if (typeof window[remote.global] !== 'undefined') { - return resolve(); - } - } else { - // @ts-ignore - if (!global.__remote_scope__) { - // create a global scope for container, similar to how remotes are set on window in the browser - // @ts-ignore - global.__remote_scope__ = { - // @ts-ignore - _config: {}, - }; - } - - // @ts-ignore - if (typeof global.__remote_scope__[remote.global] !== 'undefined') { - return resolve(); - } - } - - (__webpack_require__ as any).l( - remote.url, - function (event: Event) { - if (typeof window !== 'undefined') { - if (typeof window[remote.global] !== 'undefined') { - return resolve(); - } - } else { - // @ts-ignore - if (typeof global.__remote_scope__[remote.global] !== 'undefined') { - return resolve(); - } - } - - const errorType = - event && (event.type === 'load' ? 'missing' : event.type); - const realSrc = - event && event.target && (event.target as HTMLScriptElement).src; - - __webpack_error__.message = - 'Loading script failed.(' + - errorType + - ': ' + - realSrc + - ' or global var ' + - remote.global + - ')'; - - __webpack_error__.name = 'ScriptExternalLoadError'; - __webpack_error__.type = errorType; - __webpack_error__.request = realSrc; - - reject(__webpack_error__); - }, - remote.global - ); - }) - .then(function () { - const globalScope = - //@ts-ignore - typeof window !== 'undefined' ? window : global.__remote_scope__; - const remoteGlobal = globalScope[ - remote.global - ] as unknown as WebpackRemoteContainer & { - __initialized: boolean; - }; - const proxy: WebpackRemoteContainer = { - get: remoteGlobal.get, - //@ts-ignore - init: function (shareScope) { - const handler: ProxyHandler = { - get(target, prop: string) { - if (target[prop]) { - Object.values(target[prop]).forEach(function (o) { - if (o.from === '_N_E') { - o.loaded = 1; - } - }); - } - return target[prop]; - }, - set(target, property: string, value, receiver) { - if (target[property]) { - return target[property] as unknown as boolean; - } - target[property] = value; - return true; - }, - }; - - try { - remoteGlobal.init( - new Proxy(shareScope as typeof __webpack_share_scopes__, handler) - ); - } catch (e) { - // already initialized - } - - remoteGlobal.__initialized = true; - }, - }; - - if (!remoteGlobal.__initialized) { - try { - proxy.init(); - } catch (e) { - // already initialized - } - } - return proxy; - }) - .catch((e) => { - console.error(remote.global, 'is offline, returning fake remote'); - console.error(e); - - return { - fake: true, - get: (arg: any) => { - console.log('faking', arg, 'module on', remote.global); - - return Promise.resolve(() => { - return () => null; - }); - }, - init: () => {}, - }; - }); -}; - -/** - * @deprecated This function is being deprecated in favor of delegate modules - */ -export const promiseFactory = (factory: string | Function) => { - const wrapper = `new Promise(${factory.toString()})`; - - const isPromiseFactoryIncludesImportOrRequireContext = [ - 'require(', - 'import(', - 'import ', - ].some((statement) => wrapper.includes(statement)); - - if (isPromiseFactoryIncludesImportOrRequireContext) { - throw new Error( - 'promiseFactory does not support require, import, or import statements' - ); - } - - const template = Template.asString([ - 'function() {', - Template.indent([wrapper]), - '}', - ]); - - return template; -}; - -/** - * @deprecated This function is being deprecated in favor of delegate modules - */ -export const promiseTemplate = ( - remote: string, - ...otherPromises: Function[] -) => { - console.warn( - '[nextjs-mf]: promiseTemplate is being deprecated in favor of delegate modules' - ); - let promises: string[] = []; - - if (otherPromises) { - promises = otherPromises.map((p) => { - return Template.getFunctionContent( - promiseFactory(p) as unknown as Function - ); - }); - } - - let remoteSyntax = remote; - let remoteFactory = parseRemoteSyntax; - - if ( - typeof remote === 'function' || - remote.startsWith('function') || - remote.startsWith('(') - ) { - remoteSyntax = Template.getFunctionContent( - promiseFactory(remote) as unknown as Function - ); - - remoteFactory = (remoteSyntax) => { - return Template.asString([ - `${remoteSyntax}.then(function(urlAndGlobal) {`, - Template.indent([ - Template.getFunctionContent(IsomorphicRemoteTemplate), - ]), - '})', - ]); - }; - } - - const allPromises = [remoteFactory(remoteSyntax), ...promises].join(',\n'); - - return Template.asString([ - 'promise new Promise(function(resolve, reject) {', - transformInput( - Template.indent([ - 'Promise.all([', - Template.indent(allPromises), - ']).then(function(promises) {', - Template.indent(['resolve(promises[0]);']), - '})', - ]) - ), - '})', - ]); -}; - -// remotes: { -// shop: promiseTemplate('global@url', (resolve,reject) => {}), -// shop: promiseTemplate( -// // can also be a string if it needs to be computed in scope -// `(resolve, reject) => { -// resolve("${remotes.shop}"); -// }`, -// (resolve,reject)=>{ -// console.log('runing other promise'); -// setTimeout(() => { -// console.log('resolving promise'); -// resolve(); -// } , 1000); -// }), -// checkout: remotes.checkout, -// }, diff --git a/packages/nextjs-mf/utils/flushedChunks.ts b/packages/nextjs-mf/utils/flushedChunks.ts new file mode 100644 index 00000000000..7f86144824b --- /dev/null +++ b/packages/nextjs-mf/utils/flushedChunks.ts @@ -0,0 +1,46 @@ +import * as React from 'react'; + +export const FlushedChunks = ({ chunks = [] }: FlushedChunksProps) => { + const scripts = chunks + .filter((c) => { + // TODO: host shouldnt flush its own remote out + // if(c.includes('?')) { + // return c.split('?')[0].endsWith('.js') + // } + return c.endsWith('.js'); + }) + .map((chunk) => { + if (!chunk.includes('?') && chunk.includes('remoteEntry')) { + chunk = chunk + '?t=' + Date.now(); + } + return React.createElement( + 'script', + { + key: chunk, + src: chunk, + async: true, + }, + null + ); + }); + + const css = chunks + .filter((c) => c.endsWith('.css')) + .map((chunk) => { + return React.createElement( + 'link', + { + key: chunk, + href: chunk, + rel: 'stylesheet', + }, + null + ); + }); + + return React.createElement(React.Fragment, null, css, scripts); +}; + +export interface FlushedChunksProps { + chunks: string[]; +} diff --git a/packages/nextjs-mf/utils/index.ts b/packages/nextjs-mf/utils/index.ts index 153ed77ddd1..204bf91a6fb 100644 --- a/packages/nextjs-mf/utils/index.ts +++ b/packages/nextjs-mf/utils/index.ts @@ -1,10 +1,13 @@ import * as React from 'react'; + export { extractUrlAndGlobal, injectScript, -} from '@module-federation/utilities'; +} from '@module-federation/utilities/src/utils/common'; // @ts-ignore export { flushChunks } from '@module-federation/node/utils'; +export { FlushedChunks } from './flushedChunks'; +export type { FlushedChunksProps } from './flushedChunks'; export const revalidate = () => { if (typeof window !== 'undefined') { @@ -16,46 +19,3 @@ export const revalidate = () => { return utils.revalidate(); }); }; - -export interface FlushedChunksProps { - chunks: string[]; -} - -export const FlushedChunks = ({ chunks }: FlushedChunksProps) => { - const scripts = chunks - .filter((c) => c.endsWith('.js')) - .map((chunk) => { - if (!chunk.includes('?') && chunk.includes('remoteEntry')) { - chunk = chunk + '?t=' + Date.now(); - } - return React.createElement( - 'script', - { - key: chunk, - src: chunk, - async: true, - }, - null - ); - }); - - const css = chunks - .filter((c) => c.endsWith('.css')) - .map((chunk) => { - return React.createElement( - 'link', - { - key: chunk, - href: chunk, - rel: 'stylesheet', - }, - null - ); - }); - - return React.createElement(React.Fragment, null, css, scripts); -}; - -FlushedChunks.defaultProps = { - chunks: [], -} as FlushedChunksProps; diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 24ffeb100ae..46a359071c3 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -2,6 +2,260 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [0.16.3-rc.1](https://github.com/module-federation/nextjs-mf/compare/node-0.16.3-rc.0...node-0.16.3-rc.1) (2023-07-01) + + +### Features + +* support edge workers ([4c43729](https://github.com/module-federation/nextjs-mf/commit/4c43729153a4130d84f92ea2e56f771f2e63abc8)) +* support edge workers ([#1084](https://github.com/module-federation/nextjs-mf/issues/1084)) ([3f5df94](https://github.com/module-federation/nextjs-mf/commit/3f5df944ea787cf958fd4cf7fabed84432a50a10)) + + + +## [0.16.3-rc.0](https://github.com/module-federation/nextjs-mf/compare/node-0.16.2...node-0.16.3-rc.0) (2023-06-30) + + + +## [0.15.2-rc8.1](https://github.com/module-federation/nextjs-mf/compare/node-0.15.2-rc8.0...node-0.15.2-rc8.1) (2023-06-28) + + + +## [0.15.2-rc8.0](https://github.com/module-federation/nextjs-mf/compare/node-0.15.2-rc7.0...node-0.15.2-rc8.0) (2023-06-27) + + +### Bug Fixes + +* disable flushing remotes to ssr for now ([2495582](https://github.com/module-federation/nextjs-mf/commit/249558248682896ccb05a9517d8540b97379b1bc)) + + + +## [0.15.2-rc7.0](https://github.com/module-federation/nextjs-mf/compare/node-0.15.2-rc6.0...node-0.15.2-rc7.0) (2023-06-27) + + + +## [0.15.2-rc6.0](https://github.com/module-federation/nextjs-mf/compare/node-0.15.2-rc5.0...node-0.15.2-rc6.0) (2023-06-23) + + + +## [0.15.2-rc5.0](https://github.com/module-federation/nextjs-mf/compare/node-0.15.2-rc4.0...node-0.15.2-rc5.0) (2023-06-23) + + + +## [0.15.2-rc4.0](https://github.com/module-federation/nextjs-mf/compare/node-0.15.2-rc3.1...node-0.15.2-rc4.0) (2023-06-21) + + +### Bug Fixes + +* Resolve condition names ([#974](https://github.com/module-federation/nextjs-mf/issues/974)) ([5e8b49c](https://github.com/module-federation/nextjs-mf/commit/5e8b49cf60f19dae6be4818a1c0ff783c7689393)) +* Runtime module checking ([#969](https://github.com/module-federation/nextjs-mf/issues/969)) ([b5c7af1](https://github.com/module-federation/nextjs-mf/commit/b5c7af1697a63d9e19f901238a4c0382ea0c3f50)) + + + +## [0.15.2-rc3.1](https://github.com/module-federation/nextjs-mf/compare/node-0.15.2-rc3.0...node-0.15.2-rc3.1) (2023-06-09) + + +### Bug Fixes + +* Path loader patches ([#960](https://github.com/module-federation/nextjs-mf/issues/960)) ([d362a77](https://github.com/module-federation/nextjs-mf/commit/d362a7752c4364cc499a27f2b6eeb5399543cb29)) + + + +## [0.15.2-rc3.0](https://github.com/module-federation/nextjs-mf/compare/node-0.15.2-beta.0...node-0.15.2-rc3.0) (2023-06-09) + + + +## [0.15.2-beta.0](https://github.com/module-federation/nextjs-mf/compare/node-0.15.2-rc1.0...node-0.15.2-beta.0) (2023-05-26) + + +### Bug Fixes + +* Improve chunk correlation ([#936](https://github.com/module-federation/nextjs-mf/issues/936)) ([4dad1eb](https://github.com/module-federation/nextjs-mf/commit/4dad1eb370feacd6ecb4c1726c435d5c579f424d)) + + + +## [0.15.2-rc1.0](https://github.com/module-federation/nextjs-mf/compare/node-0.15.2-rc.0...node-0.15.2-rc1.0) (2023-05-25) + + + +## [0.15.2-rc.0](https://github.com/module-federation/nextjs-mf/compare/node-0.15.1...node-0.15.2-rc.0) (2023-05-23) + + +### Bug Fixes + +* chunk and module duplications ([#885](https://github.com/module-federation/nextjs-mf/issues/885)) ([199e6b9](https://github.com/module-federation/nextjs-mf/commit/199e6b9937f4a2ca6caedb3ae4767342de463cb6)) +* client prod build issues ([#899](https://github.com/module-federation/nextjs-mf/issues/899)) ([470d7ad](https://github.com/module-federation/nextjs-mf/commit/470d7ad408ae8d64dbccc5a9528eaa2ed60fa2ca)) +* externalization and missing runtime chunks ([#887](https://github.com/module-federation/nextjs-mf/issues/887)) ([c79cd62](https://github.com/module-federation/nextjs-mf/commit/c79cd6226d3134f1d6294cd8eba40c8c33af5cb5)) +* missing chunk hashes on exposed modules ([#893](https://github.com/module-federation/nextjs-mf/issues/893)) ([cfa43f5](https://github.com/module-federation/nextjs-mf/commit/cfa43f506999d5ce3ab6afeea513d50d85f7886e)) + + + +## [0.14.7-rc.2](https://github.com/module-federation/nextjs-mf/compare/node-0.14.7-rc.1...node-0.14.7-rc.2) (2023-05-17) + + + +## [0.14.7-rc.1](https://github.com/module-federation/nextjs-mf/compare/node-0.14.7-rc.0...node-0.14.7-rc.1) (2023-05-17) + + +### Bug Fixes + +* **chunk-module-duplication:** prevent runtime reset and share scope loss ([14bfc38](https://github.com/module-federation/nextjs-mf/commit/14bfc38515a4da3be7321d4b6d876905d45ad20b)) + + + +## [0.14.7-rc.0](https://github.com/module-federation/nextjs-mf/compare/node-0.14.7-beta.3...node-0.14.7-rc.0) (2023-05-16) + + + +## [0.14.7-beta.3](https://github.com/module-federation/nextjs-mf/compare/node-0.14.7-beta.2...node-0.14.7-beta.3) (2023-05-16) + + + +## [0.14.7-beta.2](https://github.com/module-federation/nextjs-mf/compare/node-0.14.7-beta.1...node-0.14.7-beta.2) (2023-05-16) + + + +## [0.14.7-beta.1](https://github.com/module-federation/nextjs-mf/compare/node-0.14.7-beta.0...node-0.14.7-beta.1) (2023-05-16) + + + +## [0.14.7-beta.0](https://github.com/module-federation/nextjs-mf/compare/node-0.14.6...node-0.14.7-beta.0) (2023-05-16) + + + +## [0.14.6](https://github.com/module-federation/nextjs-mf/compare/node-0.14.5...node-0.14.6) (2023-05-16) + + + +## [0.14.5](https://github.com/module-federation/nextjs-mf/compare/node-0.14.5-beta.0...node-0.14.5) (2023-05-15) + + + +## [0.14.5-beta.0](https://github.com/module-federation/nextjs-mf/compare/node-0.14.4...node-0.14.5-beta.0) (2023-05-15) + + +### Features + +* Quantum Modules ([#872](https://github.com/module-federation/nextjs-mf/issues/872)) ([2991039](https://github.com/module-federation/nextjs-mf/commit/299103932b4e0aa6d8017be588ffa5272f519260)) + + + +## [0.14.4](https://github.com/module-federation/nextjs-mf/compare/node-0.14.4-beta.0...node-0.14.4) (2023-05-13) + + + +## [0.14.4-beta.0](https://github.com/module-federation/nextjs-mf/compare/node-0.14.3...node-0.14.4-beta.0) (2023-05-13) + + +### Bug Fixes + +* remove container proxy code ([6123d98](https://github.com/module-federation/nextjs-mf/commit/6123d9846606d76be949492ca04474f5c8164bc7)) + + +### Features + +* [7] Async boundary runtime server ([#851](https://github.com/module-federation/nextjs-mf/issues/851)) ([7fa792a](https://github.com/module-federation/nextjs-mf/commit/7fa792a4b518cd007b5ac41db225e20521063e73)), closes [#864](https://github.com/module-federation/nextjs-mf/issues/864) + + +### BREAKING CHANGES + +* automaticAsyncBoundary option has been removed + +* fix: exclude specific pages from page map automatically + +* refactor: conslidate codebase + +* fix: improve hot reload share recovery + +* refactor: remove server jsonp template + +* chore: remove dead code from runtime modules + +* fix: clean up jsonp getCustomJsonpCode + +getting chunk loading global from compiler output options + +* feat: adding cleanInitArrays runtime helper + +* chore: remove share scope hoist and module hoisting system + +* chore: cleanup code + + + +## [0.14.3](https://github.com/module-federation/nextjs-mf/compare/node-0.14.3-beta.0...node-0.14.3) (2023-05-03) + + + +## [0.14.3-beta.0](https://github.com/module-federation/nextjs-mf/compare/node-0.14.2...node-0.14.3-beta.0) (2023-05-03) + + + +## [0.14.2](https://github.com/module-federation/nextjs-mf/compare/node-0.14.2-beta.1...node-0.14.2) (2023-04-28) + + + +## [0.14.2-beta.1](https://github.com/module-federation/nextjs-mf/compare/node-0.14.2-beta.0...node-0.14.2-beta.1) (2023-04-28) + + + +## [0.14.2-beta.0](https://github.com/module-federation/nextjs-mf/compare/node-0.14.1...node-0.14.2-beta.0) (2023-04-28) + + +### Bug Fixes + +* use [fullhash] if no hash exists / in development mode. ([dfa7fb3](https://github.com/module-federation/nextjs-mf/commit/dfa7fb3a49b81b87dae43ec57ff2f86f5c2b7501)) + + + +## [0.14.1](https://github.com/module-federation/nextjs-mf/compare/node-0.14.1-beta.0...node-0.14.1) (2023-04-28) + + + +## [0.14.1-beta.0](https://github.com/module-federation/nextjs-mf/compare/node-0.14.0...node-0.14.1-beta.0) (2023-04-28) + + +### Features + +* Improve module chunk connections ([#802](https://github.com/module-federation/nextjs-mf/issues/802)) ([ce0bd7b](https://github.com/module-federation/nextjs-mf/commit/ce0bd7b16e080f712e6db0bdcd3955a8167c274f)), closes [#803](https://github.com/module-federation/nextjs-mf/issues/803) [#808](https://github.com/module-federation/nextjs-mf/issues/808) [#811](https://github.com/module-federation/nextjs-mf/issues/811) + + + +## [0.13.1](https://github.com/module-federation/nextjs-mf/compare/node-0.13.1-beta.0...node-0.13.1) (2023-04-19) + + + +## [0.13.1-beta.0](https://github.com/module-federation/nextjs-mf/compare/node-0.13.0...node-0.13.1-beta.0) (2023-04-19) + + +### Bug Fixes + +* use container proxy on script VM instead of host resolver point ([2929d0f](https://github.com/module-federation/nextjs-mf/commit/2929d0f64d4b8edf268af5ca83f807a02b121861)) +* get delegates working ([#527](https://github.com/module-federation/nextjs-mf/issues/527)) ([7655568](https://github.com/module-federation/nextjs-mf/commit/7655568fcef8dbfda40573deb5d3d029c101074c)) +* improved asset pipeline ([63928b2](https://github.com/module-federation/nextjs-mf/commit/63928b28150c2c4e3adb9e14fb7aa54f5cf1578d)) +* peer dependencies metadata ([d3a2ed0](https://github.com/module-federation/nextjs-mf/commit/d3a2ed0e378b59afdeb632d1e2e0290f05cbca19)) +* solve externalization ([49f52e5](https://github.com/module-federation/nextjs-mf/commit/49f52e53ddddc990d31e6aa510d67dc0552a9d9a)) +* use EntryPlugin for injection of remotes ([e522c5a](https://github.com/module-federation/nextjs-mf/commit/e522c5ad2b7adcbd6c39f9c5fdb7a3e418277b7a)) + + +### Features + +* delegate module support ([5061d3d](https://github.com/module-federation/nextjs-mf/commit/5061d3d64d7d83dbb25b4ef2378d434545186cb1)) +* chunk flushing in delegates ([5e2375f](https://github.com/module-federation/nextjs-mf/commit/5e2375f598437803105ac4bc2237f6b652554d00)) +* delegate module support ([8dd154c](https://github.com/module-federation/nextjs-mf/commit/8dd154c261b34183b12250ce204904cd3e085658)) +* delegate module support ([d242163](https://github.com/module-federation/nextjs-mf/commit/d24216324183bfec5c7ba672ba6da05679f67809)) +* delegates part two ([1be2686](https://github.com/module-federation/nextjs-mf/commit/1be2686624798a7df9f447b48279294985b3f592)) +* improve chunk correlation ([22d8afc](https://github.com/module-federation/nextjs-mf/commit/22d8afccff101044fcdeba390656950dbc6eafed)) +* new chunk flushing system for exposed modules ([97a75d8](https://github.com/module-federation/nextjs-mf/commit/97a75d8702f2ddc5e12cff2ac4d24aca1df6f990)) +* prepare for v7 ([7bc4b3b](https://github.com/module-federation/nextjs-mf/commit/7bc4b3bd44e0926a52d6a9cbe56f0c4d7bb700ae)) + + +### BREAKING CHANGES + +* safety breaking change note +BREAKING_CHANGE: safety breaking change note + + + ## [0.16.2](https://github.com/module-federation/nextjs-mf/compare/node-0.16.1...node-0.16.2) (2023-06-30) ### Dependency Updates diff --git a/packages/node/global.d.ts b/packages/node/global.d.ts index 19be47d09b9..6ec0c7702bc 100644 --- a/packages/node/global.d.ts +++ b/packages/node/global.d.ts @@ -10,15 +10,17 @@ declare module 'webpack/lib/Template'; declare module 'webpack/lib/util/compileBooleanMatcher'; declare module 'webpack/lib/util/identifier'; -declare const global: typeof globalThis & { - usedChunks: Set; - flushChunks: () => Promise>; - __remote_scope__: { + +// globals.d.ts +declare module globalThis { + var usedChunks: Set; + var flushChunks: () => Promise>; + var __remote_scope__: { _config: Record; _medusa?: Record; [K: string]: { fake?: boolean; }; }; - webpackChunkLoad; -}; + var webpackChunkLoad: ()=> any; +} diff --git a/packages/node/package.json b/packages/node/package.json index cc71fabcae7..ee56ee9033c 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,7 +1,7 @@ { "public": true, "name": "@module-federation/node", - "version": "0.16.2", + "version": "0.16.3-rc.1", "type": "commonjs", "main": "src/index.js", "exports": { diff --git a/packages/node/src/plugins/ChunkCorrelationPlugin.js b/packages/node/src/plugins/ChunkCorrelationPlugin.js index 522a2eddf35..2642221d0c7 100644 --- a/packages/node/src/plugins/ChunkCorrelationPlugin.js +++ b/packages/node/src/plugins/ChunkCorrelationPlugin.js @@ -65,7 +65,15 @@ function getRemoteModules(stats) { * @returns {WebpackStatsModule[]} */ function getExposedModules(stats, exposedFile) { - return stats.modules.filter((mod) => mod.name.startsWith(exposedFile)); + return stats.modules.filter((mod) => mod.name?.startsWith(exposedFile)); +} + +function getDependenciesOfChunk(stats, chunk) { + return stats.chunks + .filter((c) => c.children.includes(chunk.id)) + .reduce((acc, c) => { + return acc.concat(c.modules); + }, []); } /** @@ -75,14 +83,28 @@ function getExposedModules(stats, exposedFile) { * @returns {Exposed} */ function getExposed(stats, mod) { - const chunks = stats.chunks.filter((chunk) => - mod.chunks.some((id) => id === chunk.id) - ); + const chunks = stats.chunks.filter((chunk) => { + return chunk.modules.find((modsInChunk) => { + return modsInChunk.id === mod.id && !modsInChunk.dependent; + }); + }); + const dependencies = stats.modules + .filter((sharedModule) => { + if (sharedModule.moduleType !== 'consume-shared-module') return false; + return sharedModule.issuerId === mod.id; + }) + .map((sharedModule) => { + return sharedModule.identifier.split('|')[2]; + }); const flatChunks = flatMap(chunks, (chunk) => ({ - [chunk.id]: chunk.files.map( - (f) => `${stats.publicPath === 'auto' ? '' : stats.publicPath || ''}${f}` - ), + [chunk.id]: { + files: chunk.files.map( + (f) => + `${stats.publicPath === 'auto' ? '' : stats.publicPath || ''}${f}` + ), + requiredModules: dependencies, + }, })); return flatChunks.reduce((acc, chunk) => { @@ -105,6 +127,22 @@ function searchIssuer(mod, check) { return !!mod.modules && mod.modules.some((m) => searchIssuer(m, check)); } +function searchReason(mod, check) { + if (mod.reasons && check(mod.reasons)) { + return true; + } + + return !!mod.reasons && mod.reasons.some((m) => searchReason(m, check)); +} + +function searchIssuerAndReason(mod, check) { + const foundIssuer = searchIssuer(mod, (issuer) => check(issuer)); + if (foundIssuer) return foundIssuer; + return searchReason(mod, (reason) => + reason.some((r) => check(r?.moduleIdentifier)) + ); +} + /** * @param {import("webpack").Module} mod * @param {(issuer: string) => boolean} check @@ -122,6 +160,37 @@ function getIssuers(mod, check) { ); } +function getIssuersAndReasons(mod, check) { + if (mod.issuer && check(mod.issuer)) { + return [mod.issuer]; + } + if ( + mod.reasons && + searchReason(mod, (reason) => + reason.some((r) => check(r?.moduleIdentifier)) + ) + ) { + return mod.reasons + .filter((r) => { + return r.moduleIdentifier && check(r.moduleIdentifier); + }) + .map((r) => r.moduleIdentifier); + } + + return ( + (mod.modules && + mod.modules + .filter((m) => searchIssuerAndReason(m, check)) + .map((m) => { + return ( + m.issuer || + m.reasons.find((r) => check(r?.moduleIdentifier)).moduleIdentifier + ); + })) || + [] + ); +} + /** * @param {string} issuer * @returns {SharedDependency} @@ -161,10 +230,10 @@ function parseFederatedIssuer(issuer) { function getSharedModules(stats, federationPlugin) { return flatMap( stats.chunks.filter((chunk) => { - if (!stats.entrypoints[federationPlugin._options.name]) { + if (!stats.entrypoints[federationPlugin.name]) { return false; } - return stats.entrypoints[federationPlugin._options.name].chunks.some( + return stats.entrypoints[federationPlugin.name].chunks.some( (id) => chunk.id === id ); }), @@ -175,7 +244,7 @@ function getSharedModules(stats, federationPlugin) { c.id === id && c.files.length > 0 && c.parents.some((p) => - stats.entrypoints[federationPlugin._options.name].chunks.some( + stats.entrypoints[federationPlugin.name].chunks.some( (c) => c === p ) ) && @@ -220,35 +289,40 @@ function getMainSharedModules(stats) { return flatMap(chunks, (chunk) => flatMap(chunk.children, (id) => - stats.chunks.filter( - (c) => + stats.chunks.filter((c) => { + return ( c.id === id && c.files.length > 0 && - c.modules.some((m) => - searchIssuer(m, (issuer) => - issuer?.startsWith('consume-shared-module') - ) - ) - ) + c.modules.some((m) => { + return searchIssuerAndReason(m, (check) => + check?.startsWith('consume-shared-module') + ); + }) + ); + }) ) ) - .map((chunk) => ({ - chunks: chunk.files.map( - (f) => - `${stats.publicPath === 'auto' ? '' : stats.publicPath || ''}${f}` - ), - provides: flatMap( - chunk.modules.filter((m) => - searchIssuer(m, (issuer) => - issuer?.startsWith('consume-shared-module') - ) + .map((chunk) => { + return { + chunks: chunk.files.map( + (f) => + `${stats.publicPath === 'auto' ? '' : stats.publicPath || ''}${f}` ), - (m) => - getIssuers(m, (issuer) => issuer?.startsWith('consume-shared-module')) - ) - .map(parseFederatedIssuer) - .filter((f) => !!f), - })) + provides: flatMap( + chunk.modules.filter((m) => + searchIssuerAndReason(m, (check) => + check?.startsWith('consume-shared-module') + ) + ), + (m) => + getIssuersAndReasons(m, (issuer) => + issuer?.startsWith('consume-shared-module') + ) + ) + .map(parseFederatedIssuer) + .filter((f) => !!f), + }; + }) .filter((c) => c.provides.length > 0); } @@ -258,10 +332,8 @@ function getMainSharedModules(stats) { * @param {import("webpack").container.ModuleFederationPlugin} federationPlugin * @returns {FederatedStats} */ -function getFederationStats(stats, federationPlugin) { - const exposedModules = Object.entries( - federationPlugin._options.exposes - ).reduce( +function getFederationStats(stats, federationPluginOptions) { + const exposedModules = Object.entries(federationPluginOptions.exposes).reduce( (exposedModules, [exposedAs, exposedFile]) => Object.assign(exposedModules, { [exposedAs]: getExposedModules(stats, exposedFile), @@ -280,9 +352,9 @@ function getFederationStats(stats, federationPlugin) { /** @type {string} */ const remote = - federationPlugin._options.library?.name || federationPlugin._options.name; + federationPluginOptions.library?.name || federationPluginOptions.name; - const sharedModules = getSharedModules(stats, federationPlugin); + const sharedModules = getSharedModules(stats, federationPluginOptions); const remoteModules = getRemoteModules(stats); return { remote, @@ -290,7 +362,7 @@ function getFederationStats(stats, federationPlugin) { stats.assetsByChunkName[remote] && stats.assetsByChunkName[remote].length === 1 ? stats.assetsByChunkName[remote][0] - : federationPlugin._options.filename + : federationPluginOptions.filename }`, sharedModules, exposes, @@ -338,51 +410,163 @@ class FederationStatsPlugin { console.error('No ModuleFederationPlugin(s) found.'); return; } - + // This is where the plugin is tapping into the Webpack compilation lifecycle. + // It's listening to the 'thisCompilation' event, which is triggered once for each new compilation. compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => { - compilation.hooks.processAssets.tapPromise( + // 'processAssets' is a hook that gets triggered when Webpack has finished the compilation + // and is about to generate the final assets. It allows plugins to do additional processing on the assets. + compilation.hooks.processAssets.tap( { name: PLUGIN_NAME, - stage: compilation.constructor.PROCESS_ASSETS_STAGE_ANALYSE, + stage: compilation.constructor.PROCESS_ASSETS_STAGE_REPORT, }, - async () => { + () => { + // Extract the options from the federation plugins. + const [federationOpts] = federationPlugins.map( + (federationPlugin) => federationPlugin?._options + ); + + let container; + // Loop through all entry points and if one matches the name of a federation plugin, + // store the entry point in the 'container' variable. + for (const [name, entry] of compilation.entrypoints) { + if (container) break; + federationOpts.name.includes(name) && (container = entry); + } + + // If no matching entry point was found, exit the function early. + if (!container) return; + + // Get the chunk associated with the entry point. + container = container?.getEntrypointChunk(); + + // Get the module associated with the chunk. + const [containerEntryModule] = Array.from( + compilation.chunkGraph.getChunkEntryModulesIterable(container) + ); + + // Construct an object where the keys are the names of the exposed modules and the values are their options. + const exposedObj = Object.fromEntries(containerEntryModule._exposes); + + const moduleMap = {}; + + const blocks = containerEntryModule.blocks; + + const exposedResolved = {}; + const builtExposes = {}; + + // Iterate over each dependency block associated with the entry module. + for (let block of blocks) { + const blockmodule = block; + + // Iterate over each dependency within the block. + for (const dep of blockmodule.dependencies) { + // Get the module that corresponds to the dependency. + const { module } = compilation.moduleGraph.getConnection(dep); + const moduleChunks = + compilation.chunkGraph.getModuleChunksIterable(module); + // Iterate over each chunk associated with the module. + for (let exposedChunk of moduleChunks) { + // Determine the runtime for the chunk. + const runtime = + typeof exposedChunk.runtime === 'string' + ? new Set([exposedChunk.runtime]) + : exposedChunk.runtime; + + // Check if the chunk is meant for the same runtime as the entry module. + const isForThisRuntime = runtime.has( + containerEntryModule._name + ); + + // Get the root modules for the chunk. + const rootModules = + compilation.chunkGraph.getChunkRootModules(exposedChunk); + + // Check if the module associated with the dependency is one of the root modules for the chunk. + const moduleActuallyNeedsChunk = rootModules.includes(module); + + // If the chunk is not meant for this runtime or the module doesn't need the chunk, skip the rest of this iteration. + if (!isForThisRuntime || !moduleActuallyNeedsChunk) continue; + + // Add the files associated with the chunk to the 'builtExposes' object under the name of the exposed module. + builtExposes[dep.exposedName] = [ + ...(builtExposes[dep.exposedName] || []), + ...(exposedChunk.files || []), + ]; + } + + // Add the module to the 'exposedResolved' object under the name of the exposed module. + exposedResolved[dep.exposedName] = module; + } + } + + // Generate a JSON object that contains detailed information about the compilation. const stats = compilation.getStats().toJson({ - performance: false, - time: false, - logging: 'none', - loggingDebug: false, - loggingTrace: false, - source: false, - children: false, - errors: false, - warnings: false, - errorsCount: false, - warningsCount: false, - builtAt: false, - timings: false, + all: false, + assets: true, + reasons: true, + modules: true, + children: true, + chunkGroups: true, + chunkModules: true, + chunkOrigins: false, + entrypoints: true, + namedChunkGroups: false, + chunkRelations: true, + chunks: true, + ids: true, + nestedModules: false, + outputPath: true, + publicPath: true, }); - const federatedModules = federationPlugins.map((federationPlugin) => - getFederationStats(stats, federationPlugin) - ); + // Apply a function 'getFederationStats' on the stats with the federation plugin options as the second argument. + const federatedModules = getFederationStats(stats, federationOpts); + // Assign the 'builtExposes' object to the 'exposes' property of the 'federatedModules' object. + federatedModules.exposes = builtExposes; + + // Apply a function 'getMainSharedModules' on the stats. const sharedModules = getMainSharedModules(stats); + // Create a Set to hold the vendor chunks. + const vendorChunks = new Set(); + + // Iterate over the shared modules. + for (const share of sharedModules) { + if (share?.chunks) { + // If a shared module has chunks, add them to the 'vendorChunks' Set. + for (const file of share.chunks) { + vendorChunks.add(file); + } + } + } + + // Construct an object that contains the shared and federated modules. const statsResult = { sharedModules, - federatedModules, + federatedModules: [federatedModules], }; + // Convert the 'statsResult' object to a JSON string. const statsJson = JSON.stringify(statsResult); + + // Convert the JSON string to a buffer. const statsBuffer = Buffer.from(statsJson, 'utf-8'); + + // Construct an object that represents the source of the final asset. const statsSource = { source: () => statsBuffer, size: () => statsBuffer.length, }; + // Get the filename of the final asset from the plugin options. const { filename } = this._options; + // Check if an asset with the same filename already exists. const asset = compilation.getAsset(filename); + + // If an asset with the same filename already exists, update it. Otherwise, create a new asset. if (asset) { compilation.updateAsset(filename, statsSource); } else { diff --git a/packages/node/src/plugins/CommonJsChunkLoadingPlugin.ts b/packages/node/src/plugins/CommonJsChunkLoadingPlugin.ts index 12bed68079c..27a92f8836b 100644 --- a/packages/node/src/plugins/CommonJsChunkLoadingPlugin.ts +++ b/packages/node/src/plugins/CommonJsChunkLoadingPlugin.ts @@ -1,9 +1,7 @@ import type { Chunk, Compiler } from 'webpack'; import type { ModuleFederationPluginOptions } from '../types'; - import RuntimeGlobals from 'webpack/lib/RuntimeGlobals'; import StartupChunkDependenciesPlugin from 'webpack/lib/runtime/StartupChunkDependenciesPlugin'; - import ChunkLoadingRuntimeModule from './LoadFileChunkLoadingRuntimeModule'; interface CommonJsChunkLoadingOptions extends ModuleFederationPluginOptions { @@ -12,7 +10,7 @@ interface CommonJsChunkLoadingOptions extends ModuleFederationPluginOptions { remotes: Record; name?: string; asyncChunkLoading: boolean; - verbose?: boolean; + debug?: boolean; } class CommonJsChunkLoadingPlugin { diff --git a/packages/node/src/plugins/LoadFileChunkLoadingRuntimeModule.ts b/packages/node/src/plugins/LoadFileChunkLoadingRuntimeModule.ts index a780f3add6f..6a28b503177 100644 --- a/packages/node/src/plugins/LoadFileChunkLoadingRuntimeModule.ts +++ b/packages/node/src/plugins/LoadFileChunkLoadingRuntimeModule.ts @@ -22,7 +22,7 @@ interface ReadFileChunkLoadingRuntimeModuleOptions { promiseBaseURI?: string; remotes: Record; name?: string; - verbose?: boolean; + debug?: boolean; } interface ChunkLoadingContext { @@ -70,7 +70,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule { * @param {unknown[]} items item to log */ _getLogger(...items: unknown[]) { - if (!this.options.verbose) { + if (!this.options.debug) { return ''; } @@ -120,6 +120,12 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule { if (c.ids) { for (const id of c.ids) initialChunkIds.add(id); } + for (const c of chunk.getAllAsyncChunks()) { + if (c === chunk || chunkHasJs(c, chunkGraph)) continue; + if (c.ids) { + for (const id of c.ids) initialChunkIds.add(id); + } + } } return initialChunkIds; }; @@ -131,6 +137,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule { const withExternalInstallChunk = this.runtimeRequirements.has( RuntimeGlobals.externalInstallChunk ); + const withOnChunkLoad = this.runtimeRequirements.has( RuntimeGlobals.onChunksLoaded ); @@ -161,6 +168,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule { contentHashType: 'javascript', } ); + const rootOutputDir = getUndoPath( outputName, this.compilation.outputOptions.path, @@ -170,7 +178,6 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule { const stateExpression = withHmr ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm` : undefined; - return Template.asString([ withBaseURI ? this._generateBaseUri(chunk, rootOutputDir) @@ -222,123 +229,111 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule { ])};` : '// no chunk install function needed', '', + withLoading ? + Template.asString([ + "// load script equivalent for server side", + `${RuntimeGlobals.loadScript} = ${runtimeTemplate.basicFunction('url,callback,chunkId', [ + Template.indent([ + "if(!globalThis.__remote_scope__) {", + Template.indent(["// create a global scope for container, similar to how remotes are set on window in the browser", + "globalThis.__remote_scope__ = {", + "_config: {},", + "}", + ]), + "}", + ]), + Template.indent([ + executeLoadTemplate, + `executeLoad(url,callback,chunkId)`, + ]), + ])}`, + ]) : '// no remote script loader needed', withLoading ? Template.asString([ - '// load script equivalent for server side', - `${RuntimeGlobals.loadScript} = ${runtimeTemplate.basicFunction( - 'url,callback,chunkId', - [ - Template.indent([ - 'if(!global.__remote_scope__) {', - Template.indent([ - '// create a global scope for container, similar to how remotes are set on window in the browser', - 'global.__remote_scope__ = {', - '_config: {},', - '}', - ]), - '}', - ]), + '// ReadFile + VM.run chunk loading for javascript', + `${fn}.readFileVm = function(chunkId, promises) {`, + hasJsMatcher !== false + ? Template.indent([ + '', + 'var installedChunkData = installedChunks[chunkId];', + 'if(installedChunkData !== 0) { // 0 means "already installed".', + Template.indent([ + '// array of [resolve, reject, promise] means "currently loading"', + 'if(installedChunkData) {', + Template.indent(['promises.push(installedChunkData[2]);']), + '} else {', Template.indent([ - executeLoadTemplate, - `executeLoad(url,callback,chunkId)`, - ]), - ] - )}`, - ]) - : '// no remote script loader needed', - withLoading - ? Template.asString([ - '// ReadFile + VM.run chunk loading for javascript', - `${fn}.readFileVm = function(chunkId, promises) {`, - hasJsMatcher !== false - ? Template.indent([ - '', - 'var installedChunkData = installedChunks[chunkId];', - 'if(installedChunkData !== 0) { // 0 means "already installed".', + hasJsMatcher === true + ? 'if(true) { // all chunks have JS' + : `if(${hasJsMatcher('chunkId')}) {`, Template.indent([ - '// array of [resolve, reject, promise] means "currently loading"', - 'if(installedChunkData) {', - Template.indent(['promises.push(installedChunkData[2]);']), - '} else {', + '// load the chunk and return promise to it', + 'var promise = new Promise(async function(resolve, reject) {', Template.indent([ - hasJsMatcher === true - ? 'if(true) { // all chunks have JS' - : `if(${hasJsMatcher('chunkId')}) {`, + 'installedChunkData = installedChunks[chunkId] = [resolve, reject];', + `var filename = typeof process !== \"undefined\" ? require('path').join(__dirname, ${JSON.stringify( + rootOutputDir + )} + ${ + RuntimeGlobals.getChunkScriptFilename + }(chunkId)) : false;`, + "var fs = typeof process !== \"undefined\" ? require('fs') : false;", + 'if(fs && fs.existsSync(filename)) {', + this._getLogger( + `'chunk filename local load', chunkId` + ), + Template.indent([ + "fs.readFile(filename, 'utf-8', function(err, content) {", + Template.indent([ + 'if(err) return reject(err);', + 'var chunk = {};', + "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" + + "(chunk, require, require('path').dirname(filename), filename);", + 'installChunk(chunk);', + ]), + '});', + ]), + '} else {', Template.indent([ - '// load the chunk and return promise to it', - 'var promise = new Promise(async function(resolve, reject) {', + loadScriptTemplate, + this._getLogger(`'needs to load remote module from ${JSON.stringify( + name + )}'`), + this._getLogger(`'remotes known to'`, JSON.stringify( + name + ), JSON.stringify(remotes)), + // keys are mostly useless here, we want to find remote by its global (unique name) + `var remotes = ${JSON.stringify( + Object.values(remotes).reduce((acc, remote) => { + //TODO: need to handle all other cases like when remote is not a @ syntax string + const [global, url] = remote.split('@'); + acc[global] = url; + return acc; + }, {} as Record) + )};`, Template.indent([ - 'installedChunkData = installedChunks[chunkId] = [resolve, reject];', - `var filename = require('path').join(__dirname, ${JSON.stringify( - rootOutputDir - )} + ${ - RuntimeGlobals.getChunkScriptFilename - }(chunkId));`, - "var fs = require('fs');", - 'if(fs.existsSync(filename)) {', - Template.indent([ - "fs.readFile(filename, 'utf-8', function(err, content) {", - Template.indent([ - 'if(err) return reject(err);', - 'var chunk = {};', - "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" + - "(chunk, require, require('path').dirname(filename), filename);", - 'installChunk(chunk);', - ]), - '});', + "if(!globalThis.__remote_scope__) {", + Template.indent(["// create a global scope for container, similar to how remotes are set on window in the browser", + "globalThis.__remote_scope__ = {", + "_config: {},", + "}", ]), - '} else {', - Template.indent([ - loadScriptTemplate, - - this._getLogger( - `'needs to load remote module from ${JSON.stringify( - name - )}'` - ), - this._getLogger( - `'remotes known to'`, - JSON.stringify(name), - JSON.stringify(remotes) - ), - - // keys are mostly useless here, we want to find remote by its global (unique name) - `var remotes = ${JSON.stringify( - Object.values(remotesByType.normal).reduce( - (acc, remote) => { - //TODO: need to handle all other cases like when remote is not a @ syntax string - const [global, url] = remote.split('@'); - acc[global] = url; - return acc; - }, - {} as Record - ) - )};`, - 'Object.assign(global.__remote_scope__._config, remotes)', - 'const remoteRegistry = global.__remote_scope__._config', - /* + "}", + ]), + 'Object.assign(globalThis.__remote_scope__._config, remotes)', + 'const remoteRegistry = globalThis.__remote_scope__._config', + /* TODO: keying by global should be ok, but need to verify - need to deal with when user passes promise new promise() global will/should still exist - but can only be known at runtime */ - this._getLogger( - `'remotes keyed by global name'`, - JSON.stringify(remotesByType.normal) - ), - this._getLogger( - `'remote scope configs'`, - 'global.__remote_scope__._config' - ), + this._getLogger(`'remotes keyed by global name'`,JSON.stringify(remotes)), + this._getLogger(`'remote scope configs'`,'globalThis.__remote_scope__._config'), - this._getLogger(`'before remote scope'`), - this._getLogger( - `'global.__remote_scope__'`, - `global.__remote_scope__` - ), - this._getLogger( - `'global.__remote_scope__[${JSON.stringify( - name - )}]'`, - `global.__remote_scope__[${JSON.stringify(name)}]` - ), + this._getLogger(`'before remote scope'`), + this._getLogger(`'globalThis.__remote_scope__'`,`globalThis.__remote_scope__`), + this._getLogger(`'globalThis.__remote_scope__[${JSON.stringify( + name + )}]'`,`globalThis.__remote_scope__[${JSON.stringify( + name + )}]`), /* TODO: this global.REMOTE_CONFIG doesnt work in this v5 core, not sure if i need to keep it or not not deleting it yet since i might need this for tracking all the remote entries across systems @@ -376,58 +371,68 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule { // `var scriptUrl = new URL(requestedRemote.split("@")[1]);`, // since im looping over remote and creating global at build time, i dont need to split string at runtime // there may still be a use case for that with promise new promise, depending on how we design it. - `var scriptUrl = new URL(requestedRemote);`, - this._getLogger( - `'global.__remote_scope__'`, - `global.__remote_scope__` + '"requestedRemote"', + 'requestedRemote', + 'current name', + JSON.stringify(name) ), - `var chunkName = ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`, - this._getLogger( - `'chunkname to request'`, - `chunkName` - ), - `var fileToReplace = require('path').basename(scriptUrl.pathname);`, - `scriptUrl.pathname = scriptUrl.pathname.replace(fileToReplace, chunkName);`, - this._getLogger( - `'will load remote chunk'`, - `scriptUrl.toString()` - ), - `loadScript(scriptUrl.toString(), function(err, content) {`, - Template.indent([ - this._getLogger(`'load script callback fired'`), - "if(err) {console.error('error loading remote chunk', scriptUrl.toString(),'got',content,'with error', err); return reject(err);}", - 'var chunk = {};', - 'try {', - "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" + - "(chunk, require, require('path').dirname(filename), filename);", - '} catch (e) {', - "console.error('runInThisContext threw', e)", - '}', - 'installChunk(chunk);', - ]), - '}, chunkId);', - ]), + `var scriptUrl = new URL(requestedRemote);`, + + this._getLogger(`'globalThis.__remote_scope__'`,`globalThis.__remote_scope__`), + `var chunkName = ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`, + this._getLogger(`'chunkname to request'`,`chunkName`), + ` + var getBasenameFromUrl = (url) => { + const urlParts = url.split('/'); + return urlParts[urlParts.length - 1]; + }; + var fileToReplace = typeof process !== "undefined" ? require('path').basename(scriptUrl.pathname) : getBasenameFromUrl(scriptUrl.pathname);`, + `scriptUrl.pathname = scriptUrl.pathname.replace(fileToReplace, chunkName);`, + this._getLogger(`'will load remote chunk'`, `scriptUrl.toString()`), + `loadScript(scriptUrl.toString(), function(err, content) {`, + Template.indent([ + this._getLogger(`'load script callback fired'`), + "if(err) {console.error('error loading remote chunk', scriptUrl.toString(),'got',content); return reject(err);}", + 'var chunk = {};', + "if(typeof process !== 'undefined') {", + 'try {', + "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" + + "(chunk, require, require('path').dirname(filename), filename);", + '} catch (e) {', + "console.error('runInThisContext threw', e)", '}', + '} else {', + "eval('(function(exports, require, __dirname, __filename) {' + content + '\\n})')(chunk, __webpack_require__, '.', chunkName);", + '}', + 'installChunk(chunk);', ]), '});', - 'promises.push(installedChunkData[2] = promise);', ]), - '} else installedChunks[chunkId] = 0;', + '}', ]), - '}', + '});', + 'promises.push(installedChunkData[2] = promise);', ]), - '}', - ]) - : Template.indent(['installedChunks[chunkId] = 0;']), - '};', - ]) + '} else installedChunks[chunkId] = 0;', + ]), + '}', + ]), + '}', + ]) + : Template.indent(['installedChunks[chunkId] = 0;']), + '};', + ]) : '// no chunk loading', '', withExternalInstallChunk ? Template.asString([ 'module.exports = __webpack_require__;', - `${RuntimeGlobals.externalInstallChunk} = installChunk;`, + `${RuntimeGlobals.externalInstallChunk} = function(){`, + this.options.debug + ? `console.debug('node: webpack installing to install chunk id:', arguments['0'].id);` + : '', + `return installChunk.apply(this, arguments)};`, ]) : '// no external install chunk', '', diff --git a/packages/node/src/plugins/NodeFederationPlugin.ts b/packages/node/src/plugins/NodeFederationPlugin.ts index 7c54f161755..51098184e31 100644 --- a/packages/node/src/plugins/NodeFederationPlugin.ts +++ b/packages/node/src/plugins/NodeFederationPlugin.ts @@ -6,7 +6,7 @@ import { extractUrlAndGlobal } from '@module-federation/utilities'; interface NodeFederationOptions extends ModuleFederationPluginOptions { experiments?: Record; - verbose?: boolean; + debug?: boolean; } interface Context { @@ -47,31 +47,21 @@ export const generateRemoteTemplate = ( url: string, global: any ) => `new Promise(function (resolve, reject) { - if(!global.__remote_scope__) { + if(!globalThis.__remote_scope__) { // create a global scope for container, similar to how remotes are set on window in the browser - global.__remote_scope__ = { + globalThis.__remote_scope__ = { _config: {}, } } - if (typeof global.__remote_scope__[${JSON.stringify( - global - )}] !== 'undefined') return resolve(global.__remote_scope__[${JSON.stringify( - global -)}]); - global.__remote_scope__._config[${JSON.stringify( - global - )}] = ${JSON.stringify(url)}; + if (typeof globalThis.__remote_scope__[${JSON.stringify(global)}] !== 'undefined') return resolve(globalThis.__remote_scope__[${JSON.stringify(global)}]); + globalThis.__remote_scope__._config[${JSON.stringify(global)}] = ${JSON.stringify(url)}; var __webpack_error__ = new Error(); __webpack_require__.l( ${JSON.stringify(url)}, function (event) { - if (typeof global.__remote_scope__[${JSON.stringify( - global - )}] !== 'undefined') return resolve(global.__remote_scope__[${JSON.stringify( - global -)}]); + if (typeof globalThis.__remote_scope__[${JSON.stringify(global)}] !== 'undefined') return resolve(globalThis.__remote_scope__[${JSON.stringify(global)}]); var realSrc = event && event.target && event.target.src; __webpack_error__.message = 'Loading script failed.\\n(' + event.message + ': ' + realSrc + ')'; __webpack_error__.name = 'ScriptExternalLoadError'; @@ -89,7 +79,7 @@ export const generateRemoteTemplate = ( return { fake: true, get: (arg) => { - console.log('faking', arg, 'module on', ${JSON.stringify(global)}); + console.warn('faking', arg, 'module on', ${JSON.stringify(global)}); return Promise.resolve(() => { return () => null @@ -102,59 +92,7 @@ export const generateRemoteTemplate = ( if(remote.fake) { return remote; } - const proxy = { - get: (arg)=>{ - return remote.get(arg).then((f)=>{ - const m = f(); - return ()=>new Proxy(m, { - get: (target, prop)=>{ - if(global.usedChunks) global.usedChunks.add(${JSON.stringify( - global - )} + "->" + arg); - return target[prop]; - } - }) - }) - }, - init: function(shareScope) { - const handler = { - get(target, prop) { - if (target[prop]) { - Object.values(target[prop]).forEach(function(o) { - if(o.from === '_N_E') { - o.loaded = 1 - } - }) - } - return target[prop] - }, - set(target, property, value) { - if(global.usedChunks) global.usedChunks.add(${JSON.stringify( - global - )} + "->" + property); - if (target[property]) { - return target[property] - } - target[property] = value - return true - } - } - try { - global.__remote_scope__[${JSON.stringify( - global - )}].init(new Proxy(shareScope, handler)) - } catch (e) { - - } - global.__remote_scope__[${JSON.stringify(global)}].__initialized = true - } - } - try { - proxy.init(__webpack_require__.S.default) - } catch(e) { - console.error('failed to init', ${JSON.stringify(global)}, e) - } - return proxy + return remote; })`; /* @@ -179,7 +117,7 @@ class NodeFederationPlugin { private experiments: NodeFederationOptions['experiments']; constructor( - { experiments, verbose, ...options }: NodeFederationOptions, + { experiments, debug, ...options }: NodeFederationOptions, context: Context ) { this._options = options || ({} as ModuleFederationPluginOptions); @@ -191,14 +129,6 @@ class NodeFederationPlugin { // When used with Next.js, context is needed to use Next.js webpack const { webpack } = compiler; - // const defs = { - // 'process.env.REMOTES': runtime, - // 'process.env.REMOTE_CONFIG': hot, - // }; - - // new ((webpack && webpack.DefinePlugin) || require("webpack").DefinePlugin)( - // defs - // ).apply(compiler); const pluginOptions = { ...this._options, remotes: parseRemotes( @@ -207,15 +137,33 @@ class NodeFederationPlugin { }; const chunkFileName = compiler.options?.output?.chunkFilename; - if ( - typeof chunkFileName === 'string' && - !chunkFileName.includes('[hash]') && - !chunkFileName.includes('[contenthash]') - ) { - compiler.options.output.chunkFilename = chunkFileName.replace( - '.js', - '.[contenthash].js' - ); + const uniqueName = + compiler?.options?.output?.uniqueName || this._options.name; + + if (typeof chunkFileName === 'string') { + const requiredSubstrings = [ + '[chunkhash]', + '[contenthash]', + '[fullHash]', + uniqueName, + ]; + + if ( + //@ts-ignore + !requiredSubstrings.some((substring) => + //@ts-ignore + chunkFileName.includes(substring) + ) + ) { + const suffix = + compiler.options.mode === 'development' + ? `.[chunkhash].js` + : `.[chunkhash].js`; + compiler.options.output.chunkFilename = chunkFileName.replace( + '.js', + suffix + ); + } } new (this.context.ModuleFederationPlugin || diff --git a/packages/node/src/plugins/StreamingTargetPlugin.ts b/packages/node/src/plugins/StreamingTargetPlugin.ts index 2ab24633290..92022ae99c7 100644 --- a/packages/node/src/plugins/StreamingTargetPlugin.ts +++ b/packages/node/src/plugins/StreamingTargetPlugin.ts @@ -5,7 +5,7 @@ import CommonJsChunkLoadingPlugin from './CommonJsChunkLoadingPlugin'; interface StreamingTargetOptions extends ModuleFederationPluginOptions { promiseBaseURI?: string; - verbose?: boolean; + debug?: boolean; } // eslint-disable-next-line @typescript-eslint/no-empty-interface @@ -50,16 +50,17 @@ class StreamingTargetPlugin { new (webpack?.node?.NodeTargetPlugin || require('webpack/lib/node/NodeTargetPlugin'))().apply(compiler); - new CommonJsChunkLoadingPlugin({ asyncChunkLoading: true, name: this.options.name, remotes: this.options.remotes as Record, baseURI: compiler.options.output.publicPath, promiseBaseURI: this.options.promiseBaseURI, - verbose: this.options.verbose, + debug: this.options.debug, }).apply(compiler); } } export default StreamingTargetPlugin; + + diff --git a/packages/node/src/plugins/UniversalFederationPlugin.ts b/packages/node/src/plugins/UniversalFederationPlugin.ts index 6cc0ea07fc9..5437f8d0474 100644 --- a/packages/node/src/plugins/UniversalFederationPlugin.ts +++ b/packages/node/src/plugins/UniversalFederationPlugin.ts @@ -6,7 +6,7 @@ import type { Compiler, container } from 'webpack'; interface NodeFederationOptions extends ModuleFederationPluginOptions { isServer: boolean; promiseBaseURI?: string; - verbose?: boolean; + debug?: boolean; } interface NodeFederationContext { @@ -23,12 +23,12 @@ class UniversalFederationPlugin { } apply(compiler: Compiler) { - const { isServer, verbose, ...options } = this._options; + const { isServer, debug, ...options } = this._options; const { webpack } = compiler; if (isServer || compiler.options.name === 'server') { new NodeFederationPlugin(options, this.context).apply(compiler); - new StreamingTargetPlugin({ ...options, verbose }).apply(compiler); + new StreamingTargetPlugin({ ...options, debug }).apply(compiler); } else { new (this.context.ModuleFederationPlugin || (webpack && webpack.container.ModuleFederationPlugin) || diff --git a/packages/node/src/plugins/loadScript.ts b/packages/node/src/plugins/loadScript.ts index e382106af0a..04e2b5787f2 100644 --- a/packages/node/src/plugins/loadScript.ts +++ b/packages/node/src/plugins/loadScript.ts @@ -6,16 +6,28 @@ //language=JS export default ` function loadScript(url, cb, chunkID) { - if (global.webpackChunkLoad) { - global.webpackChunkLoad(url).then(function (resp) { + var url; + var cb = arguments[arguments.length - 1]; + if (typeof cb !== "function") { + throw new Error("last argument should be a function"); + } + if (arguments.length === 2) { + url = arguments[0]; + } else if (arguments.length === 3) { + url = new URL(arguments[1], arguments[0]).toString(); + } else { + throw new Error("invalid number of arguments"); + } + if (globalThis.webpackChunkLoad) { + globalThis.webpackChunkLoad(url).then(function (resp) { return resp.text(); }).then(function (rawData) { cb(null, rawData); }).catch(function (err) { - console.error('Federated Chunk load failed', error); - return cb(error) + console.error('Federated Chunk load failed', err); + return cb(err) }); - } else { + } else if (typeof process !== 'undefined') { //TODO https support let request = (url.startsWith('https') ? require('https') : require('http')).get(url, function (resp) { if (resp.statusCode === 200) { @@ -35,6 +47,15 @@ export default ` console.error('Federated Chunk load failed', error); return cb(error) }); + } else { + fetch(url).then(function (resp) { + return resp.text(); + }).then(function (rawData) { + cb(null, rawData); + }).catch(function (err) { + console.error('Federated Chunk load failed', err); + return cb(err) + }) } } `; @@ -43,47 +64,51 @@ export default ` //language=JS export const executeLoadTemplate = ` function executeLoad(url, callback, name) { - if(!name) { + if (!name) { throw new Error('__webpack_require__.l name is required for ' + url); } + if (typeof globalThis.__remote_scope__[name] !== 'undefined') return callback(globalThis.__remote_scope__[name]); + // if its a worker or node + if (typeof process !== 'undefined') { + const vm = require('vm'); + (globalThis.webpackChunkLoad || globalThis.fetch || require("node-fetch"))(url).then(function (res) { + return res.text(); + }).then(function (scriptContent) { + try { + const m = require('module'); - if (typeof global.__remote_scope__[name] !== 'undefined') return callback(global.__remote_scope__[name]); - - const vm = require('vm'); - (global.webpackChunkLoad || global.fetch || require("node-fetch"))(url).then(function (res) { - return res.text(); - }).then(function (scriptContent) { - try { - // TODO: remove conditional in v7, this is to prevent breaking change between v6.0.x and v6.1.x - const vmContext = typeof URLSearchParams === 'undefined' ? - {exports, require, module, global, __filename, __dirname, URL, console, process,Buffer, ...global, remoteEntryName: name} : - {exports, require, module, global, __filename, __dirname, URL, URLSearchParams, console, process,Buffer, ...global, remoteEntryName: name}; - - const remote = vm.runInNewContext(scriptContent + '\\nmodule.exports', vmContext, {filename: 'node-federation-loader-' + name + '.vm'}); - const foundContainer = remote[name] || remote - - if(!global.__remote_scope__[name]) { - global.__remote_scope__[name] = { - get: foundContainer.get, - init: function(initScope, initToken) { - try { - foundContainer.init(initScope, initToken) - } catch (e) { - // already initialized - } - } - }; - global.__remote_scope__._config[name] = url; + const remoteCapsule = vm.runInThisContext(m.wrap(scriptContent), 'node-federation-loader-' + name + '.vm') + const exp = {}; + let remote = {exports:{}}; + remoteCapsule(exp,require,remote,'node-federation-loader-' + name + '.vm',__dirname); + remote = remote.exports || remote; + globalThis.__remote_scope__[name] = remote[name] || remote; + globalThis.__remote_scope__._config[name] = url; + callback(globalThis.__remote_scope__[name]) + } catch (e) { + console.error('executeLoad hit catch block', e); + e.target = {src: url}; + callback(e); } - callback(global.__remote_scope__[name]); - } catch (e) { - console.error('executeLoad hit catch block'); + }).catch((e) => { e.target = {src: url}; callback(e); - } - }).catch((e) => { - e.target = {src: url}; - callback(e); - }); + }); + } else { + fetch(url).then(function (res) { + return res.text(); + }).then(function (scriptContent) { + try { + const remote = eval('let module = {};' + scriptContent + '\\nmodule.exports') + globalThis.__remote_scope__[name] = remote[name] || remote; + globalThis.__remote_scope__._config[name] = url; + callback(globalThis.__remote_scope__[name]) + } catch (e) { + console.error('executeLoad hit catch block',e); + e.target = {src: url}; + callback(e); + } + }); + } } `; diff --git a/packages/node/src/utils/flush-chunks.ts b/packages/node/src/utils/flush-chunks.ts index d67a580df28..7acf17ee9b2 100644 --- a/packages/node/src/utils/flush-chunks.ts +++ b/packages/node/src/utils/flush-chunks.ts @@ -1,54 +1,180 @@ -export const usedChunks = new Set(); -//@ts-ignore -global.usedChunks = usedChunks; +/* eslint-disable no-undef */ -export const flushChunks = async () => { - const allFlushed = await Promise.all( - //@ts-ignore - Array.from(usedChunks).map(async (chunk: any) => { - const chunks = new Set(); - const [remote, request] = chunk.split('->'); - if (!global.__remote_scope__._config[remote]) { - return; +// @ts-ignore +if (!globalThis.usedChunks) { +// @ts-ignore + globalThis.usedChunks = new Set(); +} +/** + * Initialize usedChunks and share it globally. + * @type {Set} + */ +// @ts-ignore +export const usedChunks = globalThis.usedChunks; +/** + * Load hostStats from the JSON file. + * @returns {object} hostStats - An object containing host stats data. + */ +const loadHostStats = () => { + try { + return __non_webpack_require__('../federated-stats.json'); + } catch (e) { + return {}; + } +}; + +/** + * Create a shareMap based on the loaded modules. + * @returns {object} shareMap - An object containing the shareMap data. + */ +const createShareMap = () => { + // Check if __webpack_share_scopes__ is defined and has a default property +// @ts-ignore + if (__webpack_share_scopes__?.default) { + // Reduce the keys of the default property to create the share map +// @ts-ignore + return Object.keys(__webpack_share_scopes__.default).reduce((acc, key) => { + // Get the loaded modules for the current key +// @ts-ignore + const loadedModules = Object.values(__webpack_share_scopes__.default[key]) + // Filter out the modules that are not loaded + // @ts-ignore + .filter((sharedModule) => sharedModule.loaded) + // Map the filtered modules to their 'from' properties + // @ts-ignore + .map((sharedModule) => sharedModule.from); + + // If there are any loaded modules, add them to the accumulator object + if (loadedModules.length > 0) { +// @ts-ignore + acc[key] = loadedModules; } - // fetch the json file - try { - const statsFile = global.__remote_scope__._config[remote].replace( - 'remoteEntry.js', - 'federated-stats.json' - ); - const stats = await fetch(statsFile).then( - async (res) => await res.json() - ); - chunks.add( - global.__remote_scope__._config[remote].replace('ssr', 'chunks') - ); - const [prefix] = - global.__remote_scope__._config[remote].split('static/'); - if (stats.federatedModules) { - stats.federatedModules.forEach((modules: any) => { - if (modules.exposes?.[request]) { - modules.exposes[request].forEach((chunk: any) => { - Object.values(chunk).forEach((chunk) => { - //@ts-ignore - chunk.forEach((chunk: any) => { - chunks.add(prefix + chunk); - }); + // Return the accumulator object for the next iteration + return acc; + }, {}); + } + // If __webpack_share_scopes__ is not defined or doesn't have a default property, return an empty object + return {}; +}; + +/** + * Process a single chunk and return an array of updated chunks. + * @param {string} chunk - A chunk string containing remote and request data. + * @param {object} shareMap - An object containing the shareMap data. + * @param {object} hostStats - An object containing host stats data. + * @returns {Promise} A promise that resolves to an array of updated chunks. + */ +// @ts-ignore +const processChunk = async (chunk, shareMap, hostStats) => { + // Create a set to store the chunks + const chunks = new Set(); + + // Split the chunk string into remote and request + const [remote, request] = chunk.split('->'); + + // If the remote is not defined in the global config, return + if (!globalThis.__remote_scope__._config[remote]) { + console.error( + `flush chunks:`, + `Remote ${remote} is not defined in the global config` + ); + return; + } + + try { + // Extract the remote name from the URL + //@ts-ignore + const remoteName = new URL(globalThis.__remote_scope__._config[remote]).pathname + .split('/') + .pop(); + + // Construct the stats file URL from the remote config + const statsFile = globalThis.__remote_scope__._config[remote] + .replace(remoteName, 'federated-stats.json') + .replace('ssr', 'chunks'); + + let stats = {}; + try { + // Fetch the remote config and stats file + stats = await fetch(statsFile).then((res) => res.json()); + } catch (e) { + console.error('flush error', e); + } + + // Add the main chunk to the chunks set + //TODO: ensure host doesnt embed its own remote in ssr, this causes crash + // chunks.add( + // global.__remote_scope__._config[remote].replace('ssr', 'chunks') + // ); + + // Extract the prefix from the remote config + const [prefix] = globalThis.__remote_scope__._config[remote].split('static/'); + + // Process federated modules from the stats object +// @ts-ignore + if (stats.federatedModules) { +// @ts-ignore + stats.federatedModules.forEach((modules) => { + // Process exposed modules + if (modules.exposes?.[request]) { +// @ts-ignore + modules.exposes[request].forEach((chunk) => { + chunks.add([prefix, chunk].join('')); + + //TODO: reimplement this + Object.values(chunk).forEach((chunk) => { + // Add files to the chunks set +// @ts-ignore + if (chunk.files) { +// @ts-ignore + chunk.files.forEach((file) => { + chunks.add(prefix + file); + }); + } + // Process required modules +// @ts-ignore + if (chunk.requiredModules) { +// @ts-ignore + chunk.requiredModules.forEach((module) => { + // Check if the module is in the shareMap + if (shareMap[module]) { + // If the module is from the host, log the host stats + + } }); - }); - } + } + }); }); } + }); + } - return Array.from(chunks); - } catch (e) { - console.log(e); - } - }) + // Return the array of chunks + return Array.from(chunks); + } catch (e) { + console.error('flush error:', e); + } +}; + +/** + * Flush the chunks and return a deduplicated array of chunks. + * @returns {Promise} A promise that resolves to an array of deduplicated chunks. + */ +export const flushChunks = async () => { + const hostStats = loadHostStats(); + const shareMap = createShareMap(); + + const allFlushed = await Promise.all( + Array.from(usedChunks).map(async (chunk) => + processChunk(chunk, shareMap, hostStats) + ) ); + // Deduplicate the chunks array const dedupe = Array.from(new Set([...allFlushed.flat()])); + // Clear usedChunks usedChunks.clear(); + // Filter out any undefined or null values return dedupe.filter(Boolean); }; diff --git a/packages/node/src/utils/hot-reload.ts b/packages/node/src/utils/hot-reload.ts index 326b65c6166..26eef601fe1 100644 --- a/packages/node/src/utils/hot-reload.ts +++ b/packages/node/src/utils/hot-reload.ts @@ -1,6 +1,7 @@ const hashmap = {} as Record; import crypto from 'crypto'; -const requireCacheRegex = /(remote|runtime|server|hot-reload|react-loadable-manifest)/; +const requireCacheRegex = + /(remote|runtime|server|hot-reload|react-loadable-manifest)/; const performReload = (shouldReload: any) => { if (!shouldReload) { @@ -14,10 +15,14 @@ const performReload = (shouldReload: any) => { } //@ts-ignore - global.__remote_scope__ = { + globalThis.__remote_scope__ = { _config: {}, - _medusa: {} + _medusa: {}, }; + //@ts-ignore + globalThis.backupScope = {}; + //@ts-ignore + globalThis.factoryTracker = {}; Object.keys(req.cache).forEach((key) => { if (requireCacheRegex.test(key)) { @@ -26,7 +31,7 @@ const performReload = (shouldReload: any) => { }); return true; -} +}; /* This code is doing two things First it checks if there are any fake remotes in the global scope If so then we need to reload the server because a remote has changed @@ -34,15 +39,16 @@ const performReload = (shouldReload: any) => { webpack whether its hash has changed since last time or not */ export const revalidate = () => { - if (global.__remote_scope__) { - const remoteScope = global.__remote_scope__; - + //@ts-ignore + if (globalThis.__remote_scope__) { + //@ts-ignore + const remoteScope = globalThis.__remote_scope__; return new Promise((res) => { const fetches = []; for (const property in remoteScope) { if (remoteScope[property].fake) { - console.log( + console.error( 'unreachable remote found', property, 'hot reloading to refetch' @@ -54,20 +60,26 @@ export const revalidate = () => { const fetchModule = getFetchModule(); - if(remoteScope._medusa) { + if (remoteScope._medusa) { for (const property in remoteScope._medusa) { - fetchModule(property).then((res:Response)=>res.json()).then((medusaResponse: any) => { - //@ts-ignore - if(medusaResponse.version !== remoteScope._medusa[property].version) { - console.log( - 'medusa config changed', - property, - 'hot reloading to refetch' - ); - performReload(true); - return res(true); - } - }); + fetchModule(property) + .then((res: Response) => res.json()) + .then((medusaResponse: any) => { + //@ts-ignore + if ( + medusaResponse.version !== + //@ts-ignore + remoteScope?._medusa[property].version + ) { + console.log( + 'medusa config changed', + property, + 'hot reloading to refetch' + ); + performReload(true); + return res(true); + } + }); } } @@ -149,7 +161,8 @@ export const revalidate = () => { allows us to use fetch in our tests without having to mock out nodefetch */ function getFetchModule() { - const loadedModule = global.webpackChunkLoad || global.fetch; + //@ts-ignore + const loadedModule = globalThis.webpackChunkLoad || global.webpackChunkLoad || global.fetch; if (loadedModule) { return loadedModule; } diff --git a/packages/storybook-addon/project.json b/packages/storybook-addon/project.json index 15316dac6fa..2758068b3a1 100644 --- a/packages/storybook-addon/project.json +++ b/packages/storybook-addon/project.json @@ -24,7 +24,9 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/storybook-addon/**/*.ts"] + "lintFilePatterns": [ + "packages/storybook-addon/**/*.ts" + ] } }, "test": { @@ -44,7 +46,10 @@ "version": { "executor": "@jscutlery/semver:version", "options": { - "postTargets": ["storybook-addon:npm", "storybook-addon:github"], + "postTargets": [ + "storybook-addon:npm", + "storybook-addon:github" + ], "trackDeps": true, "push": true } @@ -65,5 +70,7 @@ } }, "tags": [], - "implicitDependencies": ["utils"] + "implicitDependencies": [ + "utils" + ] } diff --git a/packages/storybook-addon/src/lib/storybook-addon.spec.ts b/packages/storybook-addon/src/lib/storybook-addon.spec.ts index 466c8634883..e9cdb85d2f2 100644 --- a/packages/storybook-addon/src/lib/storybook-addon.spec.ts +++ b/packages/storybook-addon/src/lib/storybook-addon.spec.ts @@ -42,7 +42,7 @@ describe('webpack()', () => { ); }); - xit('should return config for webpack 5 version', async () => { + it('should return config for webpack 5 version', async () => { const apply = jest.fn().mockImplementation(async (preset: Preset) => { if (preset === 'webpackVersion') { return '5'; diff --git a/packages/utilities/CHANGELOG.md b/packages/utilities/CHANGELOG.md index 2cb51da9258..c3d8b431b28 100644 --- a/packages/utilities/CHANGELOG.md +++ b/packages/utilities/CHANGELOG.md @@ -2,6 +2,266 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [1.9.2-rc.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.9.2-rc.0...utils-1.9.2-rc.1) (2023-07-01) + + +### Features + +* support edge workers ([#1084](https://github.com/module-federation/nextjs-mf/issues/1084)) ([3f5df94](https://github.com/module-federation/nextjs-mf/commit/3f5df944ea787cf958fd4cf7fabed84432a50a10)) + + + +## [1.9.2-rc.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.9.1...utils-1.9.2-rc.0) (2023-06-30) + + + +## [1.8.2-rc8.2](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.2-rc8.1...utils-1.8.2-rc8.2) (2023-06-28) + + + +## [1.8.2-rc8.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.2-rc8.0...utils-1.8.2-rc8.1) (2023-06-28) + + +### Bug Fixes + +* disable flushing remotes to ssr for now ([6c5cfae](https://github.com/module-federation/nextjs-mf/commit/6c5cfaec3be94aeb3f1e12c24965b3904da23bae)) + + + +## [1.8.2-rc8.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.2-rc7.1...utils-1.8.2-rc8.0) (2023-06-27) + + + +## [1.8.2-rc7.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.2-rc7.0...utils-1.8.2-rc7.1) (2023-06-27) + + + +## [1.8.2-rc7.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.2-rc6.0...utils-1.8.2-rc7.0) (2023-06-27) + + + +## [1.8.2-rc6.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.2-rc5.0...utils-1.8.2-rc6.0) (2023-06-23) + + + +## [1.8.2-rc5.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.2-rc4.0...utils-1.8.2-rc5.0) (2023-06-23) + + + +## [1.8.2-rc4.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.2-rc3.1...utils-1.8.2-rc4.0) (2023-06-21) + + +### Bug Fixes + +* Resolve condition names ([#974](https://github.com/module-federation/nextjs-mf/issues/974)) ([5e8b49c](https://github.com/module-federation/nextjs-mf/commit/5e8b49cf60f19dae6be4818a1c0ff783c7689393)) +* Runtime module checking ([#969](https://github.com/module-federation/nextjs-mf/issues/969)) ([b5c7af1](https://github.com/module-federation/nextjs-mf/commit/b5c7af1697a63d9e19f901238a4c0382ea0c3f50)) + + + +## [1.8.2-rc3.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.2-rc3.0...utils-1.8.2-rc3.1) (2023-06-09) + + +### Bug Fixes + +* Path loader patches ([#960](https://github.com/module-federation/nextjs-mf/issues/960)) ([d362a77](https://github.com/module-federation/nextjs-mf/commit/d362a7752c4364cc499a27f2b6eeb5399543cb29)) + + + +## [1.8.2-rc3.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.2-beta.0...utils-1.8.2-rc3.0) (2023-06-09) + + + +## [1.8.2-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.1...utils-1.8.2-beta.0) (2023-05-26) + + + +## [1.8.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.1-rc1.0...utils-1.8.1) (2023-05-26) + + +### Bug Fixes + +* Improve chunk correlation ([#936](https://github.com/module-federation/nextjs-mf/issues/936)) ([4dad1eb](https://github.com/module-federation/nextjs-mf/commit/4dad1eb370feacd6ecb4c1726c435d5c579f424d)) + + + +## [1.8.1-rc1.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.1-rc.1...utils-1.8.1-rc1.0) (2023-05-25) + + + +## [1.8.1-rc.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.1-rc.0...utils-1.8.1-rc.1) (2023-05-23) + + + +## [1.8.1-rc.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.8.0...utils-1.8.1-rc.0) (2023-05-23) + + +### Bug Fixes + +* client prod build issues ([#899](https://github.com/module-federation/nextjs-mf/issues/899)) ([470d7ad](https://github.com/module-federation/nextjs-mf/commit/470d7ad408ae8d64dbccc5a9528eaa2ed60fa2ca)) +* externalization and missing runtime chunks ([#887](https://github.com/module-federation/nextjs-mf/issues/887)) ([c79cd62](https://github.com/module-federation/nextjs-mf/commit/c79cd6226d3134f1d6294cd8eba40c8c33af5cb5)) + + + +## [1.7.6-rc.2](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.6-rc.1...utils-1.7.6-rc.2) (2023-05-17) + + + +## [1.7.6-rc.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.6-rc.0...utils-1.7.6-rc.1) (2023-05-17) + + + +## [1.7.6-rc.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.6-beta.2...utils-1.7.6-rc.0) (2023-05-16) + + + +## [1.7.6-beta.2](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.6-beta.1...utils-1.7.6-beta.2) (2023-05-16) + + + +## [1.7.6-beta.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.6-beta.0...utils-1.7.6-beta.1) (2023-05-16) + + + +## [1.7.6-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.5...utils-1.7.6-beta.0) (2023-05-16) + + + +## [1.7.5](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.5-beta.0...utils-1.7.5) (2023-05-16) + + + +## [1.7.5-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.4...utils-1.7.5-beta.0) (2023-05-16) + + +### Bug Fixes + +* Improved Share Scope Properties and Fixed Production Build Issues ([#884](https://github.com/module-federation/nextjs-mf/issues/884)) ([de7b2ce](https://github.com/module-federation/nextjs-mf/commit/de7b2cec7518f6b069818a511275e359c616bb73)) + + + +## [1.7.4](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.3...utils-1.7.4) (2023-05-16) + + + +## [1.7.3](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.3-beta.0...utils-1.7.3) (2023-05-13) + + + +## [1.7.3-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.2...utils-1.7.3-beta.0) (2023-05-13) + + +### Features + +* [v7] Async boundary runtime ([#835](https://github.com/module-federation/nextjs-mf/issues/835)) ([840e3b5](https://github.com/module-federation/nextjs-mf/commit/840e3b5bddfbb99b5d8d0f5f24bf5e179e8b52ad)), closes [#851](https://github.com/module-federation/nextjs-mf/issues/851) [#864](https://github.com/module-federation/nextjs-mf/issues/864) + + +### BREAKING CHANGES + +* automaticAsyncBoundary option has been removed + +* fix: exclude specific pages from page map automatically + +* refactor: conslidate codebase + +* fix: improve hot reload share recovery + +* refactor: remove server jsonp template + +* chore: remove dead code from runtime modules + +* fix: clean up jsonp getCustomJsonpCode + +getting chunk loading global from compiler output options + +* feat: adding cleanInitArrays runtime helper + +* chore: remove share scope hoist and module hoisting system + +* chore: cleanup code + +* chore: remove dead code from add module runtime plugin + +likely can remove whole plugin in future + +* chore: remove logs from delegate modules + +* chore: remove old utils + +* fix: add warning on auto page stitch + +* fix: remove commented out code from InvertedContainerPlugin.ts + +* chore: improve logging to see if its local load or remote load + +* chore: clean up old custom promises factories + +* fix: remove container proxy code + +* fix: remove container proxy code + + + +## [1.7.2](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.2-beta.0...utils-1.7.2) (2023-05-03) + + + +## [1.7.2-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.1...utils-1.7.2-beta.0) (2023-05-03) + + + +## [1.7.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.1-beta.0...utils-1.7.1) (2023-04-28) + + + +## [1.7.1-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.7.0...utils-1.7.1-beta.0) (2023-04-28) + + +### Features + +* Improve module chunk connections ([#802](https://github.com/module-federation/nextjs-mf/issues/802)) ([ce0bd7b](https://github.com/module-federation/nextjs-mf/commit/ce0bd7b16e080f712e6db0bdcd3955a8167c274f)), closes [#803](https://github.com/module-federation/nextjs-mf/issues/803) [#808](https://github.com/module-federation/nextjs-mf/issues/808) [#811](https://github.com/module-federation/nextjs-mf/issues/811) + + + +## [1.5.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.5.1-beta.0...utils-1.5.1) (2023-04-19) + + + +## [1.5.1-beta.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.5.0...utils-1.5.1-beta.0) (2023-04-19) + + +### Bug Fixes + +* use container proxy on script VM instead of host resolver point ([2929d0f](https://github.com/module-federation/nextjs-mf/commit/2929d0f64d4b8edf268af5ca83f807a02b121861)) +* cache busting and async quirks when mixing delegates ([1fc6e67](https://github.com/module-federation/nextjs-mf/commit/1fc6e67ee33a3efb53ff59d2b3ac333f1d42a158)) +* get delegates working ([#527](https://github.com/module-federation/nextjs-mf/issues/527)) ([7655568](https://github.com/module-federation/nextjs-mf/commit/7655568fcef8dbfda40573deb5d3d029c101074c)) +* improved asset pipeline ([63928b2](https://github.com/module-federation/nextjs-mf/commit/63928b28150c2c4e3adb9e14fb7aa54f5cf1578d)) +* peer dependencies metadata ([d3a2ed0](https://github.com/module-federation/nextjs-mf/commit/d3a2ed0e378b59afdeb632d1e2e0290f05cbca19)) +* put error triggers if delegates are passed non-primitives ([2469383](https://github.com/module-federation/nextjs-mf/commit/2469383de68a8b6ffb7375ad335a2039e563fd71)) +* use EntryPlugin for injection of remotes ([e522c5a](https://github.com/module-federation/nextjs-mf/commit/e522c5ad2b7adcbd6c39f9c5fdb7a3e418277b7a)) + + +### Features + +* chunk flushing in delegates ([07aebc4](https://github.com/module-federation/nextjs-mf/commit/07aebc428166b3f19bb49071fa6745ed705413b8)) +* chunk flushing in delegates ([f8b8af6](https://github.com/module-federation/nextjs-mf/commit/f8b8af6e9e748605dd55d19ae50b0d60b1b0a83f)) +* chunk flushing in delegates ([5e2375f](https://github.com/module-federation/nextjs-mf/commit/5e2375f598437803105ac4bc2237f6b652554d00)) +* delegate module support ([18c9491](https://github.com/module-federation/nextjs-mf/commit/18c94914e5429584e66be49d92781b781adddb38)) +* delegate module support ([8dd154c](https://github.com/module-federation/nextjs-mf/commit/8dd154c261b34183b12250ce204904cd3e085658)) +* delegates part two ([1be2686](https://github.com/module-federation/nextjs-mf/commit/1be2686624798a7df9f447b48279294985b3f592)) +* implement basic single runtime ([2432c3e](https://github.com/module-federation/nextjs-mf/commit/2432c3ec553759ca24d17a46b696c1123a86ec5a)) +* improve chunk correlation ([22d8afc](https://github.com/module-federation/nextjs-mf/commit/22d8afccff101044fcdeba390656950dbc6eafed)) +* new chunk flushing system for exposed modules ([97a75d8](https://github.com/module-federation/nextjs-mf/commit/97a75d8702f2ddc5e12cff2ac4d24aca1df6f990)) +* prepare for v7 ([7bc4b3b](https://github.com/module-federation/nextjs-mf/commit/7bc4b3bd44e0926a52d6a9cbe56f0c4d7bb700ae)) +* support dynamic containers on server ([a2a81dd](https://github.com/module-federation/nextjs-mf/commit/a2a81dd4d54da55dfc132583d9e0d7c75771fb4c)) + + +### BREAKING CHANGES + +* safety breaking change note +BREAKING_CHANGE: safety breaking change note + + + ## [1.9.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.9.0...utils-1.9.1) (2023-06-30) diff --git a/packages/utilities/package.json b/packages/utilities/package.json index aa43a333859..a401b8bb7b5 100644 --- a/packages/utilities/package.json +++ b/packages/utilities/package.json @@ -1,6 +1,6 @@ { "name": "@module-federation/utilities", - "version": "1.9.1", + "version": "1.9.2-rc.1", "type": "commonjs", "main": "src/index.js", "types": "src/index.d.ts", diff --git a/packages/utilities/src/index.ts b/packages/utilities/src/index.ts index 00c8a8ed4a0..2a36267c5c0 100644 --- a/packages/utilities/src/index.ts +++ b/packages/utilities/src/index.ts @@ -4,3 +4,5 @@ export * from './utils/isEmpty'; export * from './utils/importRemote'; export * from './utils/correctImportPath'; export * from './Logger'; +export { getRuntimeRemotes } from './utils/getRuntimeRemotes'; +export { importDelegatedModule } from './utils/importDelegatedModule'; diff --git a/packages/utilities/src/plugins/DelegateModulesPlugin.test.ts b/packages/utilities/src/plugins/DelegateModulesPlugin.test.ts new file mode 100644 index 00000000000..ecd36a4d68e --- /dev/null +++ b/packages/utilities/src/plugins/DelegateModulesPlugin.test.ts @@ -0,0 +1,113 @@ +import DelegateModulesPlugin from './DelegateModulesPlugin'; +import { Compilation } from 'webpack'; +import { RawSource } from 'webpack-sources'; + +// Mock a minimal Webpack Module +function createMockModule(resource: string): any { + return { + resource, + identifier: () => resource, + source: () => new RawSource(''), + }; +} + +// Mock a minimal Webpack Compiler +function createMockCompiler(): any { + return { + options: { + name: 'test-compiler', + }, + hooks: { + compilation: { + tap: jest.fn(), + }, + }, + }; +} + +// Mock a minimal Webpack Compilation +function createMockCompilation(): Compilation { + return { + hooks: { + optimizeChunks: { + tap: jest.fn(), + }, + finishModules: { + tapAsync: jest.fn(), + }, + }, + chunkGraph: { + isModuleInChunk: jest.fn(), + connectChunkAndModule: jest.fn(), + disconnectChunkAndModule: jest.fn(), + }, + } as unknown as Compilation; +} + +describe('DelegateModulesPlugin', () => { + it('should be an instance of DelegateModulesPlugin', () => { + const plugin = new DelegateModulesPlugin({}); + expect(plugin).toBeInstanceOf(DelegateModulesPlugin); + }); + + it('should apply the plugin to the compiler and call the hooks', () => { + const plugin = new DelegateModulesPlugin({}); + const compiler = createMockCompiler(); + + plugin.apply(compiler); + + expect(compiler.hooks.compilation.tap).toHaveBeenCalledWith( + 'DelegateModulesPlugin', + expect.any(Function) + ); + }); + + it('should add and remove delegate modules correctly', () => { + const plugin = new DelegateModulesPlugin({ + runtime: 'runtime', + container: 'container', + remotes: { + remote1: 'internal /path/to/remote1', + remote2: 'internal /path/to/remote2', + }, + }); + + const compiler = createMockCompiler(); + const compilation = createMockCompilation(); + + plugin.apply(compiler); + + // Call the compilation tap function + (compiler.hooks.compilation.tap as jest.Mock).mock.calls[0][1](compilation); + + // Call the finishModules tap function + (compilation.hooks.finishModules.tapAsync as jest.Mock).mock.calls[0][1]( + [ + createMockModule('/path/to/remote1'), + createMockModule('/path/to/remote2'), + createMockModule('/path/to/non-delegate-module'), + ], + // eslint-disable-next-line @typescript-eslint/no-empty-function + () => {} + ); + + // Check if delegate modules are added + expect(plugin['_delegateModules'].size).toBe(2); + + // Call the optimizeChunks tap function + (compilation.hooks.optimizeChunks.tap as jest.Mock).mock.calls[0][1]([ + { name: 'runtime', hasRuntime: () => true }, + { name: 'container', hasRuntime: () => false }, + ]); + + // Check if connectChunkAndModule was called + expect(compilation.chunkGraph.connectChunkAndModule).toHaveBeenCalledTimes( + 4 + ); + + // Check if disconnectChunkAndModule was called + expect( + compilation.chunkGraph.disconnectChunkAndModule + ).toHaveBeenCalledTimes(2); + }); +}); diff --git a/packages/utilities/src/plugins/DelegateModulesPlugin.ts b/packages/utilities/src/plugins/DelegateModulesPlugin.ts new file mode 100644 index 00000000000..fb48e41fefb --- /dev/null +++ b/packages/utilities/src/plugins/DelegateModulesPlugin.ts @@ -0,0 +1,137 @@ +import type { + Compiler, + Compilation, + Chunk, + Module, + NormalModule, +} from 'webpack'; + +/** + * A webpack plugin that moves specified modules from chunks to runtime chunk. + * @class DelegateModulesPlugin + */ +class DelegateModulesPlugin { + options: { debug: boolean; [key: string]: any }; + _delegateModules: Set; + + constructor(options: { debug?: boolean; [key: string]: any }) { + this.options = { debug: false, ...options }; + this._delegateModules = new Set(); + } + + getChunkByName(chunks: Iterable, name: string): Chunk | undefined { + for (const chunk of chunks) { + if (chunk.name == name) { + return chunk; + } + } + return undefined; + } + + addDelegatesToChunks(compilation: Compilation, chunks: Chunk[]): void { + for (const chunk of chunks) { + this._delegateModules.forEach((module) => { + if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) { + this.options.debug && + console.log( + 'adding ', + module.identifier(), + ' to chunk', + chunk.name + ); + compilation.chunkGraph.connectChunkAndModule(chunk, module); + } + }); + } + } + + removeDelegatesNonRuntimeChunks( + compilation: Compilation, + chunks: Iterable + ): void { + for (const chunk of chunks) { + if (!chunk.hasRuntime()) { + this.options.debug && + console.log( + 'non-runtime chunk:', + chunk.debugId, + chunk.id, + chunk.name + ); + this._delegateModules.forEach((module) => { + compilation.chunkGraph.disconnectChunkAndModule(chunk, module); + }); + } + } + } + + /** + * Applies the plugin to the webpack compiler. + * @param {Compiler} compiler - The webpack compiler instance. + */ + apply(compiler: Compiler): void { + // Tap into compilation hooks + compiler.hooks.compilation.tap( + 'DelegateModulesPlugin', + (compilation: Compilation) => { + // fills this._delegateModules set + this.resolveDelegateModules(compilation); + compilation.hooks.optimizeChunks.tap( + 'DelegateModulesPlugin', + (chunks) => { + // Change this line + const { runtime, container } = this.options; + const runtimeChunk = this.getChunkByName(chunks, runtime); + if (!runtimeChunk || !runtimeChunk.hasRuntime()) return; + // Get the container chunk if specified + const remoteContainer = container + ? this.getChunkByName(chunks, container) + : null; + + this.options.debug && + console.log( + remoteContainer?.name, + runtimeChunk.name, + this._delegateModules.size + ); + this.addDelegatesToChunks( + compilation, + [remoteContainer, runtimeChunk].filter(Boolean) as Chunk[] + ); + + this.removeDelegatesNonRuntimeChunks(compilation, chunks); + } + ); + } + ); + } + + resolveDelegateModules(compilation: Compilation): void { + // Tap into the 'finish-modules' hook to access the module list after they are all processed + compilation.hooks.finishModules.tapAsync( + 'ModuleIDFinderPlugin', + (modules, callback) => { + const { remotes } = this.options; + + // Get the delegate module names for remote chunks if specified + const knownDelegates = new Set( + remotes + ? (Object.values(remotes) as string[]).map((remote: string) => + remote.replace('internal ', '') + ) + : [] + ); + + for (const module of modules) { + // @ts-ignore + if (module.resource && knownDelegates.has(module.resource)) { + this._delegateModules.add(module); + } + } + // Continue the process + callback(); + } + ); + } +} +export default DelegateModulesPlugin; diff --git a/packages/utilities/src/types/index.ts b/packages/utilities/src/types/index.ts index 1327c099fcb..4bac63fc23d 100644 --- a/packages/utilities/src/types/index.ts +++ b/packages/utilities/src/types/index.ts @@ -35,7 +35,7 @@ export interface NextFederationPluginExtraOptions { exposePages?: boolean; skipSharingNextInternals?: boolean; automaticPageStitching?: boolean; - automaticAsyncBoundary?: boolean; + debug?: boolean; } export interface NextFederationPluginOptions @@ -72,6 +72,8 @@ export type RemoteData = { export type RuntimeRemote = Partial & { asyncContainer?: AsyncContainer; + global?: string; + url?: string; }; export type RuntimeRemotesMap = Record; @@ -92,3 +94,10 @@ export type GetModuleOptions = { exportName?: string; remoteContainer: string | RemoteData; }; + +export type RemoteVars = Record< + string, + | Promise + | string + | (() => Promise) +>; diff --git a/packages/utilities/src/utils/common.ts b/packages/utilities/src/utils/common.ts index 1976d74aff8..3b15f16bfb6 100644 --- a/packages/utilities/src/utils/common.ts +++ b/packages/utilities/src/utils/common.ts @@ -2,21 +2,22 @@ import type { AsyncContainer, + GetModuleOptions, + RemoteData, Remotes, - RuntimeRemotesMap, RuntimeRemote, WebpackRemoteContainer, - RemoteData, - GetModuleOptions, } from '../types'; - -type RemoteVars = Record< - string, - | Promise - | string - | (() => Promise) ->; - +import { getRuntimeRemotes } from './getRuntimeRemotes'; +import { RemoteVars } from '../types'; +let remotesFromProcess = {} as RemoteVars; +try { + // @ts-ignore + remotesFromProcess = process.env['REMOTES'] || {}; +} catch (e) { + // not in webpack bundle +} +export const remoteVars = remotesFromProcess as RemoteVars; // split the @ syntax into url and global export const extractUrlAndGlobal = (urlAndGlobal: string): [string, string] => { const index = urlAndGlobal.indexOf('@'); @@ -26,95 +27,6 @@ export const extractUrlAndGlobal = (urlAndGlobal: string): [string, string] => { return [urlAndGlobal.substring(index + 1), urlAndGlobal.substring(0, index)]; }; -const getRuntimeRemotes = () => { - try { - //@ts-ignore - const remoteVars = (process.env.REMOTES || {}) as RemoteVars; - - const runtimeRemotes = Object.entries(remoteVars).reduce(function ( - acc, - item - ) { - const [key, value] = item; - // if its an object with a thenable (eagerly executing function) - if (typeof value === 'object' && typeof value.then === 'function') { - acc[key] = { asyncContainer: value }; - } - // if its a function that must be called (lazily executing function) - else if (typeof value === 'function') { - // @ts-ignore - acc[key] = { asyncContainer: value }; - } - // if its a delegate module, skip it - else if (typeof value === 'string' && value.startsWith('internal ')) { - // do nothing to internal modules - } - // if its just a string (global@url) - else if (typeof value === 'string') { - const [url, global] = extractUrlAndGlobal(value); - acc[key] = { global, url }; - } - // we dont know or currently support this type - else { - //@ts-ignore - console.log('remotes process', process.env.REMOTES); - throw new Error( - `[mf] Invalid value received for runtime_remote "${key}"` - ); - } - return acc; - }, - {} as RuntimeRemotesMap); - - return runtimeRemotes; - } catch (err) { - console.warn('Unable to retrieve runtime remotes: ', err); - } - - return {} as RuntimeRemotesMap; -}; - -export const importDelegatedModule = async ( - keyOrRuntimeRemoteItem: string | RuntimeRemote -) => { - // @ts-ignore - return loadScript(keyOrRuntimeRemoteItem) - .then((asyncContainer: WebpackRemoteContainer) => { - return asyncContainer; - }) - .then((asyncContainer: WebpackRemoteContainer) => { - // most of this is only needed because of legacy promise based implementation - // can remove proxies once we remove promise based implementations - if (typeof window === 'undefined') { - //TODO: need to solve chunk flushing with delegated modules - return asyncContainer; - } else { - const proxy = { - get: asyncContainer.get, - //@ts-ignore - init: function (shareScope: any, initScope: any) { - try { - //@ts-ignore - asyncContainer.init(shareScope, initScope); - // for legacy reasons, we must mark container a initialized - // here otherwise older promise based implementation will try to init again with diff object - //@ts-ignore - proxy.__initialized = true; - } catch (e) { - return 1; - } - }, - }; - // @ts-ignore - if (!proxy.__initialized) { - //@ts-ignore - proxy.init(__webpack_share_scopes__.default); - } - return proxy; - } - }); -}; - export const createDelegatedModule = ( delegate: string, params: { [key: string]: any } @@ -128,10 +40,11 @@ export const createDelegatedModule = ( } queries.push(`${key}=${value}`); } + if (queries.length === 0) return `internal ${delegate}`; return `internal ${delegate}?${queries.join('&')}`; }; -const loadScript = (keyOrRuntimeRemoteItem: string | RuntimeRemote) => { +export const loadScript = (keyOrRuntimeRemoteItem: string | RuntimeRemote) => { const runtimeRemotes = getRuntimeRemotes(); // 1) Load remote container if needed @@ -150,11 +63,11 @@ const loadScript = (keyOrRuntimeRemoteItem: string | RuntimeRemote) => { } else { // This casting is just to satisfy typescript, // In reality remoteGlobal will always be a string; - const remoteGlobal = reference.global as unknown as number; + const remoteGlobal = reference.global as unknown as string; // Check if theres an override for container key if not use remote global const containerKey = reference.uniqueKey - ? (reference.uniqueKey as unknown as number) + ? (reference.uniqueKey as unknown as string) : remoteGlobal; const __webpack_error__ = new Error() as Error & { @@ -163,18 +76,18 @@ const loadScript = (keyOrRuntimeRemoteItem: string | RuntimeRemote) => { }; // @ts-ignore - if (!global.__remote_scope__) { + if (!globalThis.__remote_scope__) { // create a global scope for container, similar to how remotes are set on window in the browser // @ts-ignore - global.__remote_scope__ = { + globalThis.__remote_scope__ = { // @ts-ignore _config: {}, }; } - + // @ts-ignore const globalScope = // @ts-ignore - typeof window !== 'undefined' ? window : global.__remote_scope__; + typeof window !== 'undefined' ? window : globalThis.__remote_scope__; if (typeof window === 'undefined') { globalScope['_config'][containerKey] = reference.url; @@ -187,7 +100,7 @@ const loadScript = (keyOrRuntimeRemoteItem: string | RuntimeRemote) => { return globalScope['remoteLoading'][containerKey]; } } - + // @ts-ignore asyncContainer = new Promise(function (resolve, reject) { function resolveRemoteGlobal() { const asyncContainer = globalScope[ @@ -229,6 +142,28 @@ const loadScript = (keyOrRuntimeRemoteItem: string | RuntimeRemote) => { }, containerKey ); + }).catch(function (err) { + console.error('container is offline, returning fake remote'); + console.error(err); + + return { + fake: true, + // @ts-ignore + get: (arg) => { + console.warn('faking', arg, 'module on, its offline'); + + return Promise.resolve(() => { + return { + __esModule: true, + default: () => { + return null; + }, + }; + }); + }, + //eslint-disable-next-line + init: () => {}, + }; }); if (typeof window !== 'undefined') { globalScope['remoteLoading'][containerKey] = asyncContainer; @@ -320,10 +255,10 @@ export const getContainer = async ( if (!remoteContainer) { throw Error(`Remote container options is empty`); } - + // @ts-ignore const containerScope = - //@ts-ignore - typeof window !== 'undefined' ? window : global.__remote_scope__; + // @ts-ignore + typeof window !== 'undefined' ? window : globalThis.__remote_scope__; if (typeof remoteContainer === 'string') { if (containerScope[remoteContainer]) { @@ -373,7 +308,7 @@ export const getModule = async ({ return mod; } } catch (error) { - console.log(error); + console.error(error); return undefined; } }; diff --git a/packages/utilities/src/utils/correctImportPath.ts b/packages/utilities/src/utils/correctImportPath.ts index b1b0a701cae..9514eb9804f 100644 --- a/packages/utilities/src/utils/correctImportPath.ts +++ b/packages/utilities/src/utils/correctImportPath.ts @@ -1,20 +1,25 @@ export const correctImportPath = (context: string, entryFile: string) => { - if (process?.platform !== 'win32') { - return entryFile; - } - if (entryFile.match(/^\.?\.\\/) || !entryFile.match(/^[A-Z]:\\\\/i)) { - return entryFile.replace(/\\/g, '/'); - } + if (typeof process !== 'undefined') { + if (process?.platform !== 'win32') { + return entryFile; + } + console.log('entryFile', entryFile); - // eslint-disable-next-line @typescript-eslint/no-var-requires - const path = require('path'); - const joint = path.win32.relative(context, entryFile); - const relative = joint.replace(/\\/g, '/'); + if (entryFile.match(/^\.?\.\\/) || !entryFile.match(/^[A-Z]:\\\\/i)) { + return entryFile.replace(/\\/g, '/'); + } - if (relative.includes('node_modules/')) { - return relative.split('node_modules/')[1]; - } + // eslint-disable-next-line @typescript-eslint/no-var-requires + const path = require('path'); + const joint = path.win32.relative(context, entryFile); + const relative = joint.replace(/\\/g, '/'); - return `./${relative}`; + if (relative.includes('node_modules/')) { + return relative.split('node_modules/')[1]; + } + + return `./${relative}`; + } + return null; }; diff --git a/packages/utilities/src/utils/getRuntimeRemotes.test.ts b/packages/utilities/src/utils/getRuntimeRemotes.test.ts new file mode 100644 index 00000000000..1791c2112fd --- /dev/null +++ b/packages/utilities/src/utils/getRuntimeRemotes.test.ts @@ -0,0 +1,80 @@ +import { getRuntimeRemotes } from './getRuntimeRemotes'; +import { remoteVars } from './common'; + +xdescribe('getRuntimeRemotes', () => { + afterEach(() => { + Object.keys(remoteVars).forEach((key) => { + delete remoteVars[key]; + }); + }); + + test('returns an empty object if REMOTES is not set', () => { + const remotes = getRuntimeRemotes(); + expect(remotes).toEqual({}); + }); + + test('parses asyncContainer from thenable object', () => { + const thenable = Promise.resolve({ get: () => true, init: () => true }); + // @ts-ignore + remoteVars['thenable'] = thenable; + const remotes = getRuntimeRemotes(); + expect(remotes).toEqual({ thenable: { asyncContainer: thenable } }); + }); + + test('parses asyncContainer from lazily executing function', () => { + const lazyFunction = () => + Promise.resolve({ get: () => true, init: () => true }); + // @ts-ignore + remoteVars['lazyFunction'] = lazyFunction; + + const remotes = getRuntimeRemotes(); + expect(remotes).toHaveProperty('lazyFunction.asyncContainer'); + expect(typeof remotes['lazyFunction'].asyncContainer).toBe('function'); + }); + + test('parses delegate module', () => { + // @ts-ignore + Object.assign(remoteVars, { + delegate: + 'internal some_module?remote=remoteGlobal@https://example.com/remoteEntry.js', + }); + const remotes = getRuntimeRemotes(); + expect(remotes).toEqual({ + delegate: { + global: 'remoteGlobal', + url: 'https://example.com/remoteEntry.js', + }, + }); + }); + + test('parses global@url string', () => { + // @ts-ignore + remoteVars['remote'] = 'remoteGlobal@https://example.com/remoteEntry.js'; + const remotes = getRuntimeRemotes(); + expect(remotes).toEqual({ + remote: { + global: 'remoteGlobal', + url: 'https://example.com/remoteEntry.js', + }, + }); + }); + + test('console.warn should be called for unsupported types', () => { + console.warn = jest.fn(); + // @ts-ignore + remoteVars['unsupported'] = 42; + // Call the function that triggers the warning message + getRuntimeRemotes(); + // Check that console.warn was called with the correct message + //@ts-ignore + expect(console.warn.mock.calls[0][0]).toMatch( + /Unable to retrieve runtime remotes/ + ); + //@ts-ignore + console.log(console.warn.mock.calls[0][1].message); + //@ts-ignore + expect(console.warn.mock.calls[0][1].message).toMatch(/runtime_remote/); + //@ts-ignore + expect(console.warn.mock.calls[0][1].message).toMatch(/unsupported/); + }); +}); diff --git a/packages/utilities/src/utils/getRuntimeRemotes.ts b/packages/utilities/src/utils/getRuntimeRemotes.ts new file mode 100644 index 00000000000..a617043deb7 --- /dev/null +++ b/packages/utilities/src/utils/getRuntimeRemotes.ts @@ -0,0 +1,54 @@ +import { RuntimeRemotesMap } from '../types'; +import { extractUrlAndGlobal, remoteVars } from './common'; + +export const getRuntimeRemotes = () => { + try { + const runtimeRemotes = Object.entries(remoteVars).reduce(function ( + acc, + item + ) { + const [key, value] = item; + // if its an object with a thenable (eagerly executing function) + if (typeof value === 'object' && typeof value.then === 'function') { + acc[key] = { asyncContainer: value }; + } + // if its a function that must be called (lazily executing function) + else if (typeof value === 'function') { + // @ts-ignore + acc[key] = { asyncContainer: value }; + } + // if its a delegate module, skip it + else if (typeof value === 'string' && value.startsWith('internal ')) { + const [request, query] = value.replace('internal ', '').split('?'); + if (query) { + const remoteSyntax = new URLSearchParams(query).get('remote'); + if (remoteSyntax) { + const [url, global] = extractUrlAndGlobal(remoteSyntax); + acc[key] = { global, url }; + } + } + } + // if its just a string (global@url) + else if (typeof value === 'string') { + const [url, global] = extractUrlAndGlobal(value); + acc[key] = { global, url }; + } + // we dont know or currently support this type + else { + //@ts-ignore + console.warn('remotes process', process.env.REMOTES); + throw new Error( + `[mf] Invalid value received for runtime_remote "${key}"` + ); + } + return acc; + }, + {} as RuntimeRemotesMap); + + return runtimeRemotes; + } catch (err) { + console.warn('Unable to retrieve runtime remotes: ', err); + } + + return {} as RuntimeRemotesMap; +}; diff --git a/packages/utilities/src/utils/importDelegatedModule.ts b/packages/utilities/src/utils/importDelegatedModule.ts new file mode 100644 index 00000000000..fe095161ed6 --- /dev/null +++ b/packages/utilities/src/utils/importDelegatedModule.ts @@ -0,0 +1,80 @@ +import { RuntimeRemote, WebpackRemoteContainer } from '../types'; +import { loadScript } from './common'; + +export const importDelegatedModule = async ( + keyOrRuntimeRemoteItem: string | RuntimeRemote +) => { + // @ts-ignore + return loadScript(keyOrRuntimeRemoteItem) + .then((asyncContainer: WebpackRemoteContainer) => { + return asyncContainer; + }) + .then((asyncContainer: WebpackRemoteContainer) => { + // most of this is only needed because of legacy promise based implementation + // can remove proxies once we remove promise based implementations + if (typeof window === 'undefined') { + if (!Object.hasOwnProperty.call(keyOrRuntimeRemoteItem, 'global')) { + return asyncContainer; + } + + // return asyncContainer; + + //TODO: need to solve chunk flushing with delegated modules + return { + get: function (arg: string) { + //@ts-ignore + return asyncContainer.get(arg).then((f) => { + const m = f(); + const result = { + __esModule: m.__esModule, + }; + for (const prop in m) { + if (typeof m[prop] === 'function') { + Object.defineProperty(result, prop, { + get: function () { + return function () { + //@ts-ignore + if (globalThis.usedChunks) + //@ts-ignore + globalThis.usedChunks.add( + //@ts-ignore + `${keyOrRuntimeRemoteItem.global}->${arg}` + ); + //eslint-disable-next-line prefer-rest-params + return m[prop](...arguments); + }; + }, + enumerable: true, + }); + } else { + Object.defineProperty(result, prop, { + get: () => { + //@ts-ignore + if (globalThis.usedChunks) + //@ts-ignore + globalThis.usedChunks.add( + //@ts-ignore + `${keyOrRuntimeRemoteItem.global}->${arg}` + ); + + return m[prop]; + }, + enumerable: true, + }); + } + } + + if (m.then) { + return Promise.resolve(() => result); + } + + return () => result; + }); + }, + init: asyncContainer.init, + }; + } else { + return asyncContainer; + } + }); +}; diff --git a/packages/utilities/tsconfig.json b/packages/utilities/tsconfig.json index cd95cb419af..828a2b0b65c 100644 --- a/packages/utilities/tsconfig.json +++ b/packages/utilities/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "target": "ES5", + "target": "ES2015", "module": "commonjs", "forceConsistentCasingInFileNames": true, "strict": true, diff --git a/prompt_target_pairs.jsonl b/prompt_target_pairs.jsonl new file mode 100644 index 00000000000..ca26f7d243c --- /dev/null +++ b/prompt_target_pairs.jsonl @@ -0,0 +1,25 @@ +{"prompt":"Write a function that generates a commit message using the GPT-3 model by creating a diff of the current changes and sending the prompt to the GPT-3 model. The function should truncate the diff if it exceeds the maximum character count.","target":" async function generateCommitMsg() {\n console.log('Generating commit message for staged changes...');\n\n let diff = execSync('git diff -U10 --staged').toString();\n let files = execSync('git diff --name-only --cached').toString().trim();\n console.log('files', files);\n if (!files) {\n console.error('No files to commit');\n return;\n }\n\n console.log('tokens', diff.length, MAX_CHAR_COUNT);\n const oldDiff = diff.length;\n\n if (diff.length > MAX_CHAR_COUNT) {\n diff = [\n execSync('git diff --staged --stat').toString(),\n execSync('git diff -U5 --staged').toString(),\n ].join('\\n');\n\n console.warn(\n 'over max char count, reducing diff fidelity',\n 'from:',\n oldDiff.length,\n 'to:',\n diff.length\n );\n }\n\n let prompt = createPrompt(diff);\n\n let commitMsg;\n for await (const msg of getValidJsonResponse(prompt)) {\n commitMsg = msg;\n }\n\n return commitMsg;\n}\n"} +{"prompt":"Write a function that creates a markdown-formatted commit message from a commit message object with \"Title\", \"Description\", and \"Changes\" properties. The \"Changes\" property should be an array of objects, each with a \"filename\" and a \"description\" property.","target":" function createMarkdownCommit(commitMsg = {}) {\n if (!commitMsg.Changes) {\n console.log('commit message is empty', commitMsg);\n }\n const markdownCommitMsg = `# ${commitMsg.Title}\\n\\n${\n commitMsg.Description\n }\\n\\n${commitMsg.Changes.map(\n (change) =>\n `### ${change.filename}\\n\\n${change.description\n .map((desc) => `- ${desc}`)\n .join('\\n')}`\n ).join('\\n\\n')}`;\n\n return markdownCommitMsg;\n}\n"} +{"prompt":"Write a function that executes a git commit command with a provided title and body as messages.","target":" function gitCommit(title, body) {\n // Split the body by newline characters to get an array of strings\n const bodyLines = body.split('\\n');\n\n // Create an array for the git command\n let gitCmdArray = ['git', 'commit', '-m', title];\n\n // Iterate over the bodyLines array and add a \"-m\" followed by each line\n bodyLines.forEach((line) => {\n gitCmdArray.push('-m');\n gitCmdArray.push(line);\n });\n const gitCmd = commandJoin(gitCmdArray);\n console.log('Committing changes...');\n return execSync(gitCmd, { stdio: 'inherit' });\n}\n"} +{"prompt":"Write a function that creates a prompt string for summarizing a series of git commit messages in markdown format.","target":" function createLogMarkdownPrompt(input) {\n return `\nPlease suggest one detailed summary for the series of commit messages.\nThe summary should be composed of a title and a description.\nIn the description, provide an overall summary of the changes reflected in the commits, and list each commit with a brief explanation of its content.\nReturn it as markdown format:\n# [summary title]\n[summary description]\n## Commits\n - [commit message]\n - [explanation]\n - [explanation]\n - [commit message]\n - [explanation]\n - [explanation]\n\n${response.end}\n\nHere are the commit messages: ${input.slice(0, MAX_CHAR_COUNT)}`;\n}\n"} +{"prompt":"Write a function that converts an AI generated summary of commit messages into markdown format.","target":" function createMarkdownSummary(summaryMsg = {}) {\n const markdownSummaryMsg = `# ${summaryMsg.Title}\\n\\n${\n summaryMsg.Description\n }\\n\\n${summaryMsg.Commits.map(\n (commit) =>\n `## ${commit.commit}\\n\\n${commit.explanation\n .map((desc) => `- ${desc}`)\n .join('\\n')}`\n ).join('\\n\\n')}`;\n\n return markdownSummaryMsg;\n}\n"} +{"prompt":"Write a function that executes a git commit command with a provided title and body as messages.","target":" function gitCommit(title, body) {\n // Split the body by newline characters to get an array of strings\n const bodyLines = body.split('\\n');\n\n // Create an array for the git command\n let gitCmdArray = ['git', 'commit', '-m', title];\n\n // Iterate over the bodyLines array and add a \"-m\" followed by each line\n bodyLines.forEach((line) => {\n gitCmdArray.push('-m');\n gitCmdArray.push(line);\n });\n const gitCmd = commandJoin(gitCmdArray);\n console.log('Committing changes...');\n return execSync(gitCmd, { stdio: 'inherit' });\n}\n"} +{"prompt":"Write a function that creates a prompt string for summarizing a series of git commit messages in markdown format.","target":" function createLogMarkdownPrompt(input) {\n return `\nPlease suggest one detailed summary for the series of commit messages.\nThe summary should be composed of a title and a description.\nIn the description, provide an overall summary of the changes reflected in the commits, and list each commit with a brief explanation of its content.\nReturn it as markdown format:\n# [summary title]\n[summary description]\n## Commits\n - [commit message]\n - [explanation]\n - [explanation]\n - [commit message]\n - [explanation]\n - [explanation]\n\n${response.end}\n\nHere are the commit messages: ${input.slice(0, MAX_CHAR_COUNT)}`;\n}\n"} +{"prompt":"Write a function that converts an AI generated summary of commit messages into markdown format.","target":" function createMarkdownSummary(summaryMsg = {}) {\n const markdownSummaryMsg = `# ${summaryMsg.Title}\\n\\n${\n summaryMsg.Description\n }\\n\\n${summaryMsg.Commits.map(\n (commit) =>\n `## ${commit.commit}\\n\\n${commit.explanation\n .map((desc) => `- ${desc}`)\n .join('\\n')}`\n ).join('\\n\\n')}`;\n\n return markdownSummaryMsg;\n}\n"} +{"prompt":"Write a function that sends a completion request to the OpenAI API and returns the response.","target":" async function completion({\n prompt,\n fallback,\n max_tokens,\n temperature = 0,\n model = defaultModel,\n}) {\n const messages = [\n {\n role: ChatCompletionRequestMessageRoleEnum.System,\n content: filterStopwords\n ? removeStopwords((prompt ?? '').split(' ')).join(' ')\n : prompt ?? '',\n },\n ...Array.from(chatHistory),\n ];\n\n let result;\n try {\n result = await openai.createChatCompletion({\n model,\n messages,\n temperature,\n max_tokens: max_tokens ?? 800,\n stop: [response.end],\n });\n } catch (error) {\n console.error('Error in createChatCompletion:', error);\n if (error.response) {\n console.error('HTTP response body:', error.response.data);\n }\n throw error;\n }\n\n if (!result.data.choices[0].message) {\n throw new Error('No text returned from completions endpoint');\n }\n\n const messageContent = result.data.choices[0].message.content;\n\n chatHistory.add({\n role: ChatCompletionRequestMessageRoleEnum.Assistant,\n content: messageContent,\n });\n\n return messageContent;\n}\n"} +{"prompt":"Write a function that sends a completion request to the OpenAI API and returns a stream of text.","target":" async function* completionStream({\n prompt,\n temperature,\n max_tokens,\n model = defaultModel,\n}) {\n const messages = [\n {\n role: ChatCompletionRequestMessageRoleEnum.System,\n content: filterStopwords\n ? removeStopwords((prompt ?? '').split(' ')).join(' ')\n : prompt ?? '',\n },\n ...Array.from(chatHistory),\n ];\n\n let result;\n try {\n result = await openai.createChatCompletion(\n {\n model,\n messages,\n temperature,\n max_tokens: max_tokens ?? 800,\n stream: true,\n },\n {\n responseType: 'stream',\n }\n );\n } catch (error) {\n console.error('Error in createChatCompletion:', error);\n if (error.response) {\n console.error('HTTP response body:', error.response.data);\n }\n throw error;\n }\n\n const stream = result.data;\n let buffer = '';\n const textDecoder = new TextDecoder();\n for await (const chunk of stream) {\n buffer += textDecoder.decode(chunk, { stream: true });\n\n const lines = buffer.split('\\n');\n\n if (buffer.endsWith('\\n')) {\n buffer = '';\n } else {\n buffer = lines.pop() || '';\n }\n\n for (const line of lines) {\n const message = line.trim().split('data: ')[1];\n\n if (message === '[DONE]') {\n break;\n }\n\n if (message) {\n try {\n const data = JSON.parse(message);\n\n if (data.choices[0].delta?.content) {\n yield data.choices[0].delta?.content;\n }\n } catch (error) {\n console.error('Error parsing JSON message:', error);\n }\n }\n }\n }\n\n if (buffer) {\n chatHistory.add({\n role: ChatCompletionRequestMessageRoleEnum.Assistant,\n content: buffer,\n });\n }\n}\n"} +{"prompt":"Write a function that converts an AI generated summary of commit messages into markdown format.","target":" function createMarkdownSummary(summaryMsg = {}) {\n const markdownSummaryMsg = `# ${summaryMsg.Title}\\n\\n${\n summaryMsg.Description\n }\\n\\n${summaryMsg.Commits.map(\n (commit) =>\n `## ${commit.commit}\\n\\n${commit.explanation\n .map((desc) => `- ${desc}`)\n .join('\\n')}`\n ).join('\\n\\n')}`;\n\n return markdownSummaryMsg;\n}\n"} +{"prompt":"Write a function that sends a completion request to the OpenAI API and returns the response.","target":" async function completion({\n prompt,\n fallback,\n max_tokens,\n temperature = 0,\n model = defaultModel,\n}) {\n const messages = [\n {\n role: ChatCompletionRequestMessageRoleEnum.System,\n content: filterStopwords\n ? removeStopwords((prompt ?? '').split(' ')).join(' ')\n : prompt ?? '',\n },\n ...Array.from(chatHistory),\n ];\n\n let result;\n try {\n result = await openai.createChatCompletion({\n model,\n messages,\n temperature,\n max_tokens: max_tokens ?? 800,\n stop: [response.end],\n });\n } catch (error) {\n console.error('Error in createChatCompletion:', error);\n if (error.response) {\n console.error('HTTP response body:', error.response.data);\n }\n throw error;\n }\n\n if (!result.data.choices[0].message) {\n throw new Error('No text returned from completions endpoint');\n }\n\n const messageContent = result.data.choices[0].message.content;\n\n chatHistory.add({\n role: ChatCompletionRequestMessageRoleEnum.Assistant,\n content: messageContent,\n });\n\n return messageContent;\n}\n"} +{"prompt":"Write a function that sends a completion request to the OpenAI API and returns a stream of text.","target":" async function* completionStream({\n prompt,\n temperature,\n max_tokens,\n model = defaultModel,\n}) {\n const messages = [\n {\n role: ChatCompletionRequestMessageRoleEnum.System,\n content: filterStopwords\n ? removeStopwords((prompt ?? '').split(' ')).join(' ')\n : prompt ?? '',\n },\n ...Array.from(chatHistory),\n ];\n\n let result;\n try {\n result = await openai.createChatCompletion(\n {\n model,\n messages,\n temperature,\n max_tokens: max_tokens ?? 800,\n stream: true,\n },\n {\n responseType: 'stream',\n }\n );\n } catch (error) {\n console.error('Error in createChatCompletion:', error);\n if (error.response) {\n console.error('HTTP response body:', error.response.data);\n }\n throw error;\n }\n\n const stream = result.data;\n let buffer = '';\n const textDecoder = new TextDecoder();\n for await (const chunk of stream) {\n buffer += textDecoder.decode(chunk, { stream: true });\n\n const lines = buffer.split('\\n');\n\n if (buffer.endsWith('\\n')) {\n buffer = '';\n } else {\n buffer = lines.pop() || '';\n }\n\n for (const line of lines) {\n const message = line.trim().split('data: ')[1];\n\n if (message === '[DONE]') {\n break;\n }\n\n if (message) {\n try {\n const data = JSON.parse(message);\n\n if (data.choices[0].delta?.content) {\n yield data.choices[0].delta?.content;\n }\n } catch (error) {\n console.error('Error parsing JSON message:', error);\n }\n }\n }\n }\n\n if (buffer) {\n chatHistory.add({\n role: ChatCompletionRequestMessageRoleEnum.Assistant,\n content: buffer,\n });\n }\n}\n"} +{"prompt":"Write a function that sends an embedding request to the OpenAI API and returns the response.","target":" async function embedding({ input, model = 'text-embedding-ada-002' }) {\n const result = await openai.createEmbedding({\n model: 'text-embedding-ada-002', //cant be GPT4\n input,\n });\n\n if (!result.data.data[0].embedding) {\n throw new Error('No embedding returned from the completions endpoint');\n }\n\n return result.data.data.map((d) => d.embedding);\n}\n"} +{"prompt":"Write a function that parses a given parameter from a route and returns a data structure that can be used to generate the parametrized route. Examples: - `[...slug]` -> `{ name: 'slug', repeat: true, optional: true }` - `[foo]` -> `{ name: 'foo', repeat: false, optional: true }` - `bar` -> `{ name: 'bar', repeat: false, optional: false }`","target":" function parseParameter(param: string) {\n const optional = param.startsWith('[') && param.endsWith(']');\n if (optional) {\n param = param.slice(1, -1);\n }\n const repeat = param.startsWith('...');\n if (repeat) {\n param = param.slice(3);\n }\n return { key: param, repeat, optional };\n}\n"} +{"prompt":"Write a function that sends a completion request to the OpenAI API and returns a stream of text.","target":" async function* completionStream({\n prompt,\n temperature,\n max_tokens,\n model = defaultModel,\n}) {\n const messages = [\n {\n role: ChatCompletionRequestMessageRoleEnum.System,\n content: filterStopwords\n ? removeStopwords((prompt ?? '').split(' ')).join(' ')\n : prompt ?? '',\n },\n ...Array.from(chatHistory),\n ];\n\n let result;\n try {\n result = await openai.createChatCompletion(\n {\n model,\n messages,\n temperature,\n max_tokens: max_tokens ?? 800,\n stream: true,\n },\n {\n responseType: 'stream',\n }\n );\n } catch (error) {\n console.error('Error in createChatCompletion:', error);\n if (error.response) {\n console.error('HTTP response body:', error.response.data);\n }\n throw error;\n }\n\n const stream = result.data;\n let buffer = '';\n const textDecoder = new TextDecoder();\n for await (const chunk of stream) {\n buffer += textDecoder.decode(chunk, { stream: true });\n\n const lines = buffer.split('\\n');\n\n if (buffer.endsWith('\\n')) {\n buffer = '';\n } else {\n buffer = lines.pop() || '';\n }\n\n for (const line of lines) {\n const message = line.trim().split('data: ')[1];\n\n if (message === '[DONE]') {\n break;\n }\n\n if (message) {\n try {\n const data = JSON.parse(message);\n\n if (data.choices[0].delta?.content) {\n yield data.choices[0].delta?.content;\n }\n } catch (error) {\n console.error('Error parsing JSON message:', error);\n }\n }\n }\n }\n\n if (buffer) {\n chatHistory.add({\n role: ChatCompletionRequestMessageRoleEnum.Assistant,\n content: buffer,\n });\n }\n}\n"} +{"prompt":"Write a function that sends an embedding request to the OpenAI API and returns the response.","target":" async function embedding({ input, model = 'text-embedding-ada-002' }) {\n const result = await openai.createEmbedding({\n model: 'text-embedding-ada-002', //cant be GPT4\n input,\n });\n\n if (!result.data.data[0].embedding) {\n throw new Error('No embedding returned from the completions endpoint');\n }\n\n return result.data.data.map((d) => d.embedding);\n}\n"} +{"prompt":"Write a function that parses a given parameter from a route and returns a data structure that can be used to generate the parametrized route.","target":" function parseParameter(param: string) {\n const optional = param.startsWith('[') && param.endsWith(']');\n if (optional) {\n param = param.slice(1, -1);\n }\n const repeat = param.startsWith('...');\n if (repeat) {\n param = param.slice(3);\n }\n return { key: param, repeat, optional };\n}\n"} +{"prompt":"Write a function that converts a browser pathname to a Next.js route for proper handling of dynamic routes.","target":" export function pathnameToRoute(\n cleanPathname: string,\n routes: string[]\n): string | undefined {\n if (routes.includes(cleanPathname)) {\n return cleanPathname;\n }\n\n for (const route of routes) {\n if (isDynamicRoute(route) && getRouteRegex(route).re.test(cleanPathname)) {\n return route;\n }\n }\n\n return undefined;\n}\n"} +{"prompt":"Write a function that sorts provided pages in the correct Next.js order for proper handling of dynamic routes.","target":" export function sortNextPages(pages: string[]): string[] {\n const root = new UrlNode();\n pages.forEach((pageRoute) => root.insert(pageRoute));\n // Smoosh will then sort those sublevels up to the point where you get the correct route definition priority\n return root.smoosh();\n}\n"} +{"prompt":"Write a function that parses a given parameter from a route and returns a data structure that can be used to generate the parametrized route.","target":" function parseParameter(param: string) {\n const optional = param.startsWith('[') && param.endsWith(']');\n if (optional) {\n param = param.slice(1, -1);\n }\n const repeat = param.startsWith('...');\n if (repeat) {\n param = param.slice(3);\n }\n return { key: param, repeat, optional };\n}\n"} +{"prompt":"Write a function that converts a browser pathname to a Next.js route for proper handling of dynamic routes.","target":" export function pathnameToRoute(\n cleanPathname: string,\n routes: string[]\n): string | undefined {\n if (routes.includes(cleanPathname)) {\n return cleanPathname;\n }\n\n for (const route of routes) {\n if (isDynamicRoute(route) && getRouteRegex(route).re.test(cleanPathname)) {\n return route;\n }\n }\n\n return undefined;\n}\n"} +{"prompt":"Write a function that sorts provided pages in the correct Next.js order for proper handling of dynamic routes.","target":" export function sortNextPages(pages: string[]): string[] {\n const root = new UrlNode();\n pages.forEach((pageRoute) => root.insert(pageRoute));\n // Smoosh will then sort those sublevels up to the point where you get the correct route definition priority\n return root.smoosh();\n}\n"} +{"prompt":"Write a React hook that provides a convenient way to work with Module Federation runtime changes.","target":" export function useMFClient(opts: MFClientHookOptions): MFClient {\n const MFClient: MFClient = isBrowser\n ? (window as any).mf_client\n : /* TODO: inject here SSR version of MFClient if it will be needed in future */ ({} as any);\n\n const innerState = React.useRef({\n remote: undefined,\n });\n\n React.useEffect(() => {\n // Step 1: Define handlers and helpers\n const processRemoteChange = (remote: RemoteContainer | undefined) => {\n if (innerState.current.remote !== remote) {\n innerState.current.remote = remote;\n if (opts?.onChangeRemote) {\n opts.onChangeRemote(remote, MFClient);\n }\n }\n };\n\n const handleRouterChange = (pathname: string) => {\n if (MFClient.isFederatedPathname(pathname)) {\n const remote = MFClient.remotePages.routeToRemote(pathname);\n processRemoteChange(remote);\n } else {\n processRemoteChange(undefined);\n }\n };\n\n // Step 2: run bootstrap logic\n const initialRemote = MFClient.isFederatedPathname(window.location.pathname)\n ? MFClient.remotePages.routeToRemote(window.location.pathname)\n : undefined;\n\n if (initialRemote) {\n // important for first load to fire `onChangeRemote` with different remote\n // because in innerState by default we assume that used local application\n processRemoteChange(initialRemote);\n }\n\n // Step 3: Subscribe on events\n singletonRouter.events.on('routeChangeStart', handleRouterChange);\n return () => {\n singletonRouter.events.off('routeChangeStart', handleRouterChange);\n };\n }, []);\n\n return MFClient;\n}\n"} +{"prompt":"Write a React hook that provides access to a RemoteContainer in Module Federation.","target":" export function useMFRemote(global: string): UseMFRemoteResult {\n let remote: RemoteContainer;\n\n if (isBrowser) {\n // on client (we get instances from global variable because webpack breaks Singletons)\n const MFClient: MFClient = (window as any).mf_client;\n remote = MFClient.remotes[global] || MFClient.registerRemote(global);\n } else {\n // on server side\n remote = RemoteContainer.createSingleton(global);\n }\n\n const [loaded, setLoaded] = React.useState(remote.isLoaded());\n const [error, setError] = React.useState(remote.error);\n\n React.useEffect(() => {\n const handleLoadComplete = () => {\n setLoaded(true);\n };\n const handleLoadError = (e: Error) => {\n setError(e);\n };\n\n if (!loaded && remote.isLoaded()) {\n handleLoadComplete();\n }\n\n remote.events.on('loadComplete', handleLoadComplete);\n remote.events.on('loadError', handleLoadError);\n return () => {\n remote.events.off('loadComplete', handleLoadComplete);\n remote.events.off('loadError', handleLoadError);\n };\n }, [remote]);\n\n return {\n remote,\n loaded,\n error,\n };\n}\n"} diff --git a/scripts/update-next-to-latest-at-npm.sh b/scripts/update-next-to-latest-at-npm.sh old mode 100644 new mode 100755