{"_id":"@alcyone/nextjs-mf","_rev":"4-a5dfbb5b98a3bd385c5fe3268a21663d","name":"@alcyone/nextjs-mf","dist-tags":{"latest":"0.1.3"},"versions":{"0.0.3":{"public":true,"name":"@alcyone/nextjs-mf","version":"0.0.3","description":"Module Federation helper for NextJS","main":"index.js","repository":{"type":"git","url":"git+https://github.com/noreiller/nextjs-mf.git"},"author":{"name":"Aurélien MANCA","email":"aurelien@amanca.fr"},"license":"MIT","scripts":{"prettier":"prettier --write \"**/*.{js,json,md,ts,tsx}\""},"bin":{"nextjs-mf":"bin/nextjs-mf.js"},"devDependencies":{"commander":"^6.2.0","prettier":"^2.1.2","react":"^17.0.1"},"peerDependencies":{"react":"^16 || ^17"},"dependencies":{"shelljs":"^0.8.4"},"gitHead":"44e9c702232ac0af4d9ce77985d074501bf03f07","bugs":{"url":"https://github.com/noreiller/nextjs-mf/issues"},"homepage":"https://github.com/noreiller/nextjs-mf#readme","_id":"@alcyone/nextjs-mf@0.0.3","_nodeVersion":"14.15.3","_npmVersion":"6.14.9","dist":{"integrity":"sha512-UC5gP464NTojLb6QJDKPqZAJ/XANlw2ghublFCiBu+WlErBKzqtpdI2V0RBdmnXCZO330QG9iI5XFl4ar5Sl+Q==","shasum":"d2e6860275600e84719e2b8ef194287ea8c41e13","tarball":"https://registry.npmjs.org/@alcyone/nextjs-mf/-/nextjs-mf-0.0.3.tgz","fileCount":10,"unpackedSize":241354,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/rOHCRA9TVsSAnZWagAA9oIP/iWPAnKpNVpyHthJTyxb\niKKqozCYUUO3jd9y3CFsNRxHoWS1oeuIGc4HrXYP3S9RSbg4hqO6aRHhSYsQ\nwqlmvV7va6YD5RhDjIzF62YuUy6h/q+q2LlPAT+2msXqJJXnTkbweXDGL+yR\nctzQgNQHSW23E26EkzZ22KD43OqRIcDzaPUprE0sspRDWEJbogAwGdz58pRa\n9IbshbkRROeSV9bGze0dz9yjxWWsDHshYZDYIefNzUqLVHIk/coxZQB7hpnQ\nudRqW/WsLVV04GLY1CWPSjAX8tri+thcAUEoCHYdSIqR3SeQr/63qTkCNhX2\nHTS8lFsXqCN+qgQJr43djTpLThvRDSKGT8S8RKl3wROYOTrjyrpUAvcE5rRU\n+urhyYB/NQ3lnUz5GTRdItVabgA23g/Au11tXEkzdFqHXQoVYVrozt6oVA1n\nJd5XHRrGQRC6mOA+u2xocCYQnGI4NpGZrliXi4WjuJ0qdymqlXAssTnzI2mj\nuiO1DzbTwOYhgvXvoz39liPmqUK0Nl3bEX78MwZDsENU9xV7hd0mPONeAT9b\nIr/hBcZbPZZxmpOzeePdsIPgrL2k/4wfxeUa5GQ7LJyOKl8IwRp5va+Or7XE\nPU/Lecpmzb2Tr++BRKHGPuNv8mgIci3Ju9ySdCDICEp42JP6KWLaGVv0fDWt\nDFrR\r\n=JdAZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEMCHxxTF3zSVPJ5zM4Nsu9vXQPHz3IcPL4Iwn/I8cxJH7gCICP64/NdII3mB+Bm0ZnBXdnEUuCzktadph3bnboTFKWi"}]},"_npmUser":{"name":"noreiller","email":"aurelien@amanca.fr"},"directories":{},"maintainers":[{"name":"noreiller","email":"aurelien@amanca.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nextjs-mf_0.0.3_1610527622837_0.8617997465533331"},"_hasShrinkwrap":false},"0.1.1":{"name":"@alcyone/nextjs-mf","version":"0.1.1","description":"Module Federation helper for NextJS","main":"index.js","repository":{"type":"git","url":"git+https://github.com/module-federation/nextjs-mf.git"},"author":{"name":"Aurélien MANCA","email":"aurelien@amanca.fr"},"license":"MIT","scripts":{"prettier":"prettier --write \"**/*.{js,json,md,ts,tsx}\""},"bin":{"nextjs-mf":"bin/nextjs-mf.js"},"devDependencies":{"commander":"^6.2.0","prettier":"^2.1.2","react":"^17.0.1"},"peerDependencies":{"react":"^16 || ^17"},"dependencies":{"shelljs":"^0.8.4"},"gitHead":"b00990c954f38caede3fd2696de50606a98bd268","bugs":{"url":"https://github.com/module-federation/nextjs-mf/issues"},"homepage":"https://github.com/module-federation/nextjs-mf#readme","_id":"@alcyone/nextjs-mf@0.1.1","_nodeVersion":"14.15.3","_npmVersion":"6.14.9","dist":{"integrity":"sha512-MAR4IGdyJTSjkXqobyk1brfwjrYMXInI+i3tVVrUoP4rSyqMBCELm/c7xLhHcwF8S8cEyufwNk8CP3Z9vpTJMw==","shasum":"cc151bef86eb5ce5bac71c842c0b764af61ec6f8","tarball":"https://registry.npmjs.org/@alcyone/nextjs-mf/-/nextjs-mf-0.1.1.tgz","fileCount":10,"unpackedSize":240623,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJOzGCRA9TVsSAnZWagAA6hsP/Rc87zkJ1AwOwhJHF1RD\nJxCgYS121RzfbUz2XIom6Hk7GBjcGZnnkeTcfL3MHw1wbtQpXt9bYT3I46D6\nyNSIEK1vziFL3NWvFfSBqgMMrPY+rRFfmwGSzilagmRI3F0NztEPmqrtnBoh\n3Wn5aDYnOkhub78ierGi8cdIDPSX77echi9SsAxMe2ecEq+sniOmZ7A+EeX3\nTpqUnZ1jj+8CUudBZLaHPVU1kQSZt9SQmbWP30Phrz/NQ70PgeVkfQHHIPlR\n63hj63KTKR8NXIVxGM7T8rzLm33j1FYr9+XmgmZ3Htwjs8Fh2FsfOLhAkGMp\nRc1N9jqFOmQ8mWajUEOOKSTkf3vqC+n/7lv7Mjz3+YmrGGEvj9Fe+lQWjWni\n1T6gZEQLMjJT7W8Z+bP7wbXSlqYyqHNcUYimyiNjd18eHVUXlTTGW3pgH200\n5InXcvUeVJ4DpabfQcDoV7/g4B1SRJJQ2ttL7amjeebTVpApwxEOKtrJWK9Z\nQhYpwn73gQ9qO+8XdnffKBa75LMw6lJXyAjqOta3EVIEAYutkh+IkBIfyg+p\nluJ0bFiVStPT0FiV2zMTdn8AG/Gqa9OPQsUAUo+pejDd7CzrLWbmSac0Shf1\nGmY+CgZKvZk5ue42mqASIscaU2+8szq4y7Yu4FGZgqV4T0ycMois5GKsrYxE\n3uvy\r\n=xkEE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCJXB3vcdyeQGqbmWfkpCaY1iRaDp8wGZuUPt4wYl8uQgIgCKl1TCsO/b8MSC/5nwyg+IWc5Zv/sF571mMPJgd8+Ck="}]},"_npmUser":{"name":"noreiller","email":"aurelien@amanca.fr"},"directories":{},"maintainers":[{"name":"noreiller","email":"aurelien@amanca.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nextjs-mf_0.1.1_1613032646004_0.543951952042834"},"_hasShrinkwrap":false},"0.1.2":{"name":"@alcyone/nextjs-mf","version":"0.1.2","description":"Module Federation helper for NextJS","main":"index.js","repository":{"type":"git","url":"git+https://github.com/module-federation/nextjs-mf.git"},"author":{"name":"Aurélien MANCA","email":"aurelien@amanca.fr"},"license":"MIT","scripts":{"prettier":"prettier --write \"**/*.{js,json,md,ts,tsx}\""},"bin":{"nextjs-mf":"bin/nextjs-mf.js"},"devDependencies":{"commander":"^6.2.0","prettier":"^2.1.2","react":"^17.0.1"},"peerDependencies":{"react":"^16 || ^17"},"dependencies":{"shelljs":"^0.8.4"},"gitHead":"9f857dbd7b1d76c90b6e3c23c69145a7f24baf12","bugs":{"url":"https://github.com/module-federation/nextjs-mf/issues"},"homepage":"https://github.com/module-federation/nextjs-mf#readme","_id":"@alcyone/nextjs-mf@0.1.2","_nodeVersion":"14.15.3","_npmVersion":"6.14.9","dist":{"integrity":"sha512-r+oBN//huVwfen4h5Gq8QN8BhdFf172E8qykpUDbdctPpllK7IfV8JYp/uQwJNFKVtCS32xWIF35dEd2asgWBA==","shasum":"2843b57a25e7cc1fa88dffa5dbbc1c0ecfa1bfaf","tarball":"https://registry.npmjs.org/@alcyone/nextjs-mf/-/nextjs-mf-0.1.2.tgz","fileCount":10,"unpackedSize":240679,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJQI1CRA9TVsSAnZWagAAzTUQAIk8cqYDZxbswTDhRj4N\nVf17V8WkWAVZGoV4rWerwLGQq3IIfBXTClQJruPQBrOebfV+ixJXPmrLWBfa\n2XFRxOICb/F74Fo8PjucuKVyROx3BgZHLucW2Spic5E6z060ao/wIS1TWHJ3\ncvsVdVZBWmSxPLcJYy8loLMRFZhCenysFxVVZzqj1tXwQuMiyVpusYzCUJ6i\n2HfZbN1b8+f1/Rs2A5QX1a1DMhwS16emXJrNgLBv9JQ3YymJBlcMDGMr4Grr\nWcPYsh4ZXv5UhA23rmUu5sRTsgjEgPlz9aNOWzyOXW2CwfPAZUgMscNiQAi6\ntGqOXATtOt5LBdNa2FJPhUhqHNsJ+ShamwhdHEybVT/OztzXa8kz8vFjKCyA\nhGxBdbSLZCE6MswEvotsrxBd9cPSc/FbRs/l4ZDazdM107MaUr2r74V+Oir1\nr+QKDD1cbxU3iBUNhOX/+wUIm1vBbCazoE4ZB+Z00E0sV/6APG3IGKzZ+Y1g\nEX7bwsDauFT75jSF/Hslb4eQmxYwdoW5fNu8qIiZDnmPOVU6ootcoDOy+GNo\nMBGt2wewkA8vqdPMe4OPi3Mz6eyONrz4J0xXVu3Drtpfa2A03Wq6gVaFnLDS\nNcAMaSLzo2XZE9xEd0B+wgn3jMET90g8Y64KsP/kaCVXzW5oTXf7Wvji8rfE\nwmHl\r\n=7cDI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDnPiK0tb4aD+exa8sEzD3NB/vwTalC4Wb4cLyxI/vLnAiAxuNdXjwip6aHHYWLeJ3B2JQ8CteN91Meunm0DiZm58w=="}]},"_npmUser":{"name":"noreiller","email":"aurelien@amanca.fr"},"directories":{},"maintainers":[{"name":"noreiller","email":"aurelien@amanca.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nextjs-mf_0.1.2_1613038132932_0.6239613993918658"},"_hasShrinkwrap":false},"0.1.3":{"name":"@alcyone/nextjs-mf","version":"0.1.3","description":"Module Federation helper for NextJS","main":"index.js","repository":{"type":"git","url":"git+https://github.com/module-federation/nextjs-mf.git"},"author":{"name":"Aurélien MANCA","email":"aurelien@amanca.fr"},"license":"MIT","scripts":{"prettier":"prettier --write \"**/*.{js,json,md,ts,tsx}\""},"bin":{"nextjs-mf":"bin/nextjs-mf.js"},"devDependencies":{"commander":"^6.2.0","prettier":"^2.1.2","react":"^17.0.1"},"peerDependencies":{"react":"^16 || ^17"},"dependencies":{"shelljs":"^0.8.4"},"gitHead":"204257fce1e0eccbcca1471db9267865c0705c3b","bugs":{"url":"https://github.com/module-federation/nextjs-mf/issues"},"homepage":"https://github.com/module-federation/nextjs-mf#readme","_id":"@alcyone/nextjs-mf@0.1.3","_nodeVersion":"14.15.3","_npmVersion":"6.14.9","dist":{"integrity":"sha512-8D/wjtqDpYgUPaTMxsC+b4LsoAp41g+LbUQZBLFZnyswzeE2VqaLapV7SWo3EHwjxVQVu2xc16ds6S2M2DfNtA==","shasum":"8bef2300c8e3e33f875c3299d63362fc4ee1fa94","tarball":"https://registry.npmjs.org/@alcyone/nextjs-mf/-/nextjs-mf-0.1.3.tgz","fileCount":10,"unpackedSize":240781,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJQL9CRA9TVsSAnZWagAANcgP/AnPoSmP9xBc4G97uT9o\ndE8+IQflP9oYYi/O6XMhU/2SKXB80Dp9rbHyR7sRIPLxwGY/icASDsCLiiQy\nttURTCzNCEPaUOq4N8RWZRUHZb+31gg8dmygI9FTi52P3DOw0tXV7p1ss/qd\ns30L7vtcqhhZuqaNn185gnVYLOCHfJHa/Oi7s5/HtcsjnYFa4dxDNXLl0S8C\najnwo0I4CUo8qPxoII5IWupSMjMSsyodlU1itzKwGLr1twG2DApHoGyY2mQp\n/bvjm2C+kFmvo58cU+DdaE/FjkOjLg11cBGAE6bn2Vf8RyS4kdQ3ke/qsr7w\nY/Owntfs48llGZB8vFOGejPlAVQm9svzW0OoL3mro2S31d7AYOY27+a24pHi\nr9h1w1IoIYZ766BexE+PgYElVoIEfAjhdZg6b/YCyk4Rb/N51X9tIUijeKfT\nm8wX/Y9tC4NPVNIfSmVPfNsXWRX/tralpDegraiirpLeCfKUVcXSpKiM05FL\nw0xbmkYO2KV31Ixw1ZU4mbjiOCzVKmnJymsRjru8Z1vYu1fc6B4ENKOixi+Q\nd2b6ih/iIZeovGIMed+ni1tkELjRBzzRq55mvxz9zv4N3+0NG1BbivaAeZUi\nHKGbF4/ZOTAKiLF/V1KdRrILqFMqGwOwcI/mRXShI1o4aG/zdoriRT9VLmSh\nnomS\r\n=7Rzc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICx96ZK5zECoS4RYR+CGOTF0HUZZmVCgrluBpORXIm1WAiEAs2EyElFJLlkdZr7aiwFT77HqhXXv7qS+GpV9hN+wrPg="}]},"_npmUser":{"name":"noreiller","email":"aurelien@amanca.fr"},"directories":{},"maintainers":[{"name":"noreiller","email":"aurelien@amanca.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nextjs-mf_0.1.3_1613038332559_0.303734195839958"},"_hasShrinkwrap":false}},"time":{"created":"2021-01-13T08:47:02.612Z","0.0.3":"2021-01-13T08:47:03.182Z","modified":"2022-04-04T12:36:23.235Z","0.1.1":"2021-02-11T08:37:26.171Z","0.1.2":"2021-02-11T10:08:53.173Z","0.1.3":"2021-02-11T10:12:12.765Z"},"maintainers":[{"name":"noreiller","email":"aurelien@amanca.fr"}],"description":"Module Federation helper for NextJS","homepage":"https://github.com/module-federation/nextjs-mf#readme","repository":{"type":"git","url":"git+https://github.com/module-federation/nextjs-mf.git"},"author":{"name":"Aurélien MANCA","email":"aurelien@amanca.fr"},"bugs":{"url":"https://github.com/module-federation/nextjs-mf/issues"},"license":"MIT","readme":"# Module Federation For Next.js\n\nThis plugin enables Module Federation on Next.js\n\nThis is a workaround to hard limitations caused by Next.js being synchronous.\n\nI am working on an update to Webpack Core which will circumvent projects with older architecture (like Next.js).\n\nThis is a stable and viable workaround to leverage Module Federation [until this issue is resolved](https://github.com/webpack/webpack/issues/11811).\n\n### Supports\n\n- next ^9.5.6\n- SSG\n- SSR\n\n**Once I PR webpack, this workaround will no longer be required.**\n\n# Check out our book\n\n| <a href=\"https://module-federation.myshopify.com/products/practical-module-federation\" target=\"_blank\"><img src=\"./docs/MFCover.png\" alt='Practical Module Federation Book' width=\"95%\"/></a> | <a href=\"https://module-federation.myshopify.com/products/practical-module-federation\" target=\"_blank\">We will be actively updating this book over the next year as we learn more about best practices and what issues people are running into with Module Federation, as well as with every release of Webpack as it moves towards a release candidate and release. So with your one purchase you are buying a whole year of updates.</a> |\n| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n\n#### Demo\n\nYou can see it in action here: https://github.com/module-federation/module-federation-examples/tree/master/nextjs\n\n## How to use on a fresh nextjs app\n\n```sh\nyarn global add @module-federation/nextjs-mf\n```\n\nRun this inside of a fresh nextjs install.\n\n```sh\nnextjs-mf upgrade -p 3001\n```\n\n## How to use on an existing app\n\n1. Use `withModuleFederation` in your `next.config.js`\n\n```js\n// next.config.js\nconst { withModuleFederation } = require(\"@module-federation/nextjs-mf\");\nconst path = require(\"path\");\n\nmodule.exports = {\n  webpack: (config, options) => {\n    const { buildId, dev, isServer, defaultLoaders, webpack } = options;\n    const mfConf = {\n      mergeRuntime: true, //this is experimental,  read below\n      name: \"next2\",\n      library: { type: config.output.libraryTarget, name: \"next2\" },\n      filename: \"static/runtime/remoteEntry.js\",\n      remotes: {\n        // For SSR, resolve to disk path (or you can use code streaming if you have access)\n        next1: isServer\n          ? path.resolve(\n              __dirname,\n              \"../next1/.next/server/static/runtime/remoteEntry.js\"\n            )\n          : \"next1\", // for client, treat it as a global\n      },\n      exposes: {\n        \"./nav\": \"./components/nav\",\n      },\n      shared: [\"lodash\"],\n    };\n    // Configures ModuleFederation and other Webpack properties\n    withModuleFederation(config, options, mfConf);\n\n    return config;\n  },\n};\n```\n\n2. Add the `patchSharing` to `_document.js`. This will solve the react sharing issue.\n\n```jsx\nimport Document, { Html, Head, Main, NextScript } from \"next/document\";\nimport { patchSharing } from \"@module-federation/nextjs-mf\";\n\nclass MyDocument extends Document {\n  static async getInitialProps(ctx) {\n    const initialProps = await Document.getInitialProps(ctx);\n    return { ...initialProps };\n  }\n\n  render() {\n    return (\n      <Html>\n        {patchSharing()}\n        <script src=\"http://localhost:3000/_next/static/chunks/webpack.js\" />\n        <script src=\"http://localhost:3000/_next/static/runtime/remoteEntry.js\" />\n        <Head />\n        <body>\n          <Main />\n          <NextScript />\n        </body>\n      </Html>\n    );\n  }\n}\n```\n\n3. Use top-level-await\n\n```js\n// some-component.js\nconst Nav = (await import(\"../components/nav\")).default;\nconst _ = await import(\"lodash\");\n```\n\n## Experimental\n\nUse at your own risk.\n\nNext.js uses `runtimeChunk:'single'`\nWhich forces us to also add the webpack script itself. Till this is fixed in webpack, heres a plugin that will merge the runtimes back together for MF\n\nThis can be enabled via `mergeRuntime` flag. This is not part of Module Federation, its part of this plugin.\n\n`withModuleFederation(config, options, {mergeRuntime:true,...mfConf})`\n\nYou can manually add it as follows\n\n```js\nconst { MergeRuntime } = require(\"@module-federation/nextjs-mf\");\n// in your next config.\nconfig.plugins.push(new MergeRuntime({ filename: \"remoteEntry\" }));\n```\n\nThis allows the following to be done\n\n```diff\n- <script src=\"http://localhost:3000/_next/static/chunks/webpack.js\" />\n- <script src=\"http://localhost:3000/_next/static/runtime/remoteEntry.js\" />\n+ <script src=\"http://localhost:3000/_next/static/remoteEntryMerged.js\" />\n```\n","readmeFilename":"README.md"}