{"id":350118,"date":"2023-07-11T21:00:17","date_gmt":"2023-07-11T21:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=350118"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=350118","title":{"rendered":"<span>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u043c\u043f\u043e\u0440\u0442 remote \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 Module Federation \u043d\u0430 Vue 3<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<blockquote>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432\u00a0\u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435 &#8212; \u044d\u0442\u043e\u00a0\u043d\u0435\u00a0\u0437\u043d\u0430\u043d\u0438\u0435. \u041d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0437\u043d\u0430\u043d\u0438\u044f &#8212; \u044d\u0442\u043e\u00a0\u043e\u043f\u044b\u0442.<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0432\u0441\u0435\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439, \u0447\u0442\u043e \u0437\u0430\u0431\u0440\u0435\u043b\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0432\u044b \u0442\u043e\u0436\u0435 \u043a\u0430\u043a \u0438 \u044f, \u043d\u0435 \u043d\u0430\u0448\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0439\u0442\u0435\u0441\u044c, \u0432\u0435\u0434\u044c \u0442\u0443\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u044f \u043d\u0443\u0436\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b runtime \u0438\u043c\u043f\u043e\u0440\u0442\u0430!<\/p>\n<h2>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f<\/h2>\n<p>\u041f\u043e\u0433\u0440\u0443\u0437\u0438\u0432\u0448\u0438\u0441\u044c \u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 <strong>Module Federation<\/strong>, \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043a\u0430\u043a \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0447\u0442\u043e \u044f \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0431\u044b\u043b\u0430 \u043b\u0438\u0431\u043e \u043f\u0440\u043e \u0442\u0430\u043a\u0443\u044e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e \u043a\u0430\u043a React, \u043b\u0438\u0431\u043e Angular. \u041d\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441 <strong>Vue<\/strong> \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u044b\u0445 \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435, \u0447\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u043d\u0435 \u043a\u0430\u0442\u0438\u0442 \ud83d\ude42 \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0441\u0435\u043c \u0441\u0430\u043c\u043e\u043c\u0443 \u0438 \u0441\u043f\u0443\u0441\u0442\u044f \u0442\u044b\u0441\u044f\u0447\u0438 \u043f\u0440\u043e\u0431 \u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u044f \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0442\u043e \u0434\u043e\u0434\u0435\u043b\u0430\u043b \u0434\u0430\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0438 \u0433\u043e\u0442\u043e\u0432 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u043e\u0433\u043e \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0437\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u043c \u0432\u043e Vue.<\/p>\n<h2>\u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u043e Module Federation<\/h2>\n<p><strong>Module Federation<\/strong> &#8212; \u044d\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u0431-\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b, \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044b \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0438 \u0433\u0438\u0431\u043a\u0438\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b <em>Module Federation<\/em>:<\/p>\n<ol>\n<li>\n<p><strong>\u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0435\u0439<\/strong>: \u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p><strong>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439<\/strong>: \u041c\u043e\u0434\u0443\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e<\/strong>: \u041c\u043e\u0434\u0443\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u043c. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0433\u0438\u0431\u043a\u0438\u0435 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438<\/strong>: Module Federation \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044f\u0432\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438. \u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u043e\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<\/li>\n<\/ol>\n<p>Module Federation \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432 \u0441\u0440\u0435\u0434\u0435 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0433\u0434\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043c\u043e\u0434\u0443\u043b\u0438 \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, Module Federation \u0441\u0442\u0430\u043b \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u0442\u0430\u043a\u0438\u043c\u0438 \u043a\u0430\u043a webpack, \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0438 \u0433\u0438\u0431\u043a\u0438\u0445 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0445 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<h2>\u041f\u043e\u044d\u0442\u0430\u043f\u043d\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c Host \u0438 Remote \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0417\u0430\u0434\u0443\u043c\u043a\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<br \/>Host &#8212; \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c Content \u0438 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u043e\u043d \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 3002. \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Remote \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0436\u0434\u0435\u043c \u043f\u043e\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0432\u0435\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 \u0432 \u0438\u043d\u043f\u0443\u0442, \u0434\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. <em>Profit!<\/em><\/p>\n<p><strong>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438:<\/strong><br \/>1) <em>webpack.config.js<\/em> &#8212; \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043d\u0435\u0447\u0435\u0433\u043e, \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f module federation plugin<\/p>\n<pre><code class=\"javascript\">...   plugins: [     new MiniCssExtractPlugin({       filename: '[name].css',     }),     new ModuleFederationPlugin({       name: 'home',       filename: 'remoteEntry.js',       exposes: {         '.\/Content': '.\/src\/components\/Content',       },       shared: {         vue: {           singleton: true,         },       },     }), ... }); <\/code><\/pre>\n<p>2) <em>Content.vue<\/em>:<\/p>\n<pre><code class=\"javascript\">&lt;template>   &lt;div style=\"color: #d9c1e4;\">{{ title }}&lt;\/div> &lt;\/template> &lt;script> export default {   data() {     return {       title: \"Remote content component\",     };   }, }; &lt;\/script> <\/code><\/pre>\n<p>3) <em>App.vue<\/em><\/p>\n<pre><code class=\"bash\">&lt;template>   &lt;main class=\"main\">     &lt;h3>Host App&lt;\/h3>     &lt;Content \/>   &lt;\/main> &lt;\/template>  &lt;script> import { ref, defineAsyncComponent } from \"vue\"; export default {   components: {     Content: defineAsyncComponent(() => import(\".\/components\/Content\")),   },   setup() {     const count = ref(0);     const inc = () => {       count.value++;     };      return {       count,       inc,     };   }, }; &lt;\/script>  &lt;style> \/* \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u0435\u0439 *\/ @import url('https:\/\/fonts.googleapis.com\/css2?family=Montserrat&amp;display=swap');  img {   width: 200px; } h1 {   font-family: Arial, Helvetica, sans-serif; }  html,body {   margin: 0; }  h3 {   margin: 0;   color:#d9c1e4; }  .main{   height: 100vh;   background: gray;   display: flex;   flex-direction: column;   justify-content: center;   font-family: 'Montserrat', sans-serif;   align-items: center;   color: #fff; } &lt;\/style> <\/code><\/pre>\n<p>4) <em>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f package.json<\/em>:<\/p>\n<pre><code class=\"cpp\">\"scripts\": {     \"start\": \"webpack-cli serve\",     \"serve\": \"serve dist -p 3002\",     \"build\": \"webpack --mode production\",     \"clean\": \"rm -rf dist\"   },<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0448 \u0445\u043e\u0441\u0442 \u0433\u043e\u0442\u043e\u0432 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e. \u041d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u0438\u0442\u044c 3002 \u043f\u043e\u0440\u0442 \u0438 \u0434\u043e\u043b\u0436\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0434\u043b\u044f Remote \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>1) <em>webpack.config.js:<\/em><\/p>\n<pre><code class=\"javascript\">...     new ModuleFederationPlugin({       name: 'layout',       filename: 'remoteEntry.js',       exposes: {},       shared: {         vue: {           singleton: true,         },       },     }), ... <\/code><\/pre>\n<p>2) <em>Layout.vue.<\/em> \u0422\u0443\u0442 \u044f \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435, \u0442.\u043a. \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0412 \u0447\u0435\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442:<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u0442\u044c \u0438\u043d\u043f\u0443\u0442, \u0441 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u043a \u043d\u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>port<\/em><\/p>\n<\/li>\n<li>\n<p>\u0412\u0432\u0435\u0434\u044f \u043f\u043e\u0440\u0442 \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0436\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0442\u043e\u0442 <em>manifest<\/em> \u043f\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0440\u0442\u0443<\/p>\n<\/li>\n<li>\n<p>\u041f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430 \u0438 \u043f\u043e\u0434\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0441\u044f &#8212; \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u043e\u0442\u0442\u0443\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443<\/p>\n<\/li>\n<\/ul>\n<p>3) <em>package.json<\/em>: <\/p>\n<pre><code> \"scripts\": {     \"start\": \"webpack-cli serve\",     \"serve\": \"serve dist -p 3001\",     \"build\": \"webpack --mode production\",     \"clean\": \"rm -rf dist\"   },<\/code><\/pre>\n<h2>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043e\u0434\u0443:<\/h2>\n<p>\u0424\u043e\u0440\u043c\u0430 \u0441 \u0438\u043d\u043f\u0443\u0442\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">&lt;div class=\"component\">     &lt;p style=\"font-size:22px; margin-bottom: 5px\">Layout App&lt;\/p>     &lt;div class=\"form\">     &lt;label>Enter port for loading&lt;\/label>     &lt;input type=\"text\" v-model=\"port\">     &lt;button @click=\"getRemoteComponent\">Get remote component&lt;\/button> &lt;\/div><\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>getRemoteComponent<\/em> \u0438 \u0433\u043e\u0442\u043e\u0432\u043e. \u041e\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430  const uiApplication = {    protocol: 'http',    host: 'localhost',    port: this.port,    fileName: 'remoteEntry.js' } \/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0443 const remoteURL = `${uiApplication.protocol}:\/\/${uiApplication.host}:${uiApplication.port}\/${uiApplication.fileName}`; <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"javascript\">const moduleScope = 'home' \/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 const moduleName = 'Content'  const element = document.createElement('script'); element.type = 'text\/javascript'; element.async = true; element.src = remoteURL;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">element.onerror = () => {     alert(`Port ${this.port} doesn't have any content! Try another`) }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u043e \u0434\u043b\u044f \u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0435\u0441\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/webpack.js.org\/concepts\/module-federation\/\" rel=\"noopener noreferrer nofollow\"><em>webpack<\/em>&#8216;a<\/a>:<\/p>\n<pre><code class=\"javascript\">async loadModule(scope, module) {     await __webpack_init_sharing__('default');     const container = window[scope];     await container.init(__webpack_share_scopes__.default);     const factory = await window[scope].get(module);     const Module = factory();     return Module;   }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u0438\u0434\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/368\/148\/a04\/368148a041f52e0ceeddd204044fe5cd.png\" alt=\"\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 loadModule\" title=\"\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 loadModule\" width=\"771\" height=\"149\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/368\/148\/a04\/368148a041f52e0ceeddd204044fe5cd.png\"\/><\/p>\n<div><figcaption>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 loadModule<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0435\u0432\u043e\u043e\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c \u0433\u043b\u0430\u0437\u043e\u043c \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043a\u0430\u043a\u0430\u044f \u0442\u043e \u0448\u0442\u0443\u043a\u0430, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0430\u044f\u0441\u044f \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443, \u043d\u043e \u0432\u043e\u0442 \u0447\u0442\u043e \u0441 \u043d\u0435\u0439 \u0434\u0435\u043b\u0430\u0442\u044c? \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442 &#8212; \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 \u0438\u0437 Vue \u0438 \u043e\u043d\u043e \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043e\u0431\u0435\u0440\u0435\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442! <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430:<\/p>\n<pre><code class=\"javascript\">element.onload = () => {     const remoteComponent = this.loadModule(moduleScope, `.\/${moduleName}`)     remoteComponent.then(res => {       console.log(res.default);       this.dynamicComponent = res.default;      }) }; document.head.appendChild(element);<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435! \u041d\u0430\u0448\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u043c \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">&lt;div class=\"component\">     &lt;p style=\"font-size:22px; margin-bottom: 5px\">Remote App&lt;\/p>     &lt;component :is=\"dynamicComponent\">&lt;\/component> &lt;\/div><\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0435\u043d\u0430, \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \ud83d\ude42<br \/>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <em>Layout.vue<\/em>:<\/p>\n<pre><code class=\"javascript\">&lt;template>   &lt;div class=\"main\">     &lt;div class=\"component\">       &lt;p style=\"font-size:22px; margin-bottom: 5px\">Layout App&lt;\/p>       &lt;div class=\"form\">         &lt;label>Enter port for loading&lt;\/label>         &lt;input type=\"text\" v-model=\"port\">         &lt;button @click=\"getRemoteComponent\">Get remote component&lt;\/button>       &lt;\/div>     &lt;\/div>     &lt;div class=\"component\">       &lt;p style=\"font-size:22px; margin-bottom: 5px\">Remote App&lt;\/p>       &lt;component :is=\"dynamicComponent\">&lt;\/component>     &lt;\/div>   &lt;\/div> &lt;\/template>  &lt;script> export default {   data() {     return {       port: null,       dynamicComponent: null     }   },   methods: {     getRemoteComponent() {       console.log(this.port, '&lt;- \u041f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u0442\u0443')        \/\/ \u041c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438       const uiApplication = {         protocol: 'http',         host: 'localhost',         port: this.port,         fileName: 'remoteEntry.js'       }        const remoteURL = `${uiApplication.protocol}:\/\/${uiApplication.host}:${uiApplication.port}\/${uiApplication.fileName}`;       console.log(remoteURL)        const moduleScope = 'home'       const moduleName = 'Content'       const element = document.createElement('script');       element.type = 'text\/javascript';       element.async = true;       element.src = remoteURL;        element.onload = () => {         const remoteComponent = this.loadModule(moduleScope, `.\/${moduleName}`)         remoteComponent.then(res => {           console.log(res.default);           this.dynamicComponent = res.default;         })       };        element.onerror = () => {         alert(`Port ${this.port} doesn't have any content! Try another`)       }        document.head.appendChild(element);     },     async loadModule(scope, module) {       await __webpack_init_sharing__('default');       const container = window[scope];       await container.init(__webpack_share_scopes__.default);       const factory = await window[scope].get(module);       const Module = factory();       return Module;     }   } }; &lt;\/script>  &lt;style> @import url('https:\/\/fonts.googleapis.com\/css2?family=Montserrat&amp;display=swap');  * {   font-family: 'Montserrat', sans-serif;   color:#fff; }  body, p {   margin: 0; }  .main {   height: 100vh;   display: flex;   background: gray; }  .component {   display: flex;   flex-direction: column;   justify-content: center;   align-items: center;   border: 2px solid #ffff;   padding: 5px;   border-radius: 10px;   width: 100%; }  .form {   display: flex;   max-width: 300px;   flex-direction: column; }  input {   margin: 10px 0;   color:black; }  button {   color: black; }  &lt;\/style> <\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 (\u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0445\u043e\u0441\u0442 \u0440\u0430\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u043e 3002 \u043f\u043e\u0440\u0442\u0443):<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/43e\/2db\/6b5\/43e2db6b5def8ca074fe525716e314f4.gif\" alt=\"\u0424\u0438\u043d\u0430\u043b \u0442\u0435\u043c\u044b\" title=\"\u0424\u0438\u043d\u0430\u043b \u0442\u0435\u043c\u044b\" width=\"1912\" height=\"916\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/43e\/2db\/6b5\/43e2db6b5def8ca074fe525716e314f4.gif\"\/><\/p>\n<div><figcaption>\u0424\u0438\u043d\u0430\u043b \u0442\u0435\u043c\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0435\u0441\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043c\u043e\u0435\u043c <a href=\"https:\/\/github.com\/Arthur410\/dynamic-module-federation-vue-webpack\/tree\/master\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a><\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u043b\u044f \u0432\u0430\u0441!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \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\/articles\/747384\/\"> https:\/\/habr.com\/ru\/articles\/747384\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<blockquote>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432\u00a0\u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435 &#8212; \u044d\u0442\u043e\u00a0\u043d\u0435\u00a0\u0437\u043d\u0430\u043d\u0438\u0435. \u041d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0437\u043d\u0430\u043d\u0438\u044f &#8212; \u044d\u0442\u043e\u00a0\u043e\u043f\u044b\u0442.<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0432\u0441\u0435\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439, \u0447\u0442\u043e \u0437\u0430\u0431\u0440\u0435\u043b\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0432\u044b \u0442\u043e\u0436\u0435 \u043a\u0430\u043a \u0438 \u044f, \u043d\u0435 \u043d\u0430\u0448\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0439\u0442\u0435\u0441\u044c, \u0432\u0435\u0434\u044c \u0442\u0443\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u044f \u043d\u0443\u0436\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b runtime \u0438\u043c\u043f\u043e\u0440\u0442\u0430!<\/p>\n<h2>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f<\/h2>\n<p>\u041f\u043e\u0433\u0440\u0443\u0437\u0438\u0432\u0448\u0438\u0441\u044c \u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 <strong>Module Federation<\/strong>, \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043a\u0430\u043a \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0447\u0442\u043e \u044f \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0431\u044b\u043b\u0430 \u043b\u0438\u0431\u043e \u043f\u0440\u043e \u0442\u0430\u043a\u0443\u044e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e \u043a\u0430\u043a React, \u043b\u0438\u0431\u043e Angular. \u041d\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441 <strong>Vue<\/strong> \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u044b\u0445 \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435, \u0447\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u043d\u0435 \u043a\u0430\u0442\u0438\u0442 \ud83d\ude42 \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0441\u0435\u043c \u0441\u0430\u043c\u043e\u043c\u0443 \u0438 \u0441\u043f\u0443\u0441\u0442\u044f \u0442\u044b\u0441\u044f\u0447\u0438 \u043f\u0440\u043e\u0431 \u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u044f \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0442\u043e \u0434\u043e\u0434\u0435\u043b\u0430\u043b \u0434\u0430\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0438 \u0433\u043e\u0442\u043e\u0432 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u043e\u0433\u043e \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0437\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u043c \u0432\u043e Vue.<\/p>\n<h2>\u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u043e Module Federation<\/h2>\n<p><strong>Module Federation<\/strong> &#8212; \u044d\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u0431-\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b, \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044b \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0438 \u0433\u0438\u0431\u043a\u0438\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b <em>Module Federation<\/em>:<\/p>\n<ol>\n<li>\n<p><strong>\u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0435\u0439<\/strong>: \u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p><strong>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439<\/strong>: \u041c\u043e\u0434\u0443\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e<\/strong>: \u041c\u043e\u0434\u0443\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u043c. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0433\u0438\u0431\u043a\u0438\u0435 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438<\/strong>: Module Federation \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044f\u0432\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438. \u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u043e\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<\/li>\n<\/ol>\n<p>Module Federation \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432 \u0441\u0440\u0435\u0434\u0435 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0433\u0434\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043c\u043e\u0434\u0443\u043b\u0438 \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, Module Federation \u0441\u0442\u0430\u043b \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u0442\u0430\u043a\u0438\u043c\u0438 \u043a\u0430\u043a webpack, \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0438 \u0433\u0438\u0431\u043a\u0438\u0445 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0445 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<h2>\u041f\u043e\u044d\u0442\u0430\u043f\u043d\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c Host \u0438 Remote \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0417\u0430\u0434\u0443\u043c\u043a\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<br \/>Host &#8212; \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c Content \u0438 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u043e\u043d \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 3002. \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Remote \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0436\u0434\u0435\u043c \u043f\u043e\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0432\u0435\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 \u0432 \u0438\u043d\u043f\u0443\u0442, \u0434\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. <em>Profit!<\/em><\/p>\n<p><strong>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438:<\/strong><br \/>1) <em>webpack.config.js<\/em> &#8212; \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043d\u0435\u0447\u0435\u0433\u043e, \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f module federation plugin<\/p>\n<pre><code class=\"javascript\">...   plugins: [     new MiniCssExtractPlugin({       filename: '[name].css',     }),     new ModuleFederationPlugin({       name: 'home',       filename: 'remoteEntry.js',       exposes: {         '.\/Content': '.\/src\/components\/Content',       },       shared: {         vue: {           singleton: true,         },       },     }), ... }); <\/code><\/pre>\n<p>2) <em>Content.vue<\/em>:<\/p>\n<pre><code class=\"javascript\">&lt;template>   &lt;div style=\"color: #d9c1e4;\">{{ title }}&lt;\/div> &lt;\/template> &lt;script> export default {   data() {     return {       title: \"Remote content component\",     };   }, }; &lt;\/script> <\/code><\/pre>\n<p>3) <em>App.vue<\/em><\/p>\n<pre><code class=\"bash\">&lt;template>   &lt;main class=\"main\">     &lt;h3>Host App&lt;\/h3>     &lt;Content \/>   &lt;\/main> &lt;\/template>  &lt;script> import { ref, defineAsyncComponent } from \"vue\"; export default {   components: {     Content: defineAsyncComponent(() => import(\".\/components\/Content\")),   },   setup() {     const count = ref(0);     const inc = () => {       count.value++;     };      return {       count,       inc,     };   }, }; &lt;\/script>  &lt;style> \/* \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u0435\u0439 *\/ @import url('https:\/\/fonts.googleapis.com\/css2?family=Montserrat&amp;display=swap');  img {   width: 200px; } h1 {   font-family: Arial, Helvetica, sans-serif; }  html,body {   margin: 0; }  h3 {   margin: 0;   color:#d9c1e4; }  .main{   height: 100vh;   background: gray;   display: flex;   flex-direction: column;   justify-content: center;   font-family: 'Montserrat', sans-serif;   align-items: center;   color: #fff; } &lt;\/style> <\/code><\/pre>\n<p>4) <em>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f package.json<\/em>:<\/p>\n<pre><code class=\"cpp\">\"scripts\": {     \"start\": \"webpack-cli serve\",     \"serve\": \"serve dist -p 3002\",     \"build\": \"webpack --mode production\",     \"clean\": \"rm -rf dist\"   },<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0448 \u0445\u043e\u0441\u0442 \u0433\u043e\u0442\u043e\u0432 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e. \u041d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u0438\u0442\u044c 3002 \u043f\u043e\u0440\u0442 \u0438 \u0434\u043e\u043b\u0436\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0434\u043b\u044f Remote \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>1) <em>webpack.config.js:<\/em><\/p>\n<pre><code class=\"javascript\">...     new ModuleFederationPlugin({       name: 'layout',       filename: 'remoteEntry.js',       exposes: {},       shared: {         vue: {           singleton: true,         },       },     }), ... <\/code><\/pre>\n<p>2) <em>Layout.vue.<\/em> \u0422\u0443\u0442 \u044f \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435, \u0442.\u043a. \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0412 \u0447\u0435\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442:<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u0442\u044c \u0438\u043d\u043f\u0443\u0442, \u0441 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u043a \u043d\u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>port<\/em><\/p>\n<\/li>\n<li>\n<p>\u0412\u0432\u0435\u0434\u044f \u043f\u043e\u0440\u0442 \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0436\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0442\u043e\u0442 <em>manifest<\/em> \u043f\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0440\u0442\u0443<\/p>\n<\/li>\n<li>\n<p>\u041f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430 \u0438 \u043f\u043e\u0434\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0441\u044f &#8212; \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u043e\u0442\u0442\u0443\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443<\/p>\n<\/li>\n<\/ul>\n<p>3) <em>package.json<\/em>: <\/p>\n<pre><code> \"scripts\": {     \"start\": \"webpack-cli serve\",     \"serve\": \"serve dist -p 3001\",     \"build\": \"webpack --mode production\",     \"clean\": \"rm -rf dist\"   },<\/code><\/pre>\n<h2>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043e\u0434\u0443:<\/h2>\n<p>\u0424\u043e\u0440\u043c\u0430 \u0441 \u0438\u043d\u043f\u0443\u0442\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">&lt;div class=\"component\">     &lt;p style=\"font-size:22px; margin-bottom: 5px\">Layout App&lt;\/p>     &lt;div class=\"form\">     &lt;label>Enter port for loading&lt;\/label>     &lt;input type=\"text\" v-model=\"port\">     &lt;button @click=\"getRemoteComponent\">Get remote component&lt;\/button> &lt;\/div><\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>getRemoteComponent<\/em> \u0438 \u0433\u043e\u0442\u043e\u0432\u043e. \u041e\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430  const uiApplication = {    protocol: 'http',    host: 'localhost',    port: this.port,    fileName: 'remoteEntry.js' } \/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0443 const remoteURL = `${uiApplication.protocol}:\/\/${uiApplication.host}:${uiApplication.port}\/${uiApplication.fileName}`; <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"javascript\">const moduleScope = 'home' \/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 const moduleName = 'Content'  const element = document.createElement('script'); element.type = 'text\/javascript'; element.async = true; element.src = remoteURL;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">element.onerror = () => {     alert(`Port ${this.port} doesn't have any content! Try another`) }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u043e \u0434\u043b\u044f \u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0435\u0441\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/webpack.js.org\/concepts\/module-federation\/\" rel=\"noopener noreferrer nofollow\"><em>webpack<\/em>&#8216;a<\/a>:<\/p>\n<pre><code class=\"javascript\">async loadModule(scope, module) {     await __webpack_init_sharing__('default');     const container = window[scope];     await container.init(__webpack_share_scopes__.default);     const factory = await window[scope].get(module);     const Module = factory();     return Module;   }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u0438\u0434\u0430:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 loadModule<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0435\u0432\u043e\u043e\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c \u0433\u043b\u0430\u0437\u043e\u043c \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043a\u0430\u043a\u0430\u044f \u0442\u043e \u0448\u0442\u0443\u043a\u0430, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0430\u044f\u0441\u044f \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443, \u043d\u043e \u0432\u043e\u0442 \u0447\u0442\u043e \u0441 \u043d\u0435\u0439 \u0434\u0435\u043b\u0430\u0442\u044c? \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442 &#8212; \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 \u0438\u0437 Vue \u0438 \u043e\u043d\u043e \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043e\u0431\u0435\u0440\u0435\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442! <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430:<\/p>\n<pre><code class=\"javascript\">element.onload = () => {     const remoteComponent = this.loadModule(moduleScope, `.\/${moduleName}`)     remoteComponent.then(res => {       console.log(res.default);       this.dynamicComponent = res.default;      }) }; document.head.appendChild(element);<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435! \u041d\u0430\u0448\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u043c \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">&lt;div class=\"component\">     &lt;p style=\"font-size:22px; margin-bottom: 5px\">Remote App&lt;\/p>     &lt;component :is=\"dynamicComponent\">&lt;\/component> &lt;\/div><\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0435\u043d\u0430, \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \ud83d\ude42<br \/>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <em>Layout.vue<\/em>:<\/p>\n<pre><code class=\"javascript\">&lt;template>   &lt;div class=\"main\">     &lt;div class=\"component\">       &lt;p style=\"font-size:22px; margin-bottom: 5px\">Layout App&lt;\/p>       &lt;div class=\"form\">         &lt;label>Enter port for loading&lt;\/label>         &lt;input type=\"text\" v-model=\"port\">         &lt;button @click=\"getRemoteComponent\">Get remote component&lt;\/button>       &lt;\/div>     &lt;\/div>     &lt;div class=\"component\">       &lt;p style=\"font-size:22px; margin-bottom: 5px\">Remote App&lt;\/p>       &lt;component :is=\"dynamicComponent\">&lt;\/component>     &lt;\/div>   &lt;\/div> &lt;\/template>  &lt;script> export default {   data() {     return {       port: null,       dynamicComponent: null     }   },   methods: {     getRemoteComponent() {       console.log(this.port, '&lt;- \u041f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u0442\u0443')        \/\/ \u041c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438       const uiApplication = {         protocol: 'http',         host: 'localhost',         port: this.port,         fileName: 'remoteEntry.js'       }        const remoteURL = `${uiApplication.protocol}:\/\/${uiApplication.host}:${uiApplication.port}\/${uiApplication.fileName}`;       console.log(remoteURL)        const moduleScope = 'home'       const moduleName = 'Content'       const element = document.createElement('script');       element.type = 'text\/javascript';       element.async = true;       element.src = remoteURL;        element.onload = () => {         const remoteComponent = this.loadModule(moduleScope, `.\/${moduleName}`)         remoteComponent.then(res => {           console.log(res.default);           this.dynamicComponent = res.default;         })       };        element.onerror = () => {         alert(`Port ${this.port} doesn't have any content! Try another`)       }        document.head.appendChild(element);     },     async loadModule(scope, module) {       await __webpack_init_sharing__('default');       const container = window[scope];       await container.init(__webpack_share_scopes__.default);       const factory = await<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-350118","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350118","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=350118"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350118\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}