remote
, 引用者被称为host
,remote
暴露模块给host
, host
则可以使用这些暴露的模块,这些模块被成为remote
模块字段 | 类型 | 含义 |
---|---|---|
name | string | 必传值,即输出的模块名,被远程引用时路径为${name}/${expose} |
library | object | 声明全局变量的方式,name为umd的name |
filename | string | 构建输出的文件名 |
remotes | object | 远程引用的应用名及其别名的映射,使用时以key值作为name |
exposes | object | 被远程引用时可暴露的资源路径及其别名 |
shared | object | 与其他应用之间可以共享的第三方依赖,使你的代码中不用重复加载同一份依赖 |
let path = require("path");
let webpack = require("webpack");
let HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
publicPath: "http://localhost:3000/",
},
devServer: {
port: 3000
},
module: {
rules: [
{
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: ["@babel/preset-react"]
},
},
exclude: /node_modules/,
},
]
},
plugins: [
new HtmlWebpackPlugin({
template:'./public/index.html'
}),
new ModuleFederationPlugin({
filename: "remoteEntry.js",
name: "remote",
exposes: {
"./NewsList": "./src/NewsList",
}
})
]
}
remote\src\index.js
import("./bootstrap");
remote\src\bootstrap.js
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(<App />, document.getElementById("root"));
remote\src\App.js
import React from "react";
import NewsList from './NewsList';
const App = () => (
<div>
<h2>本地组件NewsList</h2>
<NewsList />
</div>
);
export default App;
remote\src\NewsList.js
import React from "react";
export default ()=>(
<div>新闻列表</div>
)
host\webpack.config.js
let path = require("path");
let webpack = require("webpack");
let HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
publicPath: "http://localhost:8000/",
},
devServer: {
port: 8000
},
module: {
rules: [
{
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: ["@babel/preset-react"]
},
},
exclude: /node_modules/,
},
]
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html'
}),
new ModuleFederationPlugin({
filename: "remoteEntry.js",
name: "host",
remotes: {
remote: "remote@http://localhost:3000/remoteEntry.js"
}
})
]
}
host\src\index.js
import("./bootstrap");
host\src\bootstrap.js
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(<App />, document.getElementById("root"));
host\src\App.js
import React from "react";
import Slides from './Slides';
const RemoteNewsList = React.lazy(() => import("remote/NewsList"));
const App = () => (
<div>
<h2 >本地组件Slides, 远程组件NewsList</h2>
<Slides />
<React.Suspense fallback="Loading NewsList">
<RemoteNewsList />
</React.Suspense>
</div>
);
export default App;
host\src\Slides.js
import React from "react";
export default ()=>(
<div>轮播图</div>
)
shared
配置主要是用来避免项目出现多个公共依赖 plugins: [
new HtmlWebpackPlugin({
template:'./public/index.html'
}),
new ModuleFederationPlugin({
filename: "remoteEntry.js",
name: "remote",
exposes: {
"./NewsList": "./src/NewsList",
},
+ shared:{
+ react: { singleton: true },
+ "react-dom": { singleton: true }
+ }
})
]
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html'
}),
new ModuleFederationPlugin({
filename: "remoteEntry.js",
name: "host",
remotes: {
remote: "remote@http://localhost:3000/remoteEntry.js"
},
+ shared:{
+ react: { singleton: true },
+ "react-dom": { singleton: true }
+ }
})
]
plugins: [
new HtmlWebpackPlugin({
template:'./public/index.html'
}),
new ModuleFederationPlugin({
filename: "remoteEntry.js",
name: "remote",
+ remotes: {
+ host: "host@http://localhost:8000/remoteEntry.js"
+ },
exposes: {
"./NewsList": "./src/NewsList",
},
shared:{
react: { singleton: true },
"react-dom": { singleton: true }
}
})
]
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html'
}),
new ModuleFederationPlugin({
filename: "remoteEntry.js",
name: "host",
remotes: {
remote: "remote@http://localhost:3000/remoteEntry.js"
},
+ exposes: {
+ "./Slides": "./src/Slides",
+ },
shared:{
react: { singleton: true },
"react-dom": { singleton: true }
}
})
]
remote\src\App.js
import React from "react";
import NewsList from './NewsList';
+const RemoteSlides = React.lazy(() => import("host/Slides"));
const App = () => (
<div>
+ <h2>本地组件NewsList,远程组件Slides</h2>
<NewsList />
+ <React.Suspense fallback="Loading Slides">
+ <RemoteSlides />
+ </React.Suspense>
</div>
);
export default App;
let path = require("path");
let webpack = require("webpack");
let HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
publicPath: "http://localhost:3000/",
},
devServer: {
port: 5000
},
module: {
rules: [
{
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: ["@babel/preset-react"]
},
},
exclude: /node_modules/,
},
]
},
plugins: [
new HtmlWebpackPlugin({
template:'./public/index.html'
}),
new ModuleFederationPlugin({
filename: "remoteEntry.js",
name: "all",
remotes: {
remote: "remote@http://localhost:3000/remoteEntry.js",
host: "host@http://localhost:8000/remoteEntry.js",
},
shared:{
react: { singleton: true },
"react-dom": { singleton: true }
}
})
]
}
remote\src\index.js
import("./bootstrap");
remote\src\bootstrap.js
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(<App />, document.getElementById("root"));
remote\src\App.js
import React from "react";
const RemoteSlides = React.lazy(() => import("host/Slides"));
const RemoteNewsList = React.lazy(() => import("remote/NewsList"));
const App = () => (
<div>
<h2>远程组件Slides,远程组件NewsList</h2>
<React.Suspense fallback="Loading Slides">
<RemoteSlides />
</React.Suspense>
<React.Suspense fallback="Loading NewsList">
<RemoteNewsList />
</React.Suspense>
</div>
);
export default App;
npm install webpack webpack-cli webpack-dev-server html-webpack-plugin -D
remote\webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
module.exports = {
mode: 'development',
devtool: false,
entry: './src/index.js',
devServer: {
port: 3000
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-react']
}
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new ModuleFederationPlugin({
filename: 'remoteEntry.js',//向主机提供服务的文件名,构建输出的文件名
name: 'remote', //var remote;//输出的模块名,作为一个远程容器,向外界提供服务,本质上是通过一个全局变量向外提供服务的
exposes: {
'./RemoteComponent': './src/RemoteComponent',//被远程引用时可暴露的资源路径及其别名
}
})
]
}
remote\src\index.js
import('./bootstrap');
remote\src\bootstrap.js
import RemoteComponent from './RemoteComponent'
console.log(RemoteComponent);
remote\src\RemoteComponent.js
export default 'RemoteComponent'
remote\src\index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>remote</title>
</head>
<body>
</body>
</html>
remote\hand\index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>remote</title>
<script defer src="main.js"></script></head>
<body>
</body>
</html>
remote\hand\main.js
(() => {
var modules = {};
function require(moduleId) {
var module = {
exports: {}
};
modules[moduleId](module, module.exports, require);
return module.exports;
}
require.m = modules;
require.d = (exports, definition) => {
for (var key in definition) {
Object.defineProperty(exports, key, {
enumerable: true,
get: definition[key]
});
}
};
require.f = {};
require.e = chunkId => {
return Promise.all(Object.keys(require.f).reduce((promises, key) => {
require.f[key](chunkId, promises);
return promises;
}, []));
};
require.u = chunkId => {
return "" + chunkId + ".js";
};
require.g = window;
require.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
require.l = url => {
let script = document.createElement('script');
script.src = url;
document.head.appendChild(script);
};
require.r = exports => {
Object.defineProperty(exports, '__esModule', {
value: true
});
};
require.p = '';
var installedChunks = {
"main": 0
};
require.f.j = (chunkId, promises) => {
var installedChunkData;
var promise = new Promise((resolve, reject) => installedChunkData = installedChunks[chunkId] = [resolve, reject]);
promises.push(installedChunkData[2] = promise);
var url = require.p + require.u(chunkId);
require.l(url);
};
var webpackJsonpCallback = data => {
var [chunkIds, moreModules] = data;
var moduleId,
chunkId,
i = 0;
for (moduleId in moreModules) {
if (require.o(moreModules, moduleId)) {
require.m[moduleId] = moreModules[moduleId];
}
}
for (; i < chunkIds.length; i++) {
chunkId = chunkIds[i];
if (require.o(installedChunks, chunkId) && installedChunks[chunkId]) {
installedChunks[chunkId][0]();
}
installedChunks[chunkId] = 0;
}
};
var chunkLoadingGlobal = self["webpackChunkremote"] = self["webpackChunkremote"] || [];
chunkLoadingGlobal.push = webpackJsonpCallback;
require.e("src_bootstrap_js").then(() => {
require("./src/bootstrap.js")
});
})();
remote\hand\src_bootstrap_js.js
"use strict";
(self["webpackChunkremote"] = self["webpackChunkremote"] || []).push([["src_bootstrap_js"], {
"./src/RemoteComponent.js": (module, exports, require) => {
require.r(exports);
require.d(exports, {
"default": () => _DEFAULT_EXPORT__
});
const _DEFAULT_EXPORT__ = 'RemoteComponent';
},
"./src/bootstrap.js": (module, exports, require) => {
require.r(exports);
var RemoteComponent = require("./src/RemoteComponent.js");
console.log(RemoteComponent.default);
}
}]);
remote\hand\remoteEntry.js
var remote;
(() => {
var modules = {};
function require(moduleId) {
var module = {
exports: {}
};
modules[moduleId](module, module.exports, require);
return module.exports;
}
require.m = modules;
require.d = (exports, definition) => {
for (var key in definition) {
Object.defineProperty(exports, key, {
enumerable: true,
get: definition[key]
});
}
};
require.f = {};
require.e = chunkId => {
return Promise.all(Object.keys(require.f).reduce((promises, key) => {
require.f[key](chunkId, promises);
return promises;
}, []));
};
require.u = chunkId => {
return "" + chunkId + ".js";
};
require.g = window;
require.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
require.l = url => {
let script = document.createElement('script');
script.src = url;
document.head.appendChild(script);
};
require.r = exports => {
Object.defineProperty(exports, '__esModule', {
value: true
});
};
scriptUrl = document.currentScript.src;
require.p = scriptUrl.replace(/\/[^\/]+$/, "/");
var installedChunks = {
"remote": 0
};
require.f.j = (chunkId, promises) => {
var installedChunkData;
var promise = new Promise((resolve, reject) => installedChunkData = installedChunks[chunkId] = [resolve, reject]);
promises.push(installedChunkData[2] = promise);
var url = require.p + require.u(chunkId);
require.l(url);
};
var webpackJsonpCallback = data => {
var [chunkIds, moreModules] = data;
var moduleId, chunkId, i = 0;
for (moduleId in moreModules) {
if (require.o(moreModules, moduleId)) {
require.m[moduleId] = moreModules[moduleId];
}
}
for (; i < chunkIds.length; i++) {
chunkId = chunkIds[i];
if (require.o(installedChunks, chunkId) && installedChunks[chunkId]) {
installedChunks[chunkId][0]();
}
installedChunks[chunkId] = 0;
}
};
var chunkLoadingGlobal = self["webpackChunkremote"] = self["webpackChunkremote"] || [];
chunkLoadingGlobal.push = webpackJsonpCallback;
var exports = {};
var moduleMap = {
"./RemoteComponent": () => {
return require.e("src_RemoteComponent_js").then(() => () => require("./src/RemoteComponent.js"));
}
};
var get = (module) => {
return moduleMap[module]();
};
require.d(exports, {
get: () => get
});
remote = exports;
})();
remote\hand\src_RemoteComponent_js.js
(self["webpackChunkremote"] = self["webpackChunkremote"] || []).push([["src_RemoteComponent_js"], {
"./src/RemoteComponent.js": (module, exports, require) => {
require.r(exports);
require.d(exports, {
"default": () => _DEFAULT_EXPORT__
});
const _DEFAULT_EXPORT__ = 'RemoteComponent';
}
}]);
remote\webpack.config.js
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
module.exports = {
mode: 'development',
devtool: false,
entry: './src/index.js',
output: {
//publicPath: 'http://localhost:3000'
//publicPath: '/'
//publicPath: ''
},
devServer: {
port: 8000
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new ModuleFederationPlugin({
//远程引用的应用名及其别名的映射,使用时以key值作为name
remotes: {
remote: 'remote@http://127.0.0.1:3000/remoteEntry.js'//被远程引用时可暴露的资源路径及其别名
}
})
]
}
remote\src\index.js
import('./bootstrap');
remote\src\bootstrap.js
import RemoteComponent from './RemoteComponent'
console.log(RemoteComponent);
remote\src\RemoteComponent.js
export default 'RemoteComponent'
host\hand\index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>remote</title>
<script defer src="main.js"></script></head>
<body>
</body>
</html>
host\hand\main.js
(() => {
var modules = {
"webpack/container/reference/remote": (module, exports, require) => {
module.exports = new Promise(resolve => {
if (typeof remote !== "undefined") return resolve();
require.l("http://127.0.0.1:3000/remoteEntry.js", resolve);
}).then(() => remote);
}
};
function require(moduleId) {
var module = {
exports: {}
};
modules[moduleId](module, module.exports, require);
return module.exports;
}
require.m = modules;
require.d = (exports, definition) => {
for (var key in definition) {
Object.defineProperty(exports, key, {
enumerable: true,
get: definition[key]
});
}
};
require.f = {};
require.e = chunkId => {
return Promise.all(Object.keys(require.f).reduce((promises, key) => {
require.f[key](chunkId, promises);
return promises;
}, []));
};
require.u = chunkId => {
return "" + chunkId + ".js";
};
require.g = window;
require.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
require.l = (url, done) => {
let script = document.createElement('script');
script.src = url;
script.onload = done;
document.head.appendChild(script);
};
require.r = exports => {
Object.defineProperty(exports, '__esModule', {
value: true
});
};
var chunkMapping = {
"webpack_container_remote_remote_RemoteComponent": ["webpack/container/remote/remote/RemoteComponent"]
};
var idToExternalAndNameMapping = {
"webpack/container/remote/remote/RemoteComponent": ["default", "./RemoteComponent", "webpack/container/reference/remote"]
};
require.f.remotes = (chunkId, promises) => {
if (require.o(chunkMapping, chunkId)) {
chunkMapping[chunkId].forEach(id => {
var data = idToExternalAndNameMapping[id];
var promise = require(data[2]).then(external => {
return external.get(data[1]);
}).then(factory => {
require.m[id] = module => {
module.exports = factory();
};
});
promises.push(promise);
});
}
};
scriptUrl = document.currentScript.src;
require.p = scriptUrl.replace(/\/[^\/]+$/, "/");
var installedChunks = {
"main": 0
};
require.f.j = (chunkId, promises) => {
var installedChunkData;
if ("webpack_container_remote_remote_RemoteComponent" !== chunkId) {
var promise = new Promise((resolve, reject) => installedChunkData = installedChunks[chunkId] = [resolve, reject]);
promises.push(installedChunkData[2] = promise);
var url = require.p + require.u(chunkId);
require.l(url);
}
};
var webpackJsonpCallback = data => {
var [chunkIds, moreModules] = data;
var moduleId,
chunkId,
i = 0;
if (chunkIds.some(id => installedChunks[id] !== 0)) {
for (moduleId in moreModules) {
if (require.o(moreModules, moduleId)) {
require.m[moduleId] = moreModules[moduleId];
}
}
}
for (; i < chunkIds.length; i++) {
chunkId = chunkIds[i];
if (require.o(installedChunks, chunkId) && installedChunks[chunkId]) {
installedChunks[chunkId][0]();
}
installedChunks[chunkId] = 0;
}
};
var chunkLoadingGlobal = self["webpackChunkhost"] = self["webpackChunkhost"] || [];
chunkLoadingGlobal.push = webpackJsonpCallback;
require.e("src_bootstrap_js").then(() => require("./src/bootstrap.js"));
})();
host\hand\src_bootstrap_js.js
(self["webpackChunkhost"] = self["webpackChunkhost"] || []).push([["src_bootstrap_js"], {
"./src/bootstrap.js": (module, exports, require) => {
require.e("webpack_container_remote_remote_RemoteComponent").then(() => require("webpack/container/remote/remote/RemoteComponent")).then(result => {
console.log(result.default);
});
}
}]);
remote\src\index.js
import('./bootstrap');
remote\src\bootstrap.js
import RemoteComponent from './RemoteComponent'
import isArray from 'check-is-array';
console.log(RemoteComponent, isArray);
remote\src\RemoteComponent.js
export default 'RemoteComponent'
remote\hand\main.js
(() => {
var modules = {
"./src/index.js": (module, exports, require) => {
require.e("src_bootstrap_js").then(require.bind(require, "./src/bootstrap.js"));
}
};
function require(moduleId) {
var module = {
exports: {}
};
modules[moduleId](module, module.exports, require);
return module.exports;
}
require.m = modules;
require.n = module => {
var getter = module && module.__esModule ? () => module['default'] : () => module;
require.d(getter, {
a: getter
});
return getter;
};
require.d = (exports, definition) => {
for (var key in definition) {
Object.defineProperty(exports, key, {
enumerable: true,
get: definition[key]
});
}
};
require.f = {};
require.e = chunkId => {
return Promise.all(Object.keys(require.f).reduce((promises, key) => {
require.f[key](chunkId, promises);
return promises;
}, []));
};
require.u = chunkId => {
return "" + chunkId + ".js";
};
require.g = window;
require.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
require.l = (url, done) => {
var script = document.createElement('script');
script.src = url;
script.onload = done;
document.head.appendChild(script);
};
require.r = exports => {
Object.defineProperty(exports, '__esModule', { value: true });
};
require.S = {};
require.I = (name) => {
if (!require.o(require.S, name)) require.S[name] = {};
var scope = require.S[name];
var uniqueName = "remote";
var register = (name, version, factory) => {
var versions = scope[name] = scope[name] || {};
var activeVersion = versions[version];
if (!activeVersion)
versions[version] = {
get: factory,
from: uniqueName
};
};
var promises = [];
switch (name) {
case "default":
{
register("check-is-array", "2.0.6", () => require.e("node_modules_check-is-array_index_js").then(() => () => require("./node_modules/check-is-array/index.js")));
}
break;
}
return Promise.all(promises);
};
require.p = document.currentScript.src.replace(/\/[^\/]+$/, "/");
var parseVersion = str => {
var p = p => {
return p.split(".").map(p => {
return +p == p ? +p : p;
});
},
n = /^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(str),
r = n[1] ? p(n[1]) : [];
return n[2] && (r.length++, r.push.apply(r, p(n[2]))), n[3] && (r.push([]), r.push.apply(r, p(n[3]))), r;
};
var versionLt = (a, b) => {
a = parseVersion(a), b = parseVersion(b);
for (var r = 0; ;) {
if (r >= a.length) return r < b.length && "u" != (typeof b[r])[0];
var e = a[r],
n = (typeof e)[0];
if (r >= b.length) return "u" == n;
var t = b[r],
f = (typeof t)[0];
if (n != f) return "o" == n && "n" == f || "s" == f || "u" == n;
if ("o" != n && "u" != n && e != t) return e < t;
r++;
}
};
var rangeToString = range => {
var r = range[0],
n = "";
if (1 === range.length) return "*";
if (r + .5) {
n += 0 == r ? ">=" : -1 == r ? "<" : 1 == r ? "^" : 2 == r ? "~" : r > 0 ? "=" : "!=";
for (var e = 1, a = 1; a < range.length; a++) {
e--, n += "u" == (typeof (t = range[a]))[0] ? "-" : (e > 0 ? "." : "") + (e = 2, t);
}
return n;
}
var g = [];
for (a = 1; a < range.length; a++) {
var t = range[a];
g.push(0 === t ? "not(" + o() + ")" : 1 === t ? "(" + o() + " || " + o() + ")" : 2 === t ? g.pop() + " " + g.pop() : rangeToString(t));
}
return o();
function o() {
return g.pop().replace(/^\((.+)\)$/, "$1");
}
};
var satisfy = (range, version) => {
if (0 in range) {
version = parseVersion(version);
var e = range[0],
r = e < 0;
r && (e = -e - 1);
for (var n = 0, i = 1, a = !0; ; i++, n++) {
var f,
s,
g = i < range.length ? (typeof range[i])[0] : "";
if (n >= version.length || "o" == (s = (typeof (f = version[n]))[0])) return !a || ("u" == g ? i > e && !r : "" == g != r);
if ("u" == s) {
if (!a || "u" != g) return !1;
} else if (a) {
if (g == s) {
if (i <= e) {
if (f != range[i]) return !1;
} else {
if (r ? f > range[i] : f < range[i]) return !1;
f != range[i] && (a = !1);
}
} else if ("s" != g && "n" != g) {
if (r || i <= e) return !1;
a = !1, i--;
} else {
if (i <= e || s < g != r) return !1;
a = !1;
}
} else "s" != g && "n" != g && (a = !1, i--);
}
}
var t = [],
o = t.pop.bind(t);
for (n = 1; n < range.length; n++) {
var u = range[n];
t.push(1 == u ? o() | o() : 2 == u ? o() & o() : u ? satisfy(u, version) : !o());
}
return !!o();
};
var findSingletonVersionKey = (scope, key) => {
var versions = scope[key];
return Object.keys(versions).reduce((a, b) => {
return !a || !versions[a].loaded && versionLt(a, b) ? b : a;
}, 0);
};
var getInvalidSingletonVersionMessage = (scope, key, version, requiredVersion) => {
return "Unsatisfied version " + version + " from " + (version && scope[key][version].from) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")";
};
var getSingletonVersion = (scope, scopeName, key, requiredVersion) => {
var version = findSingletonVersionKey(scope, key);
if (!satisfy(requiredVersion, version))
console.warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));
return get(scope[key][version]);
};
var get = entry => {
entry.loaded = 1;
return entry.get();
};
var init = fn => function (scopeName, key, version, fallback) {
var promise = require.I(scopeName);
return promise.then(() => fn(scopeName, require.S[scopeName], key, version, fallback));
};
var loadSingletonVersionCheckFallback = init((scopeName, scope, key, version, fallback) => {
if (!scope || !require.o(scope, key)) return fallback();
return getSingletonVersion(scope, scopeName, key, version);
});
var installedModules = {};
var moduleToHandlerMapping = {
"webpack/sharing/consume/default/check-is-array/check-is-array": () => loadSingletonVersionCheckFallback("default", "check-is-array", [1, 2, 0, 6], () => require.e("node_modules_check-is-array_index_js").then(() => () => require("./node_modules/check-is-array/index.js")))
};
var chunkMapping = {
"src_bootstrap_js": ["webpack/sharing/consume/default/check-is-array/check-is-array"]
};
require.f.consumes = (chunkId, promises) => {
if (require.o(chunkMapping, chunkId)) {
chunkMapping[chunkId].forEach(id => {
if (require.o(installedModules, id)) return promises.push(installedModules[id]);
var onFactory = factory => {
installedModules[id] = 0;
require.m[id] = module => {
module.exports = factory();
};
};
var promise = moduleToHandlerMapping[id]();
if (promise.then) {
promises.push(installedModules[id] = promise.then(onFactory));
} else onFactory(promise);
});
}
};
var installedChunks = {
"main": 0
};
require.f.j = (chunkId, promises) => {
var installedChunkData;
var promise = new Promise((resolve, reject) => installedChunkData = installedChunks[chunkId] = [resolve, reject]);
promises.push(installedChunkData[2] = promise);
var url = require.p + require.u(chunkId);
require.l(url);
};
var webpackJsonpCallback = (data) => {
var [chunkIds, moreModules] = data;
var moduleId, chunkId, i = 0;
for (moduleId in moreModules) {
if (require.o(moreModules, moduleId)) {
require.m[moduleId] = moreModules[moduleId];
}
}
for (; i < chunkIds.length; i++) {
chunkId = chunkIds[i];
if (require.o(installedChunks, chunkId) && installedChunks[chunkId]) {
installedChunks[chunkId][0]();
}
installedChunks[chunkId] = 0;
}
};
var chunkLoadingGlobal = self["webpackChunkremote"] = self["webpackChunkremote"] || [];
chunkLoadingGlobal.push = webpackJsonpCallback;
require("./src/index.js");
})();
remote\hand\node_modules_check-is-array_index_js.js
"use strict";
(self["webpackChunkremote"] = self["webpackChunkremote"] || []).push([["node_modules_check-is-array_index_js"], {
"./node_modules/check-is-array/index.js": (module, exports, require) => {
require.r(exports);
require.d(exports, {
"default": () => _DEFAULT_EXPORT__
});
const _DEFAULT_EXPORT__ = Array.isArray;
}
}]);
remote\hand\remoteEntry.js
var remote;
(() => {
var modules = {
"webpack/container/entry/remote": (module, exports, require) => {
var moduleMap = {
"./RemoteComponent": () => {
return require.e("src_RemoteComponent_js").then(() => () => require("./src/RemoteComponent.js"));
}
};
var get = module => {
return moduleMap[module]();
};
var init = shareScope => {
if (!require.S) return;
var name = "default";
require.S[name] = shareScope;
return require.I(name);
};
require.d(exports, {
get: () => get,
init: () => init
});
}
};
function require(moduleId) {
var module = {
exports: {}
};
modules[moduleId](module, module.exports, require);
return module.exports;
}
require.m = modules;
require.d = (exports, definition) => {
for (var key in definition) {
Object.defineProperty(exports, key, {
enumerable: true,
get: definition[key]
});
}
};
require.f = {};
require.e = chunkId => {
return Promise.all(Object.keys(require.f).reduce((promises, key) => {
require.f[key](chunkId, promises);
return promises;
}, []));
};
require.u = chunkId => {
return "" + chunkId + ".js";
};
require.g = window;
require.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
require.l = (url, done) => {
var script = document.createElement('script');
script.src = url;
script.onload = done;
document.head.appendChild(script);
};
require.r = exports => {
Object.defineProperty(exports, '__esModule', { value: true });
};
require.S = {};
require.I = (name) => {
if (!require.o(require.S, name)) require.S[name] = {};
var scope = require.S[name];
var uniqueName = "remote";
var register = (name, version, factory) => {
var versions = scope[name] = scope[name] || {};
var activeVersion = versions[version];
if (!activeVersion)
versions[version] = {
get: factory,
from: uniqueName
};
};
switch (name) {
case "default":
{
register("check-is-array", "2.0.6", () => require.e("node_modules_check-is-array_index_js").then(() => () => require("./node_modules/check-is-array/index.js")));
}
break;
}
};
require.p = document.currentScript.src.replace(/\/[^\/]+$/, "/");
var installedChunks = {
"remote": 0
};
require.f.j = (chunkId, promises) => {
var installedChunkData;
var promise = new Promise((resolve, reject) => installedChunkData = installedChunks[chunkId] = [resolve, reject]);
promises.push(installedChunkData[2] = promise);
var url = require.p + require.u(chunkId);
require.l(url);
};
var webpackJsonpCallback = (data) => {
var [chunkIds, moreModules] = data;
var moduleId, chunkId, i = 0;
for (moduleId in moreModules) {
if (require.o(moreModules, moduleId)) {
require.m[moduleId] = moreModules[moduleId];
}
}
for (; i < chunkIds.length; i++) {
chunkId = chunkIds[i];
if (require.o(installedChunks, chunkId) && installedChunks[chunkId]) {
installedChunks[chunkId][0]();
}
installedChunks[chunkId] = 0;
}
};
var chunkLoadingGlobal = self["webpackChunkremote"] = self["webpackChunkremote"] || [];
chunkLoadingGlobal.push = webpackJsonpCallback;
var exports = require("webpack/container/entry/remote");
remote = exports;
})();
remote\hand\src_bootstrap_js.js
"use strict";
(self["webpackChunkremote"] = self["webpackChunkremote"] || []).push([["src_bootstrap_js"], {
"./src/RemoteComponent.js": (module, exports, require) => {
require.r(exports);
require.d(exports, {
"default": () => _DEFAULT_EXPORT__
});
const _DEFAULT_EXPORT__ = 'RemoteComponent';
},
"./src/bootstrap.js": (module, exports, require) => {
require.r(exports);
var _RemoteComponent_0__ = require("./src/RemoteComponent.js");
var check_is_array_1__ = require("webpack/sharing/consume/default/check-is-array/check-is-array");
var check_is_array_1___default = require.n(check_is_array_1__);
console.log(_RemoteComponent_0__["default"], check_is_array_1___default());
}
}]);
remote\hand\src_RemoteComponent_js.js
"use strict";
(self["webpackChunkremote"] = self["webpackChunkremote"] || []).push([["src_RemoteComponent_js"], {
"./src/RemoteComponent.js": (module, exports, require) => {
require.r(exports);
require.d(exports, {
"default": () => _DEFAULT_EXPORT__
});
const _DEFAULT_EXPORT__ = 'RemoteComponent';
}
}]);
host\src\index.js
import('./bootstrap');
host\src\bootstrap.js
import isArray from 'check-is-array';
import("remote/RemoteComponent").then(result => {
console.log(result.default, isArray);
});
host\hand\main.js
(() => {
var modules = {
"./src/index.js": (module, exports, require) => {
require.e("src_bootstrap_js").then(() => require("./src/bootstrap.js"));
},
"webpack/container/reference/remote": (module, exports, require) => {
module.exports = new Promise(resolve => {
if (typeof remote !== "undefined") return resolve();
require.l("http://127.0.0.1:3001/remoteEntry.js", resolve);
}).then(() => remote);
}
};
function require(moduleId) {
var module = {
exports: {}
};
modules[moduleId](module, module.exports, require);
return module.exports;
}
require.m = modules;
require.n = module => {
var getter = module && module.__esModule ? () => module['default'] : () => module;
require.d(getter, {
a: getter
});
return getter;
};
require.d = (exports, definition) => {
for (var key in definition) {
Object.defineProperty(exports, key, {
enumerable: true,
get: definition[key]
});
}
};
require.f = {};
require.e = chunkId => {
return Promise.all(Object.keys(require.f).reduce((promises, key) => {
require.f[key](chunkId, promises);
return promises;
}, []));
};
require.u = chunkId => {
return "" + chunkId + ".js";
};
require.g = window;
require.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
require.l = (url, done) => {
let script = document.createElement('script');
script.src = url;
script.onload = done;
document.head.appendChild(script);
};
require.r = exports => {
Object.defineProperty(exports, '__esModule', {
value: true
});
};
(() => {
var chunkMapping = {
"webpack_container_remote_remote_RemoteComponent": ["webpack/container/remote/remote/RemoteComponent"]
};
var idToExternalAndNameMapping = {
"webpack/container/remote/remote/RemoteComponent": ["default", "./RemoteComponent", "webpack/container/reference/remote"]
};
require.f.remotes = (chunkId, promises) => {
if (require.o(chunkMapping, chunkId)) {
chunkMapping[chunkId].forEach(id => {
var [, moduleId, remoteModuleId] = idToExternalAndNameMapping[id];
var promise = require(remoteModuleId).then(remoteModule => {
return remoteModule.get(moduleId);
}).then(factory => {
require.m[id] = module => {
module.exports = factory();
};
});
promises.push(promise);
});
}
};
})()
require.S = {};
require.I = (name) => {
if (!require.o(require.S, name)) require.S[name] = {};
var scope = require.S[name];
var uniqueName = "host";
var register = (name, version, factory) => {
var versions = scope[name] = scope[name] || {};
var activeVersion = versions[version];
if (!activeVersion) versions[version] = {
get: factory,
from: uniqueName
};
};
var promises = [];
var initExternal = id => {
var module = require(id);
promises.push(module.then(module => module.init(require.S[name])));
};
switch (name) {
case "default":
{
register("check-is-array", "2.0.6", () => require.e("node_modules_check-is-array_index_js").then(() => () => require("./node_modules/check-is-array/index.js")));
initExternal("webpack/container/reference/remote");
}
break;
}
return Promise.all(promises);
};
require.p = document.currentScript.src.replace(/\/[^\/]+$/, "/");
var parseVersion = str => {
var p = p => {
return p.split(".").map(p => {
return +p == p ? +p : p;
});
},
n = /^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(str),
r = n[1] ? p(n[1]) : [];
return n[2] && (r.length++, r.push.apply(r, p(n[2]))), n[3] && (r.push([]), r.push.apply(r, p(n[3]))), r;
};
var versionLt = (a, b) => {
a = parseVersion(a), b = parseVersion(b);
for (var r = 0; ;) {
if (r >= a.length) return r < b.length && "u" != (typeof b[r])[0];
var e = a[r],
n = (typeof e)[0];
if (r >= b.length) return "u" == n;
var t = b[r],
f = (typeof t)[0];
if (n != f) return "o" == n && "n" == f || "s" == f || "u" == n;
if ("o" != n && "u" != n && e != t) return e < t;
r++;
}
};
var rangeToString = range => {
var r = range[0],
n = "";
if (1 === range.length) return "*";
if (r + .5) {
n += 0 == r ? ">=" : -1 == r ? "<" : 1 == r ? "^" : 2 == r ? "~" : r > 0 ? "=" : "!=";
for (var e = 1, a = 1; a < range.length; a++) {
e--, n += "u" == (typeof (t = range[a]))[0] ? "-" : (e > 0 ? "." : "") + (e = 2, t);
}
return n;
}
var g = [];
for (a = 1; a < range.length; a++) {
var t = range[a];
g.push(0 === t ? "not(" + o() + ")" : 1 === t ? "(" + o() + " || " + o() + ")" : 2 === t ? g.pop() + " " + g.pop() : rangeToString(t));
}
return o();
function o() {
return g.pop().replace(/^\((.+)\)$/, "$1");
}
};
var satisfy = (range, version) => {
if (0 in range) {
version = parseVersion(version);
var e = range[0],
r = e < 0;
r && (e = -e - 1);
for (var n = 0, i = 1, a = !0; ; i++, n++) {
var f,
s,
g = i < range.length ? (typeof range[i])[0] : "";
if (n >= version.length || "o" == (s = (typeof (f = version[n]))[0])) return !a || ("u" == g ? i > e && !r : "" == g != r);
if ("u" == s) {
if (!a || "u" != g) return !1;
} else if (a) {
if (g == s) {
if (i <= e) {
if (f != range[i]) return !1;
} else {
if (r ? f > range[i] : f < range[i]) return !1;
f != range[i] && (a = !1);
}
} else if ("s" != g && "n" != g) {
if (r || i <= e) return !1;
a = !1, i--;
} else {
if (i <= e || s < g != r) return !1;
a = !1;
}
} else "s" != g && "n" != g && (a = !1, i--);
}
}
var t = [],
o = t.pop.bind(t);
for (n = 1; n < range.length; n++) {
var u = range[n];
t.push(1 == u ? o() | o() : 2 == u ? o() & o() : u ? satisfy(u, version) : !o());
}
return !!o();
};
var findSingletonVersionKey = (scope, key) => {
var versions = scope[key];
return Object.keys(versions).reduce((a, b) => {
return !a || !versions[a].loaded && versionLt(a, b) ? b : a;
}, 0);
};
var getInvalidSingletonVersionMessage = (scope, key, version, requiredVersion) => {
return "Unsatisfied version " + version + " from " + (version && scope[key][version].from) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")";
};
var getSingletonVersion = (scope, scopeName, key, requiredVersion) => {
var version = findSingletonVersionKey(scope, key);
if (!satisfy(requiredVersion, version))
console.warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));
return get(scope[key][version]);
};
var get = entry => {
entry.loaded = 1;
return entry.get();
};
var init = fn => function (scopeName, key, version, fallback) {
var promise = require.I(scopeName);
return promise.then(() => fn(scopeName, require.S[scopeName], key, version, fallback));
};
var loadSingletonVersionCheckFallback = init((scopeName, scope, key, version, fallback) => {
if (!scope || !require.o(scope, key)) return fallback();
return getSingletonVersion(scope, scopeName, key, version);
});
var moduleToHandlerMapping = {
"webpack/sharing/consume/default/check-is-array/check-is-array": () => loadSingletonVersionCheckFallback('default', "check-is-array", [1, 2, 0, 6], () => require.e("node_modules_check-is-array_index_js").then(() => () => require("./node_modules/check-is-array/index.js")))
};
var chunkMapping = {
"src_bootstrap_js": ["webpack/sharing/consume/default/check-is-array/check-is-array"]
};
require.f.consumes = (chunkId, promises) => {
if (require.o(chunkMapping, chunkId)) {
chunkMapping[chunkId].forEach(id => {
var onFactory = factory => {
require.m[id] = module => {
module.exports = factory();
};
};
var promise = moduleToHandlerMapping[id]();
promises.push(promise.then(onFactory));
});
}
};
var installedChunks = {
"main": 0
};
require.f.j = (chunkId, promises) => {
var installedChunkData;
if ("webpack_container_remote_remote_RemoteComponent" !== chunkId) {
var promise = new Promise((resolve, reject) => installedChunkData = installedChunks[chunkId] = [resolve, reject]);
promises.push(installedChunkData[2] = promise);
var url = require.p + require.u(chunkId);
require.l(url);
}
};
var webpackJsonpCallback = data => {
var [chunkIds, moreModules] = data;
var moduleId,
chunkId,
i = 0;
if (chunkIds.some(id => installedChunks[id] !== 0)) {
for (moduleId in moreModules) {
if (require.o(moreModules, moduleId)) {
require.m[moduleId] = moreModules[moduleId];
}
}
}
for (; i < chunkIds.length; i++) {
chunkId = chunkIds[i];
if (require.o(installedChunks, chunkId) && installedChunks[chunkId]) {
installedChunks[chunkId][0]();
}
installedChunks[chunkId] = 0;
}
};
var chunkLoadingGlobal = self["webpackChunkhost"] = self["webpackChunkhost"] || [];
chunkLoadingGlobal.push = webpackJsonpCallback;
require("./src/index.js");
})();
host\hand\node_modules_check-is-array_index_js.js
(self["webpackChunkhost"] = self["webpackChunkhost"] || []).push([["node_modules_check-is-array_index_js"], {
"./node_modules/check-is-array/index.js": (module, exports, require) => {
require.r(exports);
require.d(exports, {
"default": () => _DEFAULT_EXPORT__
});
const _DEFAULT_EXPORT__ = Array.isArray;
}
}]);
host\hand\src_bootstrap_js.js
(self["webpackChunkhost"] = self["webpackChunkhost"] || []).push([["src_bootstrap_js"], {
"./src/bootstrap.js": (module, exports, require) => {
require.r(exports);
var check_is_array_0__ = require("webpack/sharing/consume/default/check-is-array/check-is-array");
var check_is_array_0___default = require.n(check_is_array_0__);
require.e("webpack_container_remote_remote_RemoteComponent").then(() => require("webpack/container/remote/remote/RemoteComponent")).then(result => {
console.log(result.default, check_is_array_0___default());
});
}
}]);