{"id":305331,"date":"2020-06-14T21:00:58","date_gmt":"2020-06-14T21:00:58","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=305331"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=305331","title":{"rendered":"Module Federation \u0432 Webpack 5, \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 Javascript \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/506634\/\">\u0412 \u043f\u044f\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 Webpack \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u0430\u0431\u043e\u0440 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 Javascript \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u2014 \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0432\u0443\u0445 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 ReactJS.<\/p>\n<p>  \u041f\u043b\u0430\u0433\u0438\u043d Module Federation \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 JS \u0444\u0430\u0439\u043b. \u041e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0421\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u044d\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043a\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u041f\u0440\u0438\u0447\u0451\u043c, \u0438\u043c\u043f\u043e\u0440\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 Webpack \u0431\u0435\u0440\u0451\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f. \u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 NPM \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u043c\u043f\u043e\u0440\u0442 \u0432 runtime.<br \/>  <a name=\"habracut\"><\/a><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7q\/g2\/y-\/7qg2y-fecvyyryu0l_bnmyje1k0.png\"\/><\/p>\n<p>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 webpack \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\u043c\u043e\u0434\u0443\u043b\u0438 \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0430<\/li>\n<li>\u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0430 <em>\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 export.js<\/em><\/li>\n<li>\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e <em>\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 export.js<\/em><\/li>\n<\/ul>\n<p>  \u0412 HTML \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f-\u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f JS \u0444\u0430\u0439\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 JS \u0441\u043a\u0440\u0438\u043f\u0442: <\/p>\n<pre><code class=\"xml\">&lt;script src=&quot;http:\/\/source-app.com\/export.js&quot;&gt; <\/code><\/pre>\n<p>  \u0410 \u0432 webpack \u043a\u043e\u043d\u0444\u0438\u0433\u0435, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<h4>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442<\/h4>\n<p>  <b>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/b> \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 webpack.config.js<br \/>  \u0412 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043a\u0430\u043a\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0432 \u043d\u0435\u0433\u043e \u0432\u043e\u0439\u0434\u0443\u0442 \u0438 \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0430\u0439\u043b.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">const HtmlWebpackPlugin = require('html-webpack-plugin'); const ModuleFederationPlugin = require('webpack\/lib\/container\/ModuleFederationPlugin');   module.exports = {  ...  plugins: [    new ModuleFederationPlugin({      name: 'home',      library: { type: 'var', name: 'home' },      filename: 'export.js',      exposes: {        ProductCarousel: '.\/src\/ProductCarousel'      },      shared: ['react', 'react-dom', '@material-ui\/core', '@material-ui\/icons']    }),  ] };<\/code><\/pre>\n<\/div><\/div>\n<p>  <b>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435-\u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044c<\/b><\/p>\n<ul>\n<li>\u0412 index.html \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 js \u0444\u0430\u0439\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u043f\u0440\u0438\u043c\u0435\u0440<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt;  &lt;head&gt;    &lt;script src=&quot;http:\/\/source-app.com\/export.js&quot;&gt;&lt;\/script&gt;<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/li>\n<li>\u0412 webpack.config.js, \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043f\u043b\u0430\u0433\u0438\u043d \u0441\u0430\u043c \u043d\u0430\u0439\u0434\u0451\u0442 \u0435\u0433\u043e \u0432 JS \u0444\u0430\u0439\u043b\u0435\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">const HtmlWebpackPlugin = require('html-webpack-plugin'); const ModuleFederationPlugin = require('webpack\/lib\/container\/ModuleFederationPlugin');   module.exports = { ...  plugins: [    new ModuleFederationPlugin({      remotes: {home: 'home' } \/\/\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440    }),  ] };<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/li>\n<li>\u0412 JSX \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u0438\u0437 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import React from 'react'; import ProductCarousel from 'home\/ProductCarousel';   function App() {  return (      &lt;ProductCarousel \/&gt;  ); }   export default App;<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/li>\n<\/ul>\n<p>  <\/p>\n<h4>\u0412\u043e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/h4>\n<p>  <\/p>\n<ol>\n<li>\u0421\u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0439\u0442\u0435 \u0440\u0435\u043f\u043e <a href=\"https:\/\/github.com\/jherr\/wp5-intro-video-code\">github.com\/jherr\/wp5-intro-video-code<\/a> <\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\n<pre><code class=\"javascript\">yarn install yarn start<\/code><\/pre>\n<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u0442\u044f\u0442\u0441\u044f \u0442\u0440\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0440\u0435\u0430\u043a\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0440\u0442\u0430\u0445<br \/> \n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td>home (packages\/home)<\/td>\n<td><a href=\"http:\/\/localhost\">localhost<\/a>:3001\/<\/td>\n<\/tr>\n<tr>\n<td>search page (packages\/search)<\/td>\n<td><a href=\"http:\/\/localhost\">localhost<\/a>:3002\/<\/td>\n<\/tr>\n<tr>\n<td>nav (packages\/nav)<\/td>\n<td><a href=\"http:\/\/localhost\">localhost<\/a>:3003\/<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  <\/li>\n<li>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u0435\u0431\u043f\u0430\u043a \u0432 home: packages\/home\/webpack.config.js, \u0442\u0430\u043c \u0443\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 ProductCarousel\n<pre><code class=\"javascript\">new ModuleFederationPlugin({      name: 'home',      library: { type: 'var', name: 'home' },      filename: 'remoteEntry.js', \/\/\u0432 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0435\u0441\u044c \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435\u0439      remotes: {        nav: 'nav'      },      exposes: {        ProductCarousel: '.\/src\/ProductCarousel'  \/\/\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043e\u0434\u0438\u043d \u043c\u043e\u0434\u0443\u043b\u044c, \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e ProductCarousel      },      shared: ['react', 'react-dom', '@material-ui\/core', '@material-ui\/icons'] \/\/\u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f    }),<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 home <i>(\u044f \u043e\u0431\u0432\u0451\u043b \u0435\u0433\u043e \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0440\u0430\u043c\u043a\u043e\u0439)<\/i><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jj\/st\/ii\/jjstiibqhurwedeqpxd_dizbd8k.png\"\/>  <\/li>\n<li>\u0422\u0435\u043f\u0435\u0440\u044c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 SearchPage\n<ol>\n<li>\u0412 packages\/search\/public\/index.html \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0438\u043c\u043f\u043e\u0440\u0442 JS \u0444\u0430\u0439\u043b\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 home, \u043e\u043d \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f remoteEntry.js (\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0440\u0442 3001 \u2014 \u044d\u0442\u043e \u043f\u043e\u0440\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f home)\n<pre><code class=\"xml\">&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt;  &lt;head&gt;    &lt;script src=&quot;http:\/\/localhost:3003\/remoteEntry.js&quot;&gt;&lt;\/script&gt;    &lt;script src=&quot;http:\/\/localhost:3001\/remoteEntry.js&quot;&gt;&lt;\/script&gt;  &lt;\/head&gt;  &lt;body&gt;    &lt;div id=&quot;root&quot;&gt;&lt;\/div&gt;  &lt;\/body&gt; &lt;\/html&gt;<\/code><\/pre>\n<\/li>\n<li> \u0412 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0432\u0435\u0431\u043f\u0430\u043a \u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 remotes \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0435, ModuleFederation \u0441\u0430\u043c \u043d\u0430\u0439\u0434\u0451\u0442 \u0435\u0433\u043e. <i>(\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043a\u0440\u043e\u043c\u0435 remotes \u0438 \u0438\u043c\u043f\u043e\u0440\u0442 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u043c)<\/i>\n<pre><code class=\"xml\">module.exports = {  ...  plugins: [    new ModuleFederationPlugin({      name: 'search',      library: { type: 'var', name: 'search' },      filename: 'remoteEntry.js',      remotes: {        nav: 'nav',        home: 'home'      },      exposes: {      },      shared: ['react', 'react-dom', '@material-ui\/core', '@material-ui\/icons']    }),<\/code><\/pre>\n<\/li>\n<li> \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0442\u0430\u0432\u044c\u0442\u0435 \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 \u043a\u043e\u0434\u0435 SearchPage, packages\/search\/src\/App.jsx\n<pre><code class=\"xml\">import ProductCarousel from 'home\/ProductCarousel'; function App() {  return (    &lt;Container fixed&gt;      &lt;CssBaseline \/&gt;      &lt;Header \/&gt;      &lt;Typography variant=&quot;h3&quot;&gt;        Search Page.      &lt;\/Typography&gt;      &lt;ProductCarousel \/&gt;    &lt;\/Container&gt;  ); }<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>  <\/li>\n<li>\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 yarn \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0437\u0430\u043d\u043e\u0432\u043e, \u0447\u0442\u043e \u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0435\u0431\u043f\u0430\u043a \u0432\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u0432 \u0441\u0438\u043b\u0443. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 SearchPage \u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0442\u0430\u043c \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043a\u0430\u0440\u0443\u0441\u0435\u043b\u044c \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f home <a href=\"http:\/\/localhost\">localhost<\/a>:3002\/<br \/> \n<div class=\"scrollable-table\">\n<table>\n<tr>\n<th>\u0411\u044b\u043b\u043e<\/th>\n<th>\u0421\u0442\u0430\u043b\u043e<\/th>\n<\/tr>\n<tr>\n<td><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/8a\/2k\/-4\/8a2k-4lkfu9r5txmkxfb1bzbzje.png\"\/><\/td>\n<td><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/9u\/-g\/1a\/9u-g1alssbujadsbd47kgwidjyi.png\"\/><\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/li>\n<\/ol>\n<p>  <\/p>\n<h4>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h4>\n<p>  <\/p>\n<ul>\n<li>\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0435\u0431\u043f\u0430\u043a \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0437\u0434\u0435\u0441\u044c <a href=\"https:\/\/webpack.js.org\/concepts\/module-federation\/\">webpack.js.org\/concepts\/module-federation<\/a><\/li>\n<li>\u0421\u0442\u0430\u0442\u044c\u044f \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c <a href=\"https:\/\/indepth.dev\/webpack-5-module-federation-a-game-changer-in-javascript-architecture\/\">indepth.dev\/webpack-5-module-federation-a-game-changer-in-javascript-architecture<\/a><\/li>\n<li>\u041e\u0442\u043b\u0438\u0447\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043e \u0441 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435\u043c \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043a\u043e\u0434\u0430 <a href=\"https:\/\/youtu.be\/D3XYAx30CNc\">youtu.be\/D3XYAx30CNc<\/a><\/li>\n<\/ul>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/506634\/\"> https:\/\/habr.com\/ru\/post\/506634\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/506634\/\">\u0412 \u043f\u044f\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 Webpack \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u0430\u0431\u043e\u0440 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 Javascript \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u2014 \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0432\u0443\u0445 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 ReactJS.<\/p>\n<p>  \u041f\u043b\u0430\u0433\u0438\u043d Module Federation \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 JS \u0444\u0430\u0439\u043b. \u041e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0421\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u044d\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043a\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u041f\u0440\u0438\u0447\u0451\u043c, \u0438\u043c\u043f\u043e\u0440\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 Webpack \u0431\u0435\u0440\u0451\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f. \u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 NPM \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u043c\u043f\u043e\u0440\u0442 \u0432 runtime.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-305331","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=305331"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305331\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=305331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=305331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=305331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}