add full Semantic Versioning for Shared Modules

change storage format in the share scope
choose shared module deterministic from the same origin
remove array syntax from version and requiredVersion in schema
This commit is contained in:
Tobias Koppers 2020-06-30 15:08:13 +02:00
parent 07558fd30d
commit 3fcd5f9bc5
33 changed files with 1713 additions and 838 deletions

View File

@ -173,6 +173,7 @@
"darkblue",
"darkgreen",
"darkred",
"eqeqeq",
"webassemblyjs",
"fsevents",

View File

@ -12,10 +12,6 @@ export type Shared = (SharedItem | SharedObject)[] | SharedObject;
* A module that should be shared in the share scope.
*/
export type SharedItem = string;
/**
* Version number as array. Numbers and strings are accepted. Strings are treated as tags, which only match exactly. Numbers can match higher numbers.
*/
export type SharedVersionArray = (number | string)[];
export interface _Sharing {
[k: string]: any;
@ -48,7 +44,7 @@ export interface SharedConfig {
/**
* Version requirement from module in share scope.
*/
requiredVersion?: false | string | SharedVersionArray;
requiredVersion?: false | string;
/**
* Module is looked up under this key from the share scope.
*/
@ -68,5 +64,5 @@ export interface SharedConfig {
/**
* Version of the provided module. Will replace lower matching versions, but not higher.
*/
version?: false | string | SharedVersionArray;
version?: false | string;
}

View File

@ -95,10 +95,6 @@ export type Shared = (SharedItem | SharedObject)[] | SharedObject;
* A module that should be shared in the share scope.
*/
export type SharedItem = string;
/**
* Version number as array. Numbers and strings are accepted. Strings are treated as tags, which only match exactly. Numbers can match higher numbers.
*/
export type SharedVersionArray = (number | string)[];
export interface ModuleFederationPluginOptions {
/**
@ -265,7 +261,7 @@ export interface SharedConfig {
/**
* Version requirement from module in share scope.
*/
requiredVersion?: false | string | SharedVersionArray;
requiredVersion?: false | string;
/**
* Module is looked up under this key from the share scope.
*/
@ -285,5 +281,5 @@ export interface SharedConfig {
/**
* Version of the provided module. Will replace lower matching versions, but not higher.
*/
version?: false | string | SharedVersionArray;
version?: false | string;
}

View File

@ -12,10 +12,6 @@ export type Consumes = (ConsumesItem | ConsumesObject)[] | ConsumesObject;
* A module that should be consumed from share scope.
*/
export type ConsumesItem = string;
/**
* Version number as array. Numbers and strings are accepted. Strings are treated as tags, which only match exactly. Numbers can match higher numbers.
*/
export type SharedVersionArray = (number | string)[];
/**
* Options for consuming shared modules.
@ -58,7 +54,7 @@ export interface ConsumesConfig {
/**
* Version requirement from module in share scope.
*/
requiredVersion?: false | string | SharedVersionArray;
requiredVersion?: false | string;
/**
* Module is looked up under this key from the share scope.
*/

View File

@ -12,10 +12,6 @@ export type Provides = (ProvidesItem | ProvidesObject)[] | ProvidesObject;
* Request to a module that should be provided as shared module to the share scope (will be resolved when relative).
*/
export type ProvidesItem = string;
/**
* Version number as array. Numbers and strings are accepted. Strings are treated as tags, which only match exactly. Numbers can match higher numbers.
*/
export type SharedVersionArray = (number | string)[];
export interface ProvideSharedPluginOptions {
/**
@ -55,5 +51,5 @@ export interface ProvidesConfig {
/**
* Version of the provided module. Will replace lower matching versions, but not higher.
*/
version?: false | string | SharedVersionArray;
version?: false | string;
}

View File

@ -12,10 +12,6 @@ export type Shared = (SharedItem | SharedObject)[] | SharedObject;
* A module that should be shared in the share scope.
*/
export type SharedItem = string;
/**
* Version number as array. Numbers and strings are accepted. Strings are treated as tags, which only match exactly. Numbers can match higher numbers.
*/
export type SharedVersionArray = (number | string)[];
/**
* Options for shared modules.
@ -58,7 +54,7 @@ export interface SharedConfig {
/**
* Version requirement from module in share scope.
*/
requiredVersion?: false | string | SharedVersionArray;
requiredVersion?: false | string;
/**
* Module is looked up under this key from the share scope.
*/
@ -78,5 +74,5 @@ export interface SharedConfig {
/**
* Version of the provided module. Will replace lower matching versions, but not higher.
*/
version?: false | string | SharedVersionArray;
version?: false | string;
}

View File

@ -647,30 +647,16 @@ module.exports = new Promise((resolve, reject) => {
/******/ // runs all init snippets from all modules reachable
/******/ var scope = __webpack_require__.S[name];
/******/ var warn = (msg) => typeof console !== "undefined" && console.warn && console.warn(msg);;
/******/ var register = (name, version, factory, currentName) => {
/******/ var uniqueName = "module-federation-aaa";
/******/ var versionLt = (a, b) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var t=a[r],e=(typeof t)[0];if(r>=b.length)return"u"==e;var n=b[r],f=(typeof n)[0];if(e!=f)return"o"==e&&"n"==f||("s"==f||"u"==e);if("o"!=e&&"u"!=e&&t!=n)return t<n;r++}
/******/ }
/******/ var register = (name, version, factory) => {
/******/ version = version || [];
/******/ currentName = name;
/******/ var versionConflict = () => warn("Version conflict for shared modules: " + name + " " + (v && v.join(".")) + " <=> " + (version && version.join(".")));;
/******/ var registerCurrent = () => {
/******/ if(scope[currentName]) {
/******/ var v = scope[currentName].version || [];
/******/ for(var i = 0; i < version.length && i < v.length; i++) {
/******/ if(v[i] != version[i]) { // loose equal is intentional to match string and number
/******/ if(typeof v[i] === "string" || typeof version[i] === "string") return versionConflict();
/******/ if(v[i] > version[i]) return;
/******/ if(v[i] < version[i]) { i = -1; break; }
/******/ }
/******/ }
/******/ if(i >= 0 && version.length <= v.length) return;
/******/ if(scope[currentName].loaded) return warn("Ignoring providing of already used shared module: " + name);
/******/ }
/******/ scope[currentName] = { get: factory, version: version };
/******/ };
/******/ registerCurrent();
/******/ version.forEach((part) => {
/******/ currentName += "`" + part;
/******/ registerCurrent();
/******/ });
/******/ var versions = scope[name] = scope[name] || {};
/******/ var activeVersion = versions[version];
/******/ if(!activeVersion || uniqueName > activeVersion.from) versions[version] = { get: factory, version: version, from: uniqueName };
/******/ };
/******/ var initExternal = (id) => {
/******/ var handleError = (err) => warn("Initialization of sharing external failed: " + err);
@ -698,105 +684,129 @@ module.exports = new Promise((resolve, reject) => {
/******/
/******/ /* webpack/runtime/consumes */
/******/ (() => {
/******/ var ensureExistence = (scope, scopeName, key) => {
/******/ var satisfy = (range, version) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ var r=0,e=1,n=!0;if(0 in range){var f=range[0],i=f<0;for(i&&(f=-f-1);;){var a=e<range.length?(typeof range[e])[0]:"";if(r>=version.length)return!n||("u"==a?e>f&&!i:""==a!=i);var o=version[r],t=(typeof o)[0];if(r++,"u"==t){if(!n||"u"!=a)return!1;e++}else if(n)if("s"!=a&&"n"!=a)if("o"==t){if("o"!=a)return!(e<=f)&&!i;e++}else{if(i||e<=f)return!1;n=!1}else{if("o"==t)return!(e<=f)&&i;if(a!=t)return!1;if("s"==a||e<=f){if(o!=range[e])return!1;e++}else{if(i?o>range[e]:o<range[e])return!1;o!=range[e]&&(n=!1),e++}}else{if("o"==t)return!0;"s"==a||"n"==a?e++:n=!1}}}var u=[];for(r=1;r<range.length;r++){var s=range[r];u.push(1==s?u.pop()|u.pop():2==s?u.pop()&u.pop():s?satisfy(s,version):!u.pop())}return!!u[0]
/******/ }
/******/ var versionLt = (a, b) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var t=a[r],e=(typeof t)[0];if(r>=b.length)return"u"==e;var n=b[r],f=(typeof n)[0];if(e!=f)return"o"==e&&"n"==f||("s"==f||"u"==e);if("o"!=e&&"u"!=e&&t!=n)return t<n;r++}
/******/ }
/******/ var versionToString = (version) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ if(!version)return"[unknown]";for(var r="",n=1,o=0;o<version.length;o++){var e=version[o],t=(typeof e)[0];n--,r+="u"==t?"-":"o"==t?"+":(n>0?".":"")+(n=2,e)}return r
/******/ }
/******/ var rangeToString = (range) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ if(0 in range){var r="",n=range[0];r+=0==n?">=":-1==n?"<":1==n?"^":2==n?"~":n>0?"=":"!=";for(var e=1,a=1;a<range.length;a++){var o=(typeof(t=range[a]))[0];e--,r+="u"==o?"-":"o"==o?"+":(e>0?".":"")+(e=2,t)}return r}var g=[];for(a=1;a<range.length;a++){var t=range[a];g.push(0===t?"not("+p()+")":1===t?"("+p()+" || "+p()+")":2===t?g.pop()+" "+g.pop():rangeToString(t))}return p();function p(){return g.pop().replace(/^\((.+)\)$/,"$1")}
/******/ }
/******/ var ensureExistence = (scopeName, key) => {
/******/ var scope = __webpack_require__.S[scopeName];
/******/ if(!scope || !__webpack_require__.o(scope, key)) throw new Error("Shared module " + key + " doesn't exist in shared scope " + scopeName);
/******/ return scope;
/******/ };
/******/ var invalidVersion = (version, requiredVersion) => {
/******/ for(var i = 0; i < requiredVersion.length; i++) {
/******/ if(i === version.length) return 1;
/******/ if(version[i] != requiredVersion[i]) { // loose equal is intentional to match string and number
/******/ if(typeof version[i] === "string" || typeof requiredVersion[i] === "string" || version[i] < requiredVersion[i]) return 1;
/******/ if(version[i] > requiredVersion[i]) return;
/******/ }
/******/ }
/******/ var findVersion = (scope, key) => {
/******/ var versions = scope[key];
/******/ return Object.keys(versions).reduce((a, bKey) => {
/******/ return !a || versionLt(a.version, versions[bKey].version) ? versions[bKey] : a;
/******/ }, 0);
/******/ };
/******/ var checkSingletonVersion = (key, version, requiredVersion, strict) => {
/******/ if(!invalidVersion(version, requiredVersion)) return 1;
/******/ var msg = "Unsatisfied version of shared singleton module " + key + "@" + (version && version.join(".")) + " (required " + key + "@" + requiredVersion.join(".") + ")";
/******/ if(strict) throw new Error(msg);
/******/ typeof console !== "undefined" && console.warn && console.warn(msg);
/******/ var findSingletonVersion = (scope, key) => {
/******/ var versions = scope[key];
/******/ return Object.keys(versions).reduce((a, bKey) => {
/******/ return !a || (!a.loaded && versionLt(a.version, versions[bKey].version)) ? versions[bKey] : a;
/******/ }, 0);
/******/ };
/******/ var findVersion = (scope, key, requiredVersion, strict) => {
/******/ requiredVersion = requiredVersion || [];
/******/ var currentName = key;
/******/ var versions = requiredVersion.map((v) => currentName += "`" + v);
/******/ versions.unshift(key);
/******/ var lastVersion;
/******/ while(currentName = versions.shift()) {
/******/ if(__webpack_require__.o(scope, currentName) && !invalidVersion(lastVersion = scope[currentName].version || [], requiredVersion)) return scope[currentName];
/******/ }
/******/ var msg = "Unsatisfied version of shared module " + key + "@" + (lastVersion && lastVersion.join(".")) + " (required " + key + "@" + requiredVersion.join(".") + ")";
/******/ if(strict) throw new Error(msg);
/******/ typeof console !== "undefined" && console.warn && console.warn(msg);
/******/ var getInvalidSingletonVersionMessage = (key, entry, requiredVersion) => {
/******/ return "Unsatisfied version " + versionToString(entry.version) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"
/******/ };
/******/ var get = (sharedModule) => (sharedModule.loaded = 1, sharedModule.get());
/******/ var load = (scopeName, key) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ return get(scope[key]);
/******/ var getSingletonVersion = (scope, scopeName, key, requiredVersion) => {
/******/ var entry = findSingletonVersion(scope, key);
/******/ if (!satisfy(requiredVersion, entry.version || [])) typeof console !== "undefined" && console.warn && console.warn(getInvalidSingletonVersionMessage(key, entry, requiredVersion));
/******/ return get(entry);
/******/ };
/******/ var loadFallback = (scopeName, key, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ return scope && __webpack_require__.o(scope, key) ? get(scope[key]) : fallback();
/******/ var getStrictSingletonVersion = (scope, scopeName, key, requiredVersion) => {
/******/ var entry = findSingletonVersion(scope, key);
/******/ if (!satisfy(requiredVersion, entry.version || [])) throw new Error(getInvalidSingletonVersionMessage(key, entry, requiredVersion));
/******/ return get(entry);
/******/ };
/******/ var loadVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ return get(findVersion(scope, key, version) || scope[key]);
/******/ var findValidVersion = (scope, key, requiredVersion) => {
/******/ var versions = scope[key];
/******/ return Object.keys(versions).reduce((a, bKey) => {
/******/ var b = versions[bKey];
/******/ if (!satisfy(requiredVersion, b.version || [])) return a;
/******/ return !a || versionLt(a.version, versions[bKey].version) ? versions[bKey] : a;
/******/ }, 0);
/******/ };
/******/ var loadSingletonVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ checkSingletonVersion(key, scope[key].version, version);
/******/ return get(scope[key]);
/******/ var getInvalidVersionMessage = (scope, scopeName, key, requiredVersion) => {
/******/ var versions = scope[key];
/******/ return "No satisfying version (" + rangeToString(requiredVersion) + ") of shared module " + key + " found in shared scope " + scopeName + ".\n" +
/******/ "Available versions: " + Object.keys(versions).map((key) => {
/******/ var entry = versions[key];
/******/ return versionToString(entry.version) + " from " + entry.from;
/******/ }).join(", ");
/******/ };
/******/ var loadStrictVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ return get(findVersion(scope, key, version, 1));
/******/ var getValidVersion = (scope, scopeName, key, requiredVersion) => {
/******/ var entry = findValidVersion(scope, key, requiredVersion);
/******/ if(entry) return get(entry);
/******/ throw new Error(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));
/******/ };
/******/ var loadStrictSingletonVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ checkSingletonVersion(key, scope[key].version, version, 1);
/******/ return get(scope[key]);
/******/ var warnInvalidVersion = (scope, scopeName, key, requiredVersion) => {
/******/ typeof console !== "undefined" && console.warn && console.warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));
/******/ };
/******/ var loadVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ var get = (entry) => {
/******/ entry.loaded = 1;
/******/ return entry.get()
/******/ };
/******/ var init = (fn) => function(scopeName, a, b, c) {
/******/ var promise = __webpack_require__.I(scopeName);
/******/ if (promise.then) return promise.then(fn.bind(fn, scopeName, __webpack_require__.S[scopeName], a, b, c));
/******/ return fn(scopeName, __webpack_require__.S[scopeName], a, b, c);
/******/ };
/******/
/******/ var load = /*#__PURE__*/ init((scopeName, scope, key) => {
/******/ ensureExistence(scopeName, key);
/******/ return get(findVersion(scope, key));
/******/ });
/******/ var loadFallback = /*#__PURE__*/ init((scopeName, scope, key, fallback) => {
/******/ return scope && __webpack_require__.o(scope, key) ? get(findVersion(scope, key)) : fallback();
/******/ });
/******/ var loadVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));
/******/ });
/******/ var loadSingletonVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return getSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadStrictVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return getValidVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadStrictSingletonVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return getStrictSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ if(!scope || !__webpack_require__.o(scope, key)) return fallback();
/******/ return get(findVersion(scope, key, version) || scope[key]);
/******/ };
/******/ var loadSingletonVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));
/******/ });
/******/ var loadSingletonVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ if(!scope || !__webpack_require__.o(scope, key)) return fallback();
/******/ checkSingletonVersion(key, scope[key].version, version);
/******/ return get(scope[key]);
/******/ };
/******/ var loadStrictVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ var entry = scope && findVersion(scope, key, version);
/******/ return getSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadStrictVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ var entry = scope && __webpack_require__.o(scope, key) && findValidVersion(scope, key, version);
/******/ return entry ? get(entry) : fallback();
/******/ };
/******/ var loadStrictSingletonVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ });
/******/ var loadStrictSingletonVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ if(!scope || !__webpack_require__.o(scope, key)) return fallback();
/******/ checkSingletonVersion(key, scope[key].version, version, 1);
/******/ return get(scope[key]);
/******/ };
/******/ return getStrictSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var installedModules = {};
/******/ var moduleToHandlerMapping = {
/******/ 5: () => loadSingletonVersionCheckFallback("default", "react", ["16",13,1], () => __webpack_require__.e("node_modules_react_index_js-_11191").then(() => () => __webpack_require__(/*! react */ 25))),
/******/ 9: () => loadSingletonVersionCheckFallback("default", "react", ["16",8,0], () => __webpack_require__.e("node_modules_react_index_js-_11191").then(() => () => __webpack_require__(/*! react */ 25)))
/******/ 5: () => loadSingletonVersionCheckFallback("default", "react", [1,16,13,1], () => __webpack_require__.e("node_modules_react_index_js-_11191").then(() => () => __webpack_require__(/*! react */ 25))),
/******/ 9: () => loadSingletonVersionCheckFallback("default", "react", [1,16,8,0], () => __webpack_require__.e("node_modules_react_index_js-_11191").then(() => () => __webpack_require__(/*! react */ 25)))
/******/ };
/******/ // no consumes in initial chunks
/******/ var chunkMapping = {
@ -1167,30 +1177,16 @@ __webpack_require__.d(exports, {
/******/ // runs all init snippets from all modules reachable
/******/ var scope = __webpack_require__.S[name];
/******/ var warn = (msg) => typeof console !== "undefined" && console.warn && console.warn(msg);;
/******/ var register = (name, version, factory, currentName) => {
/******/ var uniqueName = "module-federation-bbb";
/******/ var versionLt = (a, b) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var t=a[r],e=(typeof t)[0];if(r>=b.length)return"u"==e;var n=b[r],f=(typeof n)[0];if(e!=f)return"o"==e&&"n"==f||("s"==f||"u"==e);if("o"!=e&&"u"!=e&&t!=n)return t<n;r++}
/******/ }
/******/ var register = (name, version, factory) => {
/******/ version = version || [];
/******/ currentName = name;
/******/ var versionConflict = () => warn("Version conflict for shared modules: " + name + " " + (v && v.join(".")) + " <=> " + (version && version.join(".")));;
/******/ var registerCurrent = () => {
/******/ if(scope[currentName]) {
/******/ var v = scope[currentName].version || [];
/******/ for(var i = 0; i < version.length && i < v.length; i++) {
/******/ if(v[i] != version[i]) { // loose equal is intentional to match string and number
/******/ if(typeof v[i] === "string" || typeof version[i] === "string") return versionConflict();
/******/ if(v[i] > version[i]) return;
/******/ if(v[i] < version[i]) { i = -1; break; }
/******/ }
/******/ }
/******/ if(i >= 0 && version.length <= v.length) return;
/******/ if(scope[currentName].loaded) return warn("Ignoring providing of already used shared module: " + name);
/******/ }
/******/ scope[currentName] = { get: factory, version: version };
/******/ };
/******/ registerCurrent();
/******/ version.forEach((part) => {
/******/ currentName += "`" + part;
/******/ registerCurrent();
/******/ });
/******/ var versions = scope[name] = scope[name] || {};
/******/ var activeVersion = versions[version];
/******/ if(!activeVersion || uniqueName > activeVersion.from) versions[version] = { get: factory, version: version, from: uniqueName };
/******/ };
/******/ var initExternal = (id) => {
/******/ var handleError = (err) => warn("Initialization of sharing external failed: " + err);
@ -1217,105 +1213,129 @@ __webpack_require__.d(exports, {
/******/
/******/ /* webpack/runtime/consumes */
/******/ (() => {
/******/ var ensureExistence = (scope, scopeName, key) => {
/******/ var satisfy = (range, version) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ var r=0,e=1,n=!0;if(0 in range){var f=range[0],i=f<0;for(i&&(f=-f-1);;){var a=e<range.length?(typeof range[e])[0]:"";if(r>=version.length)return!n||("u"==a?e>f&&!i:""==a!=i);var o=version[r],t=(typeof o)[0];if(r++,"u"==t){if(!n||"u"!=a)return!1;e++}else if(n)if("s"!=a&&"n"!=a)if("o"==t){if("o"!=a)return!(e<=f)&&!i;e++}else{if(i||e<=f)return!1;n=!1}else{if("o"==t)return!(e<=f)&&i;if(a!=t)return!1;if("s"==a||e<=f){if(o!=range[e])return!1;e++}else{if(i?o>range[e]:o<range[e])return!1;o!=range[e]&&(n=!1),e++}}else{if("o"==t)return!0;"s"==a||"n"==a?e++:n=!1}}}var u=[];for(r=1;r<range.length;r++){var s=range[r];u.push(1==s?u.pop()|u.pop():2==s?u.pop()&u.pop():s?satisfy(s,version):!u.pop())}return!!u[0]
/******/ }
/******/ var versionLt = (a, b) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var t=a[r],e=(typeof t)[0];if(r>=b.length)return"u"==e;var n=b[r],f=(typeof n)[0];if(e!=f)return"o"==e&&"n"==f||("s"==f||"u"==e);if("o"!=e&&"u"!=e&&t!=n)return t<n;r++}
/******/ }
/******/ var versionToString = (version) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ if(!version)return"[unknown]";for(var r="",n=1,o=0;o<version.length;o++){var e=version[o],t=(typeof e)[0];n--,r+="u"==t?"-":"o"==t?"+":(n>0?".":"")+(n=2,e)}return r
/******/ }
/******/ var rangeToString = (range) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ if(0 in range){var r="",n=range[0];r+=0==n?">=":-1==n?"<":1==n?"^":2==n?"~":n>0?"=":"!=";for(var e=1,a=1;a<range.length;a++){var o=(typeof(t=range[a]))[0];e--,r+="u"==o?"-":"o"==o?"+":(e>0?".":"")+(e=2,t)}return r}var g=[];for(a=1;a<range.length;a++){var t=range[a];g.push(0===t?"not("+p()+")":1===t?"("+p()+" || "+p()+")":2===t?g.pop()+" "+g.pop():rangeToString(t))}return p();function p(){return g.pop().replace(/^\((.+)\)$/,"$1")}
/******/ }
/******/ var ensureExistence = (scopeName, key) => {
/******/ var scope = __webpack_require__.S[scopeName];
/******/ if(!scope || !__webpack_require__.o(scope, key)) throw new Error("Shared module " + key + " doesn't exist in shared scope " + scopeName);
/******/ return scope;
/******/ };
/******/ var invalidVersion = (version, requiredVersion) => {
/******/ for(var i = 0; i < requiredVersion.length; i++) {
/******/ if(i === version.length) return 1;
/******/ if(version[i] != requiredVersion[i]) { // loose equal is intentional to match string and number
/******/ if(typeof version[i] === "string" || typeof requiredVersion[i] === "string" || version[i] < requiredVersion[i]) return 1;
/******/ if(version[i] > requiredVersion[i]) return;
/******/ }
/******/ }
/******/ var findVersion = (scope, key) => {
/******/ var versions = scope[key];
/******/ return Object.keys(versions).reduce((a, bKey) => {
/******/ return !a || versionLt(a.version, versions[bKey].version) ? versions[bKey] : a;
/******/ }, 0);
/******/ };
/******/ var checkSingletonVersion = (key, version, requiredVersion, strict) => {
/******/ if(!invalidVersion(version, requiredVersion)) return 1;
/******/ var msg = "Unsatisfied version of shared singleton module " + key + "@" + (version && version.join(".")) + " (required " + key + "@" + requiredVersion.join(".") + ")";
/******/ if(strict) throw new Error(msg);
/******/ typeof console !== "undefined" && console.warn && console.warn(msg);
/******/ var findSingletonVersion = (scope, key) => {
/******/ var versions = scope[key];
/******/ return Object.keys(versions).reduce((a, bKey) => {
/******/ return !a || (!a.loaded && versionLt(a.version, versions[bKey].version)) ? versions[bKey] : a;
/******/ }, 0);
/******/ };
/******/ var findVersion = (scope, key, requiredVersion, strict) => {
/******/ requiredVersion = requiredVersion || [];
/******/ var currentName = key;
/******/ var versions = requiredVersion.map((v) => currentName += "`" + v);
/******/ versions.unshift(key);
/******/ var lastVersion;
/******/ while(currentName = versions.shift()) {
/******/ if(__webpack_require__.o(scope, currentName) && !invalidVersion(lastVersion = scope[currentName].version || [], requiredVersion)) return scope[currentName];
/******/ }
/******/ var msg = "Unsatisfied version of shared module " + key + "@" + (lastVersion && lastVersion.join(".")) + " (required " + key + "@" + requiredVersion.join(".") + ")";
/******/ if(strict) throw new Error(msg);
/******/ typeof console !== "undefined" && console.warn && console.warn(msg);
/******/ var getInvalidSingletonVersionMessage = (key, entry, requiredVersion) => {
/******/ return "Unsatisfied version " + versionToString(entry.version) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"
/******/ };
/******/ var get = (sharedModule) => (sharedModule.loaded = 1, sharedModule.get());
/******/ var load = (scopeName, key) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ return get(scope[key]);
/******/ var getSingletonVersion = (scope, scopeName, key, requiredVersion) => {
/******/ var entry = findSingletonVersion(scope, key);
/******/ if (!satisfy(requiredVersion, entry.version || [])) typeof console !== "undefined" && console.warn && console.warn(getInvalidSingletonVersionMessage(key, entry, requiredVersion));
/******/ return get(entry);
/******/ };
/******/ var loadFallback = (scopeName, key, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ return scope && __webpack_require__.o(scope, key) ? get(scope[key]) : fallback();
/******/ var getStrictSingletonVersion = (scope, scopeName, key, requiredVersion) => {
/******/ var entry = findSingletonVersion(scope, key);
/******/ if (!satisfy(requiredVersion, entry.version || [])) throw new Error(getInvalidSingletonVersionMessage(key, entry, requiredVersion));
/******/ return get(entry);
/******/ };
/******/ var loadVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ return get(findVersion(scope, key, version) || scope[key]);
/******/ var findValidVersion = (scope, key, requiredVersion) => {
/******/ var versions = scope[key];
/******/ return Object.keys(versions).reduce((a, bKey) => {
/******/ var b = versions[bKey];
/******/ if (!satisfy(requiredVersion, b.version || [])) return a;
/******/ return !a || versionLt(a.version, versions[bKey].version) ? versions[bKey] : a;
/******/ }, 0);
/******/ };
/******/ var loadSingletonVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ checkSingletonVersion(key, scope[key].version, version);
/******/ return get(scope[key]);
/******/ var getInvalidVersionMessage = (scope, scopeName, key, requiredVersion) => {
/******/ var versions = scope[key];
/******/ return "No satisfying version (" + rangeToString(requiredVersion) + ") of shared module " + key + " found in shared scope " + scopeName + ".\n" +
/******/ "Available versions: " + Object.keys(versions).map((key) => {
/******/ var entry = versions[key];
/******/ return versionToString(entry.version) + " from " + entry.from;
/******/ }).join(", ");
/******/ };
/******/ var loadStrictVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ return get(findVersion(scope, key, version, 1));
/******/ var getValidVersion = (scope, scopeName, key, requiredVersion) => {
/******/ var entry = findValidVersion(scope, key, requiredVersion);
/******/ if(entry) return get(entry);
/******/ throw new Error(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));
/******/ };
/******/ var loadStrictSingletonVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ checkSingletonVersion(key, scope[key].version, version, 1);
/******/ return get(scope[key]);
/******/ var warnInvalidVersion = (scope, scopeName, key, requiredVersion) => {
/******/ typeof console !== "undefined" && console.warn && console.warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));
/******/ };
/******/ var loadVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ var get = (entry) => {
/******/ entry.loaded = 1;
/******/ return entry.get()
/******/ };
/******/ var init = (fn) => function(scopeName, a, b, c) {
/******/ var promise = __webpack_require__.I(scopeName);
/******/ if (promise.then) return promise.then(fn.bind(fn, scopeName, __webpack_require__.S[scopeName], a, b, c));
/******/ return fn(scopeName, __webpack_require__.S[scopeName], a, b, c);
/******/ };
/******/
/******/ var load = /*#__PURE__*/ init((scopeName, scope, key) => {
/******/ ensureExistence(scopeName, key);
/******/ return get(findVersion(scope, key));
/******/ });
/******/ var loadFallback = /*#__PURE__*/ init((scopeName, scope, key, fallback) => {
/******/ return scope && __webpack_require__.o(scope, key) ? get(findVersion(scope, key)) : fallback();
/******/ });
/******/ var loadVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));
/******/ });
/******/ var loadSingletonVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return getSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadStrictVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return getValidVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadStrictSingletonVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return getStrictSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ if(!scope || !__webpack_require__.o(scope, key)) return fallback();
/******/ return get(findVersion(scope, key, version) || scope[key]);
/******/ };
/******/ var loadSingletonVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));
/******/ });
/******/ var loadSingletonVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ if(!scope || !__webpack_require__.o(scope, key)) return fallback();
/******/ checkSingletonVersion(key, scope[key].version, version);
/******/ return get(scope[key]);
/******/ };
/******/ var loadStrictVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ var entry = scope && findVersion(scope, key, version);
/******/ return getSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadStrictVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ var entry = scope && __webpack_require__.o(scope, key) && findValidVersion(scope, key, version);
/******/ return entry ? get(entry) : fallback();
/******/ };
/******/ var loadStrictSingletonVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ });
/******/ var loadStrictSingletonVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ if(!scope || !__webpack_require__.o(scope, key)) return fallback();
/******/ checkSingletonVersion(key, scope[key].version, version, 1);
/******/ return get(scope[key]);
/******/ };
/******/ return getStrictSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var installedModules = {};
/******/ var moduleToHandlerMapping = {
/******/ 5: () => loadStrictVersionCheckFallback("default", "date-fns", ["2",12,0], () => __webpack_require__.e("vendors-node_modules_date-fns_esm_index_js").then(() => () => __webpack_require__(/*! date-fns */ 6))),
/******/ 4: () => loadSingletonVersionCheckFallback("default", "react", ["16",8,0], () => __webpack_require__.e("node_modules_react_index_js").then(() => () => __webpack_require__(/*! react */ 237)))
/******/ 5: () => loadStrictVersionCheckFallback("default", "date-fns", [1,2,12,0], () => __webpack_require__.e("vendors-node_modules_date-fns_esm_index_js").then(() => () => __webpack_require__(/*! date-fns */ 6))),
/******/ 4: () => loadSingletonVersionCheckFallback("default", "react", [1,16,8,0], () => __webpack_require__.e("node_modules_react_index_js").then(() => () => __webpack_require__(/*! react */ 237)))
/******/ };
/******/ // no consumes in initial chunks
/******/ var chunkMapping = {
@ -1687,30 +1707,16 @@ __webpack_require__.d(exports, {
/******/ // runs all init snippets from all modules reachable
/******/ var scope = __webpack_require__.S[name];
/******/ var warn = (msg) => typeof console !== "undefined" && console.warn && console.warn(msg);;
/******/ var register = (name, version, factory, currentName) => {
/******/ var uniqueName = "module-federation-ccc";
/******/ var versionLt = (a, b) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var t=a[r],e=(typeof t)[0];if(r>=b.length)return"u"==e;var n=b[r],f=(typeof n)[0];if(e!=f)return"o"==e&&"n"==f||("s"==f||"u"==e);if("o"!=e&&"u"!=e&&t!=n)return t<n;r++}
/******/ }
/******/ var register = (name, version, factory) => {
/******/ version = version || [];
/******/ currentName = name;
/******/ var versionConflict = () => warn("Version conflict for shared modules: " + name + " " + (v && v.join(".")) + " <=> " + (version && version.join(".")));;
/******/ var registerCurrent = () => {
/******/ if(scope[currentName]) {
/******/ var v = scope[currentName].version || [];
/******/ for(var i = 0; i < version.length && i < v.length; i++) {
/******/ if(v[i] != version[i]) { // loose equal is intentional to match string and number
/******/ if(typeof v[i] === "string" || typeof version[i] === "string") return versionConflict();
/******/ if(v[i] > version[i]) return;
/******/ if(v[i] < version[i]) { i = -1; break; }
/******/ }
/******/ }
/******/ if(i >= 0 && version.length <= v.length) return;
/******/ if(scope[currentName].loaded) return warn("Ignoring providing of already used shared module: " + name);
/******/ }
/******/ scope[currentName] = { get: factory, version: version };
/******/ };
/******/ registerCurrent();
/******/ version.forEach((part) => {
/******/ currentName += "`" + part;
/******/ registerCurrent();
/******/ });
/******/ var versions = scope[name] = scope[name] || {};
/******/ var activeVersion = versions[version];
/******/ if(!activeVersion || uniqueName > activeVersion.from) versions[version] = { get: factory, version: version, from: uniqueName };
/******/ };
/******/ var initExternal = (id) => {
/******/ var handleError = (err) => warn("Initialization of sharing external failed: " + err);
@ -1737,106 +1743,130 @@ __webpack_require__.d(exports, {
/******/
/******/ /* webpack/runtime/consumes */
/******/ (() => {
/******/ var ensureExistence = (scope, scopeName, key) => {
/******/ var satisfy = (range, version) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ var r=0,e=1,n=!0;if(0 in range){var f=range[0],i=f<0;for(i&&(f=-f-1);;){var a=e<range.length?(typeof range[e])[0]:"";if(r>=version.length)return!n||("u"==a?e>f&&!i:""==a!=i);var o=version[r],t=(typeof o)[0];if(r++,"u"==t){if(!n||"u"!=a)return!1;e++}else if(n)if("s"!=a&&"n"!=a)if("o"==t){if("o"!=a)return!(e<=f)&&!i;e++}else{if(i||e<=f)return!1;n=!1}else{if("o"==t)return!(e<=f)&&i;if(a!=t)return!1;if("s"==a||e<=f){if(o!=range[e])return!1;e++}else{if(i?o>range[e]:o<range[e])return!1;o!=range[e]&&(n=!1),e++}}else{if("o"==t)return!0;"s"==a||"n"==a?e++:n=!1}}}var u=[];for(r=1;r<range.length;r++){var s=range[r];u.push(1==s?u.pop()|u.pop():2==s?u.pop()&u.pop():s?satisfy(s,version):!u.pop())}return!!u[0]
/******/ }
/******/ var versionLt = (a, b) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var t=a[r],e=(typeof t)[0];if(r>=b.length)return"u"==e;var n=b[r],f=(typeof n)[0];if(e!=f)return"o"==e&&"n"==f||("s"==f||"u"==e);if("o"!=e&&"u"!=e&&t!=n)return t<n;r++}
/******/ }
/******/ var versionToString = (version) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ if(!version)return"[unknown]";for(var r="",n=1,o=0;o<version.length;o++){var e=version[o],t=(typeof e)[0];n--,r+="u"==t?"-":"o"==t?"+":(n>0?".":"")+(n=2,e)}return r
/******/ }
/******/ var rangeToString = (range) => {
/******/ // see webpack/lib/util/semver.js for original code
/******/ if(0 in range){var r="",n=range[0];r+=0==n?">=":-1==n?"<":1==n?"^":2==n?"~":n>0?"=":"!=";for(var e=1,a=1;a<range.length;a++){var o=(typeof(t=range[a]))[0];e--,r+="u"==o?"-":"o"==o?"+":(e>0?".":"")+(e=2,t)}return r}var g=[];for(a=1;a<range.length;a++){var t=range[a];g.push(0===t?"not("+p()+")":1===t?"("+p()+" || "+p()+")":2===t?g.pop()+" "+g.pop():rangeToString(t))}return p();function p(){return g.pop().replace(/^\((.+)\)$/,"$1")}
/******/ }
/******/ var ensureExistence = (scopeName, key) => {
/******/ var scope = __webpack_require__.S[scopeName];
/******/ if(!scope || !__webpack_require__.o(scope, key)) throw new Error("Shared module " + key + " doesn't exist in shared scope " + scopeName);
/******/ return scope;
/******/ };
/******/ var invalidVersion = (version, requiredVersion) => {
/******/ for(var i = 0; i < requiredVersion.length; i++) {
/******/ if(i === version.length) return 1;
/******/ if(version[i] != requiredVersion[i]) { // loose equal is intentional to match string and number
/******/ if(typeof version[i] === "string" || typeof requiredVersion[i] === "string" || version[i] < requiredVersion[i]) return 1;
/******/ if(version[i] > requiredVersion[i]) return;
/******/ }
/******/ }
/******/ var findVersion = (scope, key) => {
/******/ var versions = scope[key];
/******/ return Object.keys(versions).reduce((a, bKey) => {
/******/ return !a || versionLt(a.version, versions[bKey].version) ? versions[bKey] : a;
/******/ }, 0);
/******/ };
/******/ var checkSingletonVersion = (key, version, requiredVersion, strict) => {
/******/ if(!invalidVersion(version, requiredVersion)) return 1;
/******/ var msg = "Unsatisfied version of shared singleton module " + key + "@" + (version && version.join(".")) + " (required " + key + "@" + requiredVersion.join(".") + ")";
/******/ if(strict) throw new Error(msg);
/******/ typeof console !== "undefined" && console.warn && console.warn(msg);
/******/ var findSingletonVersion = (scope, key) => {
/******/ var versions = scope[key];
/******/ return Object.keys(versions).reduce((a, bKey) => {
/******/ return !a || (!a.loaded && versionLt(a.version, versions[bKey].version)) ? versions[bKey] : a;
/******/ }, 0);
/******/ };
/******/ var findVersion = (scope, key, requiredVersion, strict) => {
/******/ requiredVersion = requiredVersion || [];
/******/ var currentName = key;
/******/ var versions = requiredVersion.map((v) => currentName += "`" + v);
/******/ versions.unshift(key);
/******/ var lastVersion;
/******/ while(currentName = versions.shift()) {
/******/ if(__webpack_require__.o(scope, currentName) && !invalidVersion(lastVersion = scope[currentName].version || [], requiredVersion)) return scope[currentName];
/******/ }
/******/ var msg = "Unsatisfied version of shared module " + key + "@" + (lastVersion && lastVersion.join(".")) + " (required " + key + "@" + requiredVersion.join(".") + ")";
/******/ if(strict) throw new Error(msg);
/******/ typeof console !== "undefined" && console.warn && console.warn(msg);
/******/ var getInvalidSingletonVersionMessage = (key, entry, requiredVersion) => {
/******/ return "Unsatisfied version " + versionToString(entry.version) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"
/******/ };
/******/ var get = (sharedModule) => (sharedModule.loaded = 1, sharedModule.get());
/******/ var load = (scopeName, key) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ return get(scope[key]);
/******/ var getSingletonVersion = (scope, scopeName, key, requiredVersion) => {
/******/ var entry = findSingletonVersion(scope, key);
/******/ if (!satisfy(requiredVersion, entry.version || [])) typeof console !== "undefined" && console.warn && console.warn(getInvalidSingletonVersionMessage(key, entry, requiredVersion));
/******/ return get(entry);
/******/ };
/******/ var loadFallback = (scopeName, key, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ return scope && __webpack_require__.o(scope, key) ? get(scope[key]) : fallback();
/******/ var getStrictSingletonVersion = (scope, scopeName, key, requiredVersion) => {
/******/ var entry = findSingletonVersion(scope, key);
/******/ if (!satisfy(requiredVersion, entry.version || [])) throw new Error(getInvalidSingletonVersionMessage(key, entry, requiredVersion));
/******/ return get(entry);
/******/ };
/******/ var loadVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ return get(findVersion(scope, key, version) || scope[key]);
/******/ var findValidVersion = (scope, key, requiredVersion) => {
/******/ var versions = scope[key];
/******/ return Object.keys(versions).reduce((a, bKey) => {
/******/ var b = versions[bKey];
/******/ if (!satisfy(requiredVersion, b.version || [])) return a;
/******/ return !a || versionLt(a.version, versions[bKey].version) ? versions[bKey] : a;
/******/ }, 0);
/******/ };
/******/ var loadSingletonVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ checkSingletonVersion(key, scope[key].version, version);
/******/ return get(scope[key]);
/******/ var getInvalidVersionMessage = (scope, scopeName, key, requiredVersion) => {
/******/ var versions = scope[key];
/******/ return "No satisfying version (" + rangeToString(requiredVersion) + ") of shared module " + key + " found in shared scope " + scopeName + ".\n" +
/******/ "Available versions: " + Object.keys(versions).map((key) => {
/******/ var entry = versions[key];
/******/ return versionToString(entry.version) + " from " + entry.from;
/******/ }).join(", ");
/******/ };
/******/ var loadStrictVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ return get(findVersion(scope, key, version, 1));
/******/ var getValidVersion = (scope, scopeName, key, requiredVersion) => {
/******/ var entry = findValidVersion(scope, key, requiredVersion);
/******/ if(entry) return get(entry);
/******/ throw new Error(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));
/******/ };
/******/ var loadStrictSingletonVersionCheck = (scopeName, key, version) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ ensureExistence(scope, scopeName, key);
/******/ checkSingletonVersion(key, scope[key].version, version, 1);
/******/ return get(scope[key]);
/******/ var warnInvalidVersion = (scope, scopeName, key, requiredVersion) => {
/******/ typeof console !== "undefined" && console.warn && console.warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));
/******/ };
/******/ var loadVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ var get = (entry) => {
/******/ entry.loaded = 1;
/******/ return entry.get()
/******/ };
/******/ var init = (fn) => function(scopeName, a, b, c) {
/******/ var promise = __webpack_require__.I(scopeName);
/******/ if (promise.then) return promise.then(fn.bind(fn, scopeName, __webpack_require__.S[scopeName], a, b, c));
/******/ return fn(scopeName, __webpack_require__.S[scopeName], a, b, c);
/******/ };
/******/
/******/ var load = /*#__PURE__*/ init((scopeName, scope, key) => {
/******/ ensureExistence(scopeName, key);
/******/ return get(findVersion(scope, key));
/******/ });
/******/ var loadFallback = /*#__PURE__*/ init((scopeName, scope, key, fallback) => {
/******/ return scope && __webpack_require__.o(scope, key) ? get(findVersion(scope, key)) : fallback();
/******/ });
/******/ var loadVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));
/******/ });
/******/ var loadSingletonVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return getSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadStrictVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return getValidVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadStrictSingletonVersionCheck = /*#__PURE__*/ init((scopeName, scope, key, version) => {
/******/ ensureExistence(scopeName, key);
/******/ return getStrictSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ if(!scope || !__webpack_require__.o(scope, key)) return fallback();
/******/ return get(findVersion(scope, key, version) || scope[key]);
/******/ };
/******/ var loadSingletonVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));
/******/ });
/******/ var loadSingletonVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ if(!scope || !__webpack_require__.o(scope, key)) return fallback();
/******/ checkSingletonVersion(key, scope[key].version, version);
/******/ return get(scope[key]);
/******/ };
/******/ var loadStrictVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ var entry = scope && findVersion(scope, key, version);
/******/ return getSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var loadStrictVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ var entry = scope && __webpack_require__.o(scope, key) && findValidVersion(scope, key, version);
/******/ return entry ? get(entry) : fallback();
/******/ };
/******/ var loadStrictSingletonVersionCheckFallback = (scopeName, key, version, fallback) => {
/******/ __webpack_require__.I(scopeName);
/******/ var scope = __webpack_require__.S[scopeName];
/******/ });
/******/ var loadStrictSingletonVersionCheckFallback = /*#__PURE__*/ init((scopeName, scope, key, version, fallback) => {
/******/ if(!scope || !__webpack_require__.o(scope, key)) return fallback();
/******/ checkSingletonVersion(key, scope[key].version, version, 1);
/******/ return get(scope[key]);
/******/ };
/******/ return getStrictSingletonVersion(scope, scopeName, key, version);
/******/ });
/******/ var installedModules = {};
/******/ var moduleToHandlerMapping = {
/******/ 4: () => loadSingletonVersionCheck("default", "react", ["16",8,0]),
/******/ 5: () => loadStrictVersionCheckFallback("default", "date-fns", ["2",12,0], () => __webpack_require__.e("vendors-node_modules_date-fns_esm_index_js").then(() => () => __webpack_require__(/*! date-fns */ 8))),
/******/ 7: () => loadStrictVersionCheckFallback("default", "lodash/random", ["4",17,4], () => __webpack_require__.e("vendors-node_modules_lodash_random_js").then(() => () => __webpack_require__(/*! lodash/random */ 239)))
/******/ 4: () => loadSingletonVersionCheck("default", "react", [1,16,8,0]),
/******/ 5: () => loadStrictVersionCheckFallback("default", "date-fns", [1,2,12,0], () => __webpack_require__.e("vendors-node_modules_date-fns_esm_index_js").then(() => () => __webpack_require__(/*! date-fns */ 8))),
/******/ 7: () => loadStrictVersionCheckFallback("default", "lodash/random", [1,4,17,4], () => __webpack_require__.e("vendors-node_modules_lodash_random_js").then(() => () => __webpack_require__(/*! lodash/random */ 239)))
/******/ };
/******/ // no consumes in initial chunks
/******/ var chunkMapping = {
@ -1999,12 +2029,12 @@ Version: webpack 5.0.0-beta.20
Child app:
Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size
app.js 26.8 KiB [emitted] [name: app]
app.js 29.2 KiB [emitted] [name: app]
node_modules_react_index_js-_11190.js 12.6 KiB [emitted]
node_modules_react_index_js-_11191.js 10.2 KiB [emitted]
src_bootstrap_js.js 157 KiB [emitted]
Entrypoint app = app.js
chunk app.js (app) 669 bytes (javascript) 42 bytes (share-init) 16.4 KiB (runtime) [entry] [rendered]
chunk app.js (app) 669 bytes (javascript) 42 bytes (share-init) 18.7 KiB (runtime) [entry] [rendered]
> ./src/index.js app
./src/index.js 585 bytes [built]
external "mfeBBB@/dist/bbb/mfeBBB.js" 42 bytes [built]
@ -2030,12 +2060,12 @@ Child app:
Child mfe-b:
Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size
mfeBBB.js 21.9 KiB [emitted] [name: mfeBBB]
mfeBBB.js 24.3 KiB [emitted] [name: mfeBBB]
node_modules_react_index_js.js 12.6 KiB [emitted]
src-b_Component_js.js 2.26 KiB [emitted]
vendors-node_modules_date-fns_esm_index_js.js 796 KiB [emitted] [id hint: vendors]
Entrypoint mfeBBB = mfeBBB.js
chunk mfeBBB.js (mfeBBB) 42 bytes (javascript) 84 bytes (share-init) 14.1 KiB (runtime) [entry] [rendered]
chunk mfeBBB.js (mfeBBB) 42 bytes (javascript) 84 bytes (share-init) 16.4 KiB (runtime) [entry] [rendered]
> mfeBBB
container entry 42 bytes [built]
provide shared module (default) date-fns@2.14.0 = ../../node_modules/date-fns/esm/index.js 42 bytes [built]
@ -2058,13 +2088,13 @@ Child mfe-b:
Child mfe-c:
Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size
mfeCCC.js 22.9 KiB [emitted] [name: mfeCCC]
mfeCCC.js 25.2 KiB [emitted] [name: mfeCCC]
src-c_Component_js.js 1.99 KiB [emitted]
src-c_LazyComponent_js.js 2.08 KiB [emitted]
vendors-node_modules_date-fns_esm_index_js.js 797 KiB [emitted] [id hint: vendors]
vendors-node_modules_lodash_random_js.js 23.3 KiB [emitted] [id hint: vendors]
Entrypoint mfeCCC = mfeCCC.js
chunk mfeCCC.js (mfeCCC) 42 bytes (javascript) 84 bytes (share-init) 14.5 KiB (runtime) [entry] [rendered]
chunk mfeCCC.js (mfeCCC) 42 bytes (javascript) 84 bytes (share-init) 16.8 KiB (runtime) [entry] [rendered]
> mfeCCC
container entry 42 bytes [built]
provide shared module (default) date-fns@2.14.0 = ../../node_modules/date-fns/esm/index.js 42 bytes [built]
@ -2102,7 +2132,7 @@ Version: webpack 5.0.0-beta.20
Child app:
Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size
app.js 5.89 KiB [emitted] [name: app]
app.js 6.98 KiB [emitted] [name: app]
node_modules_react_index_js-_11190.js 7.26 KiB [emitted]
node_modules_react_index_js-_11190.js.LICENSE.txt 295 bytes [emitted]
node_modules_react_index_js-_11191.js 6.31 KiB [emitted]
@ -2110,7 +2140,7 @@ Child app:
src_bootstrap_js.js 129 KiB [emitted]
src_bootstrap_js.js.LICENSE.txt 546 bytes [emitted]
Entrypoint app = app.js
chunk app.js (app) 669 bytes (javascript) 42 bytes (share-init) 16.3 KiB (runtime) [entry] [rendered]
chunk app.js (app) 669 bytes (javascript) 42 bytes (share-init) 18.6 KiB (runtime) [entry] [rendered]
> ./src/index.js app
./src/index.js 585 bytes [built]
external "mfeBBB@/dist/bbb/mfeBBB.js" 42 bytes [built]
@ -2136,13 +2166,13 @@ Child app:
Child mfe-b:
Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size
mfeBBB.js 4.79 KiB [emitted] [name: mfeBBB]
mfeBBB.js 5.64 KiB [emitted] [name: mfeBBB]
node_modules_react_index_js.js 7.21 KiB [emitted]
node_modules_react_index_js.js.LICENSE.txt 295 bytes [emitted]
src-b_Component_js.js 493 bytes [emitted]
vendors-node_modules_date-fns_esm_index_js.js 77.4 KiB [emitted] [id hint: vendors]
Entrypoint mfeBBB = mfeBBB.js
chunk mfeBBB.js (mfeBBB) 42 bytes (javascript) 84 bytes (share-init) 14 KiB (runtime) [entry] [rendered]
chunk mfeBBB.js (mfeBBB) 42 bytes (javascript) 84 bytes (share-init) 16.3 KiB (runtime) [entry] [rendered]
> mfeBBB
container entry 42 bytes [built]
provide shared module (default) date-fns@2.14.0 = ../../node_modules/date-fns/esm/index.js 42 bytes [built]
@ -2164,13 +2194,13 @@ Child mfe-b:
Child mfe-c:
Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size
mfeCCC.js 5.42 KiB [emitted] [name: mfeCCC]
mfeCCC.js 6.29 KiB [emitted] [name: mfeCCC]
node_modules_lodash_random_js.js 2.95 KiB [emitted]
src-c_Component_js.js 493 bytes [emitted]
src-c_LazyComponent_js.js 537 bytes [emitted]
vendors-node_modules_date-fns_esm_index_js.js 77.4 KiB [emitted] [id hint: vendors]
Entrypoint mfeCCC = mfeCCC.js
chunk mfeCCC.js (mfeCCC) 42 bytes (javascript) 84 bytes (share-init) 14.4 KiB (runtime) [entry] [rendered]
chunk mfeCCC.js (mfeCCC) 42 bytes (javascript) 84 bytes (share-init) 16.7 KiB (runtime) [entry] [rendered]
> mfeCCC
container entry 42 bytes [built]
provide shared module (default) date-fns@2.14.0 = ../../node_modules/date-fns/esm/index.js 42 bytes [built]

View File

@ -10,8 +10,8 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
const Module = require("../Module");
const RuntimeGlobals = require("../RuntimeGlobals");
const makeSerializable = require("../util/makeSerializable");
const { rangeToString, stringifyHoley } = require("../util/semver");
const ConsumeSharedFallbackDependency = require("./ConsumeSharedFallbackDependency");
const { versionToString } = require("./utils");
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
@ -26,6 +26,7 @@ const { versionToString } = require("./utils");
/** @typedef {import("../WebpackError")} WebpackError */
/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
/** @typedef {import("../util/semver").SemVerRange} SemVerRange */
/**
* @typedef {Object} ConsumeOptions
@ -33,7 +34,7 @@ const { versionToString } = require("./utils");
* @property {string=} importResolved resolved fallback request
* @property {string} shareKey global share key
* @property {string} shareScope share scope
* @property {(number|string)[] | undefined} requiredVersion version requirement
* @property {SemVerRange | false | undefined} requiredVersion version requirement
* @property {string} packageName package name to determine required version automatically
* @property {boolean} strictVersion don't use shared version even if version isn't valid
* @property {boolean} singleton use single global version
@ -66,7 +67,7 @@ class ConsumeSharedModule extends Module {
eager
} = this.options;
return `consume-shared-module|${shareScope}|${shareKey}|${
requiredVersion && versionToString(requiredVersion)
requiredVersion && rangeToString(requiredVersion)
}|${strictVersion}|${importResolved}|${singleton}|${eager}`;
}
@ -84,9 +85,9 @@ class ConsumeSharedModule extends Module {
singleton,
eager
} = this.options;
return `consume shared module (${shareScope}) ${shareKey}@${versionToString(
requiredVersion
)}${strictVersion ? " (strict)" : ""}${singleton ? " (singleton)" : ""}${
return `consume shared module (${shareScope}) ${shareKey}@${
requiredVersion ? rangeToString(requiredVersion) : "*"
}${strictVersion ? " (strict)" : ""}${singleton ? " (singleton)" : ""}${
importResolved
? ` (fallback: ${requestShortener.shorten(importResolved)})`
: ""
@ -206,7 +207,7 @@ class ConsumeSharedModule extends Module {
if (singleton) {
fn += "Singleton";
}
args.push(JSON.stringify(requiredVersion));
args.push(stringifyHoley(requiredVersion));
fn += "VersionCheck";
}
if (fallbackCode) {

View File

@ -12,13 +12,13 @@ const RuntimeGlobals = require("../RuntimeGlobals");
const WebpackError = require("../WebpackError");
const { parseOptions } = require("../container/options");
const LazySet = require("../util/LazySet");
const { parseRange } = require("../util/semver");
const ConsumeSharedFallbackDependency = require("./ConsumeSharedFallbackDependency");
const ConsumeSharedModule = require("./ConsumeSharedModule");
const ConsumeSharedRuntimeModule = require("./ConsumeSharedRuntimeModule");
const ProvideForSharedDependency = require("./ProvideForSharedDependency");
const { resolveMatchedConfigs } = require("./resolveMatchedConfigs");
const {
parseRequiredVersion,
isRequiredVersion,
getDescriptionFile,
getRequiredVersionFromDescriptionFile
@ -43,12 +43,12 @@ class ConsumeSharedPlugin {
validateOptions(schema, options, { name: "Consumes Shared Plugin" });
}
/** @type {[string, ConsumesConfig][]} */
/** @type {[string, ConsumeOptions][]} */
this._consumes = parseOptions(
options.consumes,
(item, key) => {
if (Array.isArray(item)) throw new Error("Unexpected array in options");
/** @type {ConsumesConfig} */
/** @type {ConsumeOptions} */
let result =
item === key || !isRequiredVersion(item)
? // item is a request/key
@ -68,8 +68,7 @@ class ConsumeSharedPlugin {
import: key,
shareScope: options.shareScope || "default",
shareKey: key,
requiredVersion:
typeof item === "string" ? parseRequiredVersion(item) : item,
requiredVersion: parseRange(item),
strictVersion: true,
packageName: undefined,
singleton: false,
@ -83,7 +82,7 @@ class ConsumeSharedPlugin {
shareKey: item.shareKey || key,
requiredVersion:
typeof item.requiredVersion === "string"
? parseRequiredVersion(item.requiredVersion)
? parseRange(item.requiredVersion)
: item.requiredVersion,
strictVersion:
typeof item.strictVersion === "boolean"
@ -227,13 +226,7 @@ class ConsumeSharedPlugin {
);
return resolve();
}
if (!isRequiredVersion(requiredVersion)) {
requiredVersionWarning(
`Required version in description file ("${requiredVersion}") is unsupported (too complex, weird syntax).`
);
return resolve();
}
resolve(parseRequiredVersion(requiredVersion));
resolve(parseRange(requiredVersion));
}
);
})

View File

@ -8,6 +8,12 @@
const RuntimeGlobals = require("../RuntimeGlobals");
const RuntimeModule = require("../RuntimeModule");
const Template = require("../Template");
const {
satisfyRuntimeCode,
versionLtRuntimeCode,
versionToStringRuntimeCode,
rangeToStringRuntimeCode
} = require("../util/semver");
/** @typedef {import("./ConsumeSharedModule")} ConsumeSharedModule */
@ -58,150 +64,188 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
}
if (idToModuleMapping.size === 0) return null;
return Template.asString([
`var ensureExistence = ${runtimeTemplate.basicFunction(
"scope, scopeName, key",
`if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) throw new Error("Shared module " + key + " doesn't exist in shared scope " + scopeName);`
)};`,
`var invalidVersion = ${runtimeTemplate.basicFunction(
"version, requiredVersion",
satisfyRuntimeCode(runtimeTemplate),
versionLtRuntimeCode(runtimeTemplate),
versionToStringRuntimeCode(runtimeTemplate),
rangeToStringRuntimeCode(runtimeTemplate),
`var ensureExistence = ${runtimeTemplate.basicFunction("scopeName, key", [
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
`if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) throw new Error("Shared module " + key + " doesn't exist in shared scope " + scopeName);`,
"return scope;"
])};`,
`var findVersion = ${runtimeTemplate.basicFunction("scope, key", [
"var versions = scope[key];",
`return Object.keys(versions).reduce(${runtimeTemplate.basicFunction(
"a, bKey",
[
"return !a || versionLt(a.version, versions[bKey].version) ? versions[bKey] : a;"
]
)}, 0);`
])};`,
`var findSingletonVersion = ${runtimeTemplate.basicFunction(
"scope, key",
[
"for(var i = 0; i < requiredVersion.length; i++) {",
"var versions = scope[key];",
`return Object.keys(versions).reduce(${runtimeTemplate.basicFunction(
"a, bKey",
[
"return !a || (!a.loaded && versionLt(a.version, versions[bKey].version)) ? versions[bKey] : a;"
]
)}, 0);`
]
)};`,
`var getInvalidSingletonVersionMessage = ${runtimeTemplate.basicFunction(
"key, entry, requiredVersion",
[
`return "Unsatisfied version " + versionToString(entry.version) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"`
]
)};`,
`var getSingletonVersion = ${runtimeTemplate.basicFunction(
"scope, scopeName, key, requiredVersion",
[
"var entry = findSingletonVersion(scope, key);",
"if (!satisfy(requiredVersion, entry.version || [])) " +
'typeof console !== "undefined" && console.warn && console.warn(getInvalidSingletonVersionMessage(key, entry, requiredVersion));',
"return get(entry);"
]
)};`,
`var getStrictSingletonVersion = ${runtimeTemplate.basicFunction(
"scope, scopeName, key, requiredVersion",
[
"var entry = findSingletonVersion(scope, key);",
"if (!satisfy(requiredVersion, entry.version || [])) " +
"throw new Error(getInvalidSingletonVersionMessage(key, entry, requiredVersion));",
"return get(entry);"
]
)};`,
`var findValidVersion = ${runtimeTemplate.basicFunction(
"scope, key, requiredVersion",
[
"var versions = scope[key];",
`return Object.keys(versions).reduce(${runtimeTemplate.basicFunction(
"a, bKey",
[
"var b = versions[bKey];",
"if (!satisfy(requiredVersion, b.version || [])) return a;",
"return !a || versionLt(a.version, versions[bKey].version) ? versions[bKey] : a;"
]
)}, 0);`
]
)};`,
`var getInvalidVersionMessage = ${runtimeTemplate.basicFunction(
"scope, scopeName, key, requiredVersion",
[
"var versions = scope[key];",
'return "No satisfying version (" + rangeToString(requiredVersion) + ") of shared module " + key + " found in shared scope " + scopeName + ".\\n" +',
`\t"Available versions: " + Object.keys(versions).map(${runtimeTemplate.basicFunction(
"key",
[
"var entry = versions[key];",
'return versionToString(entry.version) + " from " + entry.from;'
]
)}).join(", ");`
]
)};`,
`var getValidVersion = ${runtimeTemplate.basicFunction(
"scope, scopeName, key, requiredVersion",
[
"var entry = findValidVersion(scope, key, requiredVersion);",
"if(entry) return get(entry);",
"throw new Error(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));"
]
)};`,
`var warnInvalidVersion = ${runtimeTemplate.basicFunction(
"scope, scopeName, key, requiredVersion",
[
'typeof console !== "undefined" && console.warn && console.warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));'
]
)};`,
`var get = ${runtimeTemplate.basicFunction("entry", [
"entry.loaded = 1;",
"return entry.get()"
])};`,
`var init = ${runtimeTemplate.returningFunction(
Template.asString([
"function(scopeName, a, b, c) {",
Template.indent([
"if(i === version.length) return 1;",
"if(version[i] != requiredVersion[i]) { // loose equal is intentional to match string and number",
Template.indent([
'if(typeof version[i] === "string" || typeof requiredVersion[i] === "string" || version[i] < requiredVersion[i]) return 1;',
"if(version[i] > requiredVersion[i]) return;"
]),
"}"
`var promise = ${RuntimeGlobals.initializeSharing}(scopeName);`,
`if (promise.then) return promise.then(fn.bind(fn, scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c));`,
`return fn(scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c);`
]),
"}"
]
]),
"fn"
)};`,
`var checkSingletonVersion = ${runtimeTemplate.basicFunction(
"key, version, requiredVersion, strict",
"",
`var load = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
"scopeName, scope, key",
[
"if(!invalidVersion(version, requiredVersion)) return 1;",
'var msg = "Unsatisfied version of shared singleton module " + key + "@" + (version && version.join(".")) + " (required " + key + "@" + requiredVersion.join(".") + ")";',
"if(strict) throw new Error(msg);",
'typeof console !== "undefined" && console.warn && console.warn(msg);'
"ensureExistence(scopeName, key);",
"return get(findVersion(scope, key));"
]
)};`,
`var findVersion = ${runtimeTemplate.basicFunction(
"scope, key, requiredVersion, strict",
)});`,
`var loadFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
"scopeName, scope, key, fallback",
[
"requiredVersion = requiredVersion || [];",
"var currentName = key;",
`var versions = requiredVersion.map(${runtimeTemplate.returningFunction(
'currentName += "`" + v',
"v"
)});`,
"versions.unshift(key);",
"var lastVersion;",
"while(currentName = versions.shift()) {",
Template.indent([
`if(${RuntimeGlobals.hasOwnProperty}(scope, currentName) && !invalidVersion(lastVersion = scope[currentName].version || [], requiredVersion)) return scope[currentName];`
]),
"}",
'var msg = "Unsatisfied version of shared module " + key + "@" + (lastVersion && lastVersion.join(".")) + " (required " + key + "@" + requiredVersion.join(".") + ")";',
"if(strict) throw new Error(msg);",
'typeof console !== "undefined" && console.warn && console.warn(msg);'
`return scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) ? get(findVersion(scope, key)) : fallback();`
]
)};`,
`var get = ${runtimeTemplate.returningFunction(
"(sharedModule.loaded = 1, sharedModule.get())",
"sharedModule"
)};`,
`var load = ${runtimeTemplate.basicFunction("scopeName, key", [
`${RuntimeGlobals.initializeSharing}(scopeName);`,
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
`ensureExistence(scope, scopeName, key);`,
"return get(scope[key]);"
])};`,
`var loadFallback = ${runtimeTemplate.basicFunction(
"scopeName, key, fallback",
)});`,
`var loadVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
"scopeName, scope, key, version",
[
`${RuntimeGlobals.initializeSharing}(scopeName);`,
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
`return scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) ? get(scope[key]) : fallback();`
"ensureExistence(scopeName, key);",
"return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));"
]
)};`,
`var loadVersionCheck = ${runtimeTemplate.basicFunction(
"scopeName, key, version",
)});`,
`var loadSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
"scopeName, scope, key, version",
[
`${RuntimeGlobals.initializeSharing}(scopeName);`,
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
"ensureExistence(scope, scopeName, key);",
"return get(findVersion(scope, key, version) || scope[key]);"
"ensureExistence(scopeName, key);",
"return getSingletonVersion(scope, scopeName, key, version);"
]
)};`,
`var loadSingletonVersionCheck = ${runtimeTemplate.basicFunction(
"scopeName, key, version",
)});`,
`var loadStrictVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
"scopeName, scope, key, version",
[
`${RuntimeGlobals.initializeSharing}(scopeName);`,
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
"ensureExistence(scope, scopeName, key);",
"checkSingletonVersion(key, scope[key].version, version);",
"return get(scope[key]);"
"ensureExistence(scopeName, key);",
"return getValidVersion(scope, scopeName, key, version);"
]
)};`,
`var loadStrictVersionCheck = ${runtimeTemplate.basicFunction(
"scopeName, key, version",
)});`,
`var loadStrictSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
"scopeName, scope, key, version",
[
`${RuntimeGlobals.initializeSharing}(scopeName);`,
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
"ensureExistence(scope, scopeName, key);",
"return get(findVersion(scope, key, version, 1));"
"ensureExistence(scopeName, key);",
"return getStrictSingletonVersion(scope, scopeName, key, version);"
]
)};`,
`var loadStrictSingletonVersionCheck = ${runtimeTemplate.basicFunction(
"scopeName, key, version",
)});`,
`var loadVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
"scopeName, scope, key, version, fallback",
[
`${RuntimeGlobals.initializeSharing}(scopeName);`,
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
"ensureExistence(scope, scopeName, key);",
"checkSingletonVersion(key, scope[key].version, version, 1);",
"return get(scope[key]);"
]
)};`,
`var loadVersionCheckFallback = ${runtimeTemplate.basicFunction(
"scopeName, key, version, fallback",
[
`${RuntimeGlobals.initializeSharing}(scopeName);`,
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
`if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,
"return get(findVersion(scope, key, version) || scope[key]);"
"return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));"
]
)};`,
`var loadSingletonVersionCheckFallback = ${runtimeTemplate.basicFunction(
"scopeName, key, version, fallback",
)});`,
`var loadSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
"scopeName, scope, key, version, fallback",
[
`${RuntimeGlobals.initializeSharing}(scopeName);`,
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
`if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,
"checkSingletonVersion(key, scope[key].version, version);",
"return get(scope[key]);"
"return getSingletonVersion(scope, scopeName, key, version);"
]
)};`,
`var loadStrictVersionCheckFallback = ${runtimeTemplate.basicFunction(
"scopeName, key, version, fallback",
)});`,
`var loadStrictVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
"scopeName, scope, key, version, fallback",
[
`${RuntimeGlobals.initializeSharing}(scopeName);`,
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
"var entry = scope && findVersion(scope, key, version);",
`var entry = scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) && findValidVersion(scope, key, version);`,
`return entry ? get(entry) : fallback();`
]
)};`,
`var loadStrictSingletonVersionCheckFallback = ${runtimeTemplate.basicFunction(
"scopeName, key, version, fallback",
)});`,
`var loadStrictSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
"scopeName, scope, key, version, fallback",
[
`${RuntimeGlobals.initializeSharing}(scopeName);`,
`var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
`if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,
"checkSingletonVersion(key, scope[key].version, version, 1);",
"return get(scope[key]);"
"return getStrictSingletonVersion(scope, scopeName, key, version);"
]
)};`,
)});`,
"var installedModules = {};",
"var moduleToHandlerMapping = {",
Template.indent(

View File

@ -9,6 +9,7 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
const Module = require("../Module");
const RuntimeGlobals = require("../RuntimeGlobals");
const makeSerializable = require("../util/makeSerializable");
const { versionToString, stringifyHoley } = require("../util/semver");
const ProvideForSharedDependency = require("./ProvideForSharedDependency");
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
@ -50,7 +51,7 @@ class ProvideSharedModule extends Module {
*/
identifier() {
return `provide module (${this._shareScope}) ${this._name}@${
this._version && this._version.join(".")
this._version && versionToString(this._version)
} = ${this._request}`;
}
@ -60,7 +61,7 @@ class ProvideSharedModule extends Module {
*/
readableIdentifier(requestShortener) {
return `provide shared module (${this._shareScope}) ${this._name}@${
this._version && this._version.join(".")
this._version && versionToString(this._version)
} = ${requestShortener.shorten(this._request)}`;
}
@ -129,7 +130,7 @@ class ProvideSharedModule extends Module {
*/
codeGeneration({ runtimeTemplate, moduleGraph, chunkGraph }) {
const runtimeRequirements = new Set([RuntimeGlobals.initializeSharing]);
const code = `register(${JSON.stringify(this._name)}, ${JSON.stringify(
const code = `register(${JSON.stringify(this._name)}, ${stringifyHoley(
this._version || 0
)}, ${
this._eager

View File

@ -9,24 +9,25 @@ const validateOptions = require("schema-utils");
const schema = require("../../schemas/plugins/sharing/ProvideSharedPlugin.json");
const WebpackError = require("../WebpackError");
const { parseOptions } = require("../container/options");
const { parseVersion } = require("../util/semver");
const ProvideForSharedDependency = require("./ProvideForSharedDependency");
const ProvideSharedDependency = require("./ProvideSharedDependency");
const ProvideSharedModuleFactory = require("./ProvideSharedModuleFactory");
const { parseVersion } = require("./utils");
/** @typedef {import("../../declarations/plugins/sharing/ProvideSharedPlugin").ProvideSharedPluginOptions} ProvideSharedPluginOptions */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../util/semver").SemVerVersion} SemVerVersion */
/**
* @typedef {Object} ProvideOptions
* @property {string} shareKey
* @property {string} shareScope
* @property {(string|number)[] | undefined | false} version
* @property {SemVerVersion | undefined | false} version
* @property {boolean} eager
*/
/** @typedef {Map<string, { config: ProvideOptions, version: (string|number)[] | undefined | false }>} ResolvedProvideMap */
/** @typedef {Map<string, { config: ProvideOptions, version: SemVerVersion | undefined | false }>} ResolvedProvideMap */
class ProvideSharedPlugin {
/**

View File

@ -12,6 +12,7 @@ const {
compareModulesByIdentifier,
compareStrings
} = require("../util/comparators");
const { versionLtRuntimeCode } = require("../util/semver");
class ShareRuntimeModule extends RuntimeModule {
constructor() {
@ -25,7 +26,8 @@ class ShareRuntimeModule extends RuntimeModule {
const {
runtimeTemplate,
chunkGraph,
codeGenerationResults
codeGenerationResults,
outputOptions: { uniqueName }
} = this.compilation;
/** @type {Map<string, Map<number, Set<string>>>} */
const initCodePerScope = new Map();
@ -73,40 +75,15 @@ class ShareRuntimeModule extends RuntimeModule {
'typeof console !== "undefined" && console.warn && console.warn(msg);',
"msg"
)};`,
`var uniqueName = ${JSON.stringify(uniqueName || undefined)};`,
versionLtRuntimeCode(runtimeTemplate),
`var register = ${runtimeTemplate.basicFunction(
"name, version, factory, currentName",
"name, version, factory",
[
"version = version || [];",
"currentName = name;",
`var versionConflict = ${runtimeTemplate.returningFunction(
'warn("Version conflict for shared modules: " + name + " " + (v && v.join(".")) + " <=> " + (version && version.join(".")));'
)};`,
`var registerCurrent = ${runtimeTemplate.basicFunction("", [
"if(scope[currentName]) {",
Template.indent([
"var v = scope[currentName].version || [];",
"for(var i = 0; i < version.length && i < v.length; i++) {",
Template.indent([
"if(v[i] != version[i]) { // loose equal is intentional to match string and number",
Template.indent([
'if(typeof v[i] === "string" || typeof version[i] === "string") return versionConflict();',
"if(v[i] > version[i]) return;",
"if(v[i] < version[i]) { i = -1; break; }"
]),
"}"
]),
"}",
"if(i >= 0 && version.length <= v.length) return;",
'if(scope[currentName].loaded) return warn("Ignoring providing of already used shared module: " + name);'
]),
"}",
"scope[currentName] = { get: factory, version: version };"
])};`,
"registerCurrent();",
`version.forEach(${runtimeTemplate.basicFunction("part", [
'currentName += "`" + part;',
"registerCurrent();"
])});`
"var versions = scope[name] = scope[name] || {};",
"var activeVersion = versions[version];",
"if(!activeVersion || uniqueName > activeVersion.from) versions[version] = { get: factory, version: version, from: uniqueName };"
]
)};`,
`var initExternal = ${runtimeTemplate.basicFunction("id", [

View File

@ -9,105 +9,13 @@ const { join, dirname, readJson } = require("../util/fs");
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
/**
* @param {string} version version as string
* @returns {(number|string)[]} version as array
*/
exports.parseRequiredVersion = version => {
if (version === "*") return [];
let fuzzyStart = Infinity;
if (version.startsWith(">=")) {
fuzzyStart = 0;
version = version.slice(2);
} else if (version.startsWith("^")) {
fuzzyStart = 1;
version = version.slice(1);
} else if (version.startsWith("~")) {
fuzzyStart = 2;
version = version.slice(1);
}
return version
.split(".")
.map((x, i) => (i >= fuzzyStart && `${+x}` === x ? +x : x));
};
/**
* @param {string} version version as string
* @returns {(number|string)[]} version as array
*/
exports.parseVersion = version => {
return version.split(".").map(x => (`${+x}` === x ? +x : x));
};
/**
* @param {(number|string)[]} version version
* @returns {string} version as string
*/
exports.versionToString = version => {
if (!version) return "(unknown)";
if (version.length === 0) return "*";
const info = version.map(value =>
typeof value !== "string"
? {
type: "min",
value: `${value}`
}
: `${+value}` === value
? {
type: "exact",
value
}
: {
type: "tag",
value
}
);
switch (`${info[0].type}.${info.length > 1 ? info[1].type : "undefined"}`) {
case "exact.min":
case "tag.min":
if (!info.slice(2).some(i => i.type === "exact"))
return `^${version.join(".")}`;
break;
case "exact.exact":
case "exact.tag":
case "tag.exact":
case "tag.tag":
if (!info.slice(2).some(i => i.type === "exact"))
return `~${version.join(".")}`;
else if (!info.slice(2).some(i => i.type === "min"))
return version.join(".");
break;
case "min.min":
case "min.tag":
if (!info.slice(2).some(i => i.type === "exact"))
return `>=${version.join(".")}`;
break;
case "min.undefined":
return `>=${version.join(".")}`;
case "exact.undefined":
case "tag.undefined":
return version.join(".");
}
return info
.map(i => (i.type === "exact" ? i.value : `[>=${i.value}]`))
.join(".");
};
/**
* @param {string} str maybe required version
* @returns {boolean} true, if it looks like a version
*/
exports.isRequiredVersion = str => {
if (str === "*") return true;
if (/&&|\|\|/.test(str)) return false;
if (str.startsWith("^")) return true;
if (str.startsWith("~")) return true;
if (str.startsWith(">=")) return true;
return /^\d/.test(str);
return /^[\d^=<>~]/.test(str) || /\|\|/.test(str);
};
/**

483
lib/util/semver.js Normal file
View File

@ -0,0 +1,483 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
/** @typedef {(string|number|undefined|[])[]} SemVerRange */
/** @typedef {(string|number|undefined|[])[]} SemVerVersion */
const removeStars = arr => {
while (/^[Xx*]$/.test(arr[arr.length - 1])) arr.pop();
return arr;
};
/**
* @param {string} str version string
* @returns {SemVerVersion} parsed version
*/
const parseVersion = str => {
if (!str) return [];
const match = /^([^-+]+)(?:-([^+]+))?(?:\+(.+))?$/.exec(str);
const convertToNumber = item => (`${+item}` === item ? +item : item);
const version = removeStars(match[1].split(".").map(convertToNumber));
const prerelease = match[2]
? removeStars(match[2].split(".").map(convertToNumber))
: [];
const build = match[3] ? match[3].split(".").map(convertToNumber) : [];
if (prerelease.length) {
return build.length
? // eslint-disable-next-line no-sparse-arrays
[...version, , ...prerelease, [], ...build]
: // eslint-disable-next-line no-sparse-arrays
[...version, , ...prerelease];
} else {
// eslint-disable-next-line no-sparse-arrays
return build.length ? [...version, [], ...build] : version;
}
};
exports.parseVersion = parseVersion;
/* eslint-disable eqeqeq */
const versionToString = version => {
if (!version) return "[unknown]";
for (var str = "", needDot = 1, i = 0; i < version.length; i++) {
var item = version[i];
var t = (typeof item)[0];
needDot--;
str +=
t == "u"
? // undefined: prerelease marker, add an "-"
"-"
: t == "o"
? // object: build marker, add an "+"
"+"
: // number or string: add the item, set flag to add an "." between two of them
(needDot > 0 ? "." : "") + ((needDot = 2), item);
}
return str;
};
/* eslint-enable eqeqeq */
exports.versionToString = versionToString;
// must be a minimized version of above
exports.versionToStringRuntimeCode = runtimeTemplate =>
`var versionToString = ${runtimeTemplate.basicFunction("version", [
"// see webpack/lib/util/semver.js for original code",
'if(!version)return"[unknown]";for(var r="",n=1,o=0;o<version.length;o++){var e=version[o],t=(typeof e)[0];n--,r+="u"==t?"-":"o"==t?"+":(n>0?".":"")+(n=2,e)}return r'
])}`;
/* eslint-disable eqeqeq */
/**
* @param {SemVerVersion} a version
* @param {SemVerVersion} b version
* @returns {boolean} true, iff a < b
*/
const versionLt = (a, b) => {
var i = 0;
for (;;) {
// a b EOA object undefined number string
// EOA a == b a < b b < a a < b a < b
// object b < a (0) b < a a < b a < b
// undefined a < b a < b (0) a < b a < b
// number b < a b < a b < a (1) a < b
// string b < a b < a b < a b < a (1)
// EOA end of array
// (0) continue on
// (1) compare them via "<"
// Handles first row in table
if (i >= a.length) return i < b.length && (typeof b[i])[0] != "u";
var aValue = a[i];
var aType = (typeof aValue)[0];
// Handles first column in table
if (i >= b.length) return aType == "u";
var bValue = b[i];
var bType = (typeof bValue)[0];
if (aType == bType) {
if (aType != "o" && aType != "u" && aValue != bValue) {
return aValue < bValue;
}
i++;
} else {
// Handles remaining cases
if (aType == "o" && bType == "n") return true;
return bType == "s" || aType == "u";
}
}
};
/* eslint-enable eqeqeq */
exports.versionLt = versionLt;
// must be a minimized version of above
exports.versionLtRuntimeCode = runtimeTemplate =>
`var versionLt = ${runtimeTemplate.basicFunction("a, b", [
"// see webpack/lib/util/semver.js for original code",
'for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var t=a[r],e=(typeof t)[0];if(r>=b.length)return"u"==e;var n=b[r],f=(typeof n)[0];if(e!=f)return"o"==e&&"n"==f||("s"==f||"u"==e);if("o"!=e&&"u"!=e&&t!=n)return t<n;r++}'
])}`;
/**
* @param {string} str range string
* @returns {SemVerRange} parsed range
*/
exports.parseRange = str => {
// see https://docs.npmjs.com/misc/semver#range-grammar for grammar
const parsePartial = str => {
const v = parseVersion(str);
return [0, ...v];
};
const toFixed = range => {
if (range.length === 1) {
// Special case for "*" is "x.x.x" instead of "="
return [0];
} else if (range.length === 2) {
// Special case for "1" is "1.x.x" instead of "=1"
return [1, ...range.slice(1)];
} else if (range.length === 3) {
// Special case for "1.2" is "1.2.x" instead of "=1.2"
return [2, ...range.slice(1)];
} else {
return [range.length, ...range.slice(1)];
}
};
const negate = range => {
return [-range[0] - 1, ...range.slice(1)];
};
const parseSimple = str => {
// simple ::= primitive | partial | tilde | caret
// primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
// tilde ::= '~' partial
// caret ::= '^' partial
const match = /^(\^|~|<=|<|>=|>|=|v|!)/.exec(str);
const start = match ? match[0] : "";
const remainder = parsePartial(str.slice(start.length));
switch (start) {
case "^":
if (remainder.length > 1 && remainder[1] === 0) {
if (remainder.length > 2 && remainder[2] === 0) {
return [3, ...remainder.slice(1)];
}
return [2, ...remainder.slice(1)];
}
return [1, ...remainder.slice(1)];
case "~":
return [2, ...remainder.slice(1)];
case ">=":
return remainder;
case "=":
case "v":
case "":
return toFixed(remainder);
case "<":
return negate(remainder);
case ">": {
// and( >=, not( = ) ) => >=, =, not, and
const fixed = toFixed(remainder);
// eslint-disable-next-line no-sparse-arrays
return [, fixed, 0, remainder, 2];
}
case "<=":
// or( <, = ) => <, =, or
// eslint-disable-next-line no-sparse-arrays
return [, toFixed(remainder), negate(remainder), 1];
case "!": {
// not =
const fixed = toFixed(remainder);
// eslint-disable-next-line no-sparse-arrays
return [, fixed, 0];
}
default:
throw new Error("Unexpected start value");
}
};
const combine = (items, fn) => {
if (items.length === 1) return items[0];
const arr = [];
for (const item of items.slice().reverse()) {
if (0 in item) {
arr.push(item);
} else {
arr.push(...item.slice(1));
}
}
// eslint-disable-next-line no-sparse-arrays
return [, ...arr, ...items.slice(1).map(() => fn)];
};
const parseRange = str => {
// range ::= hyphen | simple ( ' ' simple ) * | ''
// hyphen ::= partial ' - ' partial
const items = str.split(" - ");
if (items.length === 1) {
const items = str.trim().split(/\s+/g).map(parseSimple);
return combine(items, 2);
}
const a = parsePartial(items[0]);
const b = parsePartial(items[1]);
// >=a <=b => and( >=a, or( <b, =b ) ) => >=a, <b, =b, or, and
// eslint-disable-next-line no-sparse-arrays
return [, toFixed(b), negate(b), 1, a, 2];
};
const parseLogicalOr = str => {
// range-set ::= range ( logical-or range ) *
// logical-or ::= ( ' ' ) * '||' ( ' ' ) *
const items = str.split(/\s*\|\|\s*/).map(parseRange);
return combine(items, 1);
};
return parseLogicalOr(str);
};
/* eslint-disable eqeqeq */
const rangeToString = range => {
if (0 in range) {
var str = "";
var fixCount = range[0];
str +=
fixCount == 0
? ">="
: fixCount == -1
? "<"
: fixCount == 1
? "^"
: fixCount == 2
? "~"
: fixCount > 0
? "="
: "!=";
var needDot = 1;
// eslint-disable-next-line no-redeclare
for (var i = 1; i < range.length; i++) {
var item = range[i];
var t = (typeof item)[0];
needDot--;
str +=
t == "u"
? // undefined: prerelease marker, add an "-"
"-"
: t == "o"
? // object: build marker, add an "+"
"+"
: // number or string: add the item, set flag to add an "." between two of them
(needDot > 0 ? "." : "") + ((needDot = 2), item);
}
return str;
} else {
var stack = [];
// eslint-disable-next-line no-redeclare
for (var i = 1; i < range.length; i++) {
// eslint-disable-next-line no-redeclare
var item = range[i];
stack.push(
item === 0
? "not(" + pop() + ")"
: item === 1
? "(" + pop() + " || " + pop() + ")"
: item === 2
? stack.pop() + " " + stack.pop()
: rangeToString(item)
);
}
return pop();
}
function pop() {
return stack.pop().replace(/^\((.+)\)$/, "$1");
}
};
/* eslint-enable eqeqeq */
exports.rangeToString = rangeToString;
// must be a minimized version of above
exports.rangeToStringRuntimeCode = runtimeTemplate =>
`var rangeToString = ${runtimeTemplate.basicFunction("range", [
"// see webpack/lib/util/semver.js for original code",
'if(0 in range){var r="",n=range[0];r+=0==n?">=":-1==n?"<":1==n?"^":2==n?"~":n>0?"=":"!=";for(var e=1,a=1;a<range.length;a++){var o=(typeof(t=range[a]))[0];e--,r+="u"==o?"-":"o"==o?"+":(e>0?".":"")+(e=2,t)}return r}var g=[];for(a=1;a<range.length;a++){var t=range[a];g.push(0===t?"not("+p()+")":1===t?"("+p()+" || "+p()+")":2===t?g.pop()+" "+g.pop():rangeToString(t))}return p();function p(){return g.pop().replace(/^\\((.+)\\)$/,"$1")}'
])}`;
/* eslint-disable eqeqeq */
/**
* @param {SemVerRange} range version range
* @param {SemVerVersion} version the version
* @returns {boolean} if version satisfy the range
*/
const satisfy = (range, version) => {
var i = 0; // index in version
var j = 1; // index in range
var isEqual = true;
if (0 in range) {
var fixCount = range[0];
// when negated is set it will set for < instead of >=
var negated = fixCount < 0;
if (negated) fixCount = -fixCount - 1;
for (;;) {
// cspell:word nequal nequ
// when isEqual = true:
// range version: EOA undefined object number string
// EOA equal block bigger big-ver big-ver
// undefined bigger next bigger big-ver big-ver
// object smaller block next big-ver big-ver
// number smaller block smaller cmp differ
// fixed number smaller block smaller cmp-fix differ
// string smaller block smaller differ cmp-fix
// when isEqual = false:
// range version: EOA undefined object number string
// EOA nequal block nequal next-ver next-ver
// undefined nequal block nequal next-ver next-ver
// object nequal block nequal next-ver next-ver
// number nequal block nequal next next
// fixed number nequal block nequal next next (this never happens)
// string nequal block nequal next next
// EOA end of array
// equal (version is equal range):
// when !negated: return true,
// when negated: return false
// bigger (version is bigger as range):
// when fixed: return false,
// when !negated: return true,
// when negated: return false,
// smaller (version is smaller as range):
// when !negated: return false,
// when negated: return true
// nequal (version is not equal range (> resp <)): return true
// block (version is in different prerelease area): return false
// differ (version is different from range (string vs. number)): return false
// next: continues to the next items
// next-ver: when fixed: return false, continues to the next item only for the version, sets isEqual=false
// big-ver: when fixed || negated: return false, continues to the next item only for the version, sets isEqual=false
// next-nequ: continues to the next items, sets isEqual=false
// cmp (negated === false): version < range => return false, version > range => next-nequ, else => next
// cmp (negated === true): version > range => return false, version < range => next-nequ, else => next
// cmp-fix: version == range => next, else => return false
var rangeType = j < range.length ? (typeof range[j])[0] : "";
// Handles first column in both tables
if (i >= version.length) {
// Handles nequal
if (!isEqual) return true;
// Handles bigger
if (rangeType == "u") return j > fixCount && !negated;
// Handles equal and smaller: (range === EOA) XOR negated
return (rangeType == "") != negated; // equal + smaller
}
var versionValue = version[i];
var versionType = (typeof versionValue)[0];
i++;
// Handles second column in both tables
if (versionType == "u") {
if (!isEqual || rangeType != "u") {
return false;
}
j++;
}
// switch between first and second table
else if (isEqual) {
if (rangeType != "s" && rangeType != "n") {
// Handles upper half of the remaining first table
if (versionType == "o") {
if (rangeType == "o") {
j++;
} else {
if (j <= fixCount) return false;
return !negated;
}
} else {
// Handles all "big-ver" cases in the first table
if (negated || j <= fixCount) return false;
isEqual = false;
}
} else if (versionType == "o") {
// Handle lower half of the 3rd column in the first table
if (j <= fixCount) return false;
return negated;
} else if (rangeType != versionType) {
// Handles all "differ" cases
return false;
} else if (rangeType == "s" || j <= fixCount) {
// Handles both remaining "cmp-fix" cases
if (versionValue == range[j]) {
j++;
} else {
return false;
}
} else {
// Handles "cmp" case
if (negated ? versionValue > range[j] : versionValue < range[j]) {
return false;
}
if (versionValue != range[j]) isEqual = false;
j++;
}
} else {
// Handle 3rd column in the second table
if (versionType == "o") {
return true;
}
if (rangeType == "s" || rangeType == "n") {
// Handles all "next" cases in the second table
j++;
} else {
// Handles all "next-ver" cases in the second table
isEqual = false;
}
}
}
}
/** @type {(boolean | number)[]} */
var stack = [];
for (i = 1; i < range.length; i++) {
var item = /** @type {SemVerRange | 0 | 1 | 2} */ (range[i]);
stack.push(
item == 1
? /** @type {number} */ (stack.pop()) |
/** @type {number} */ (stack.pop())
: item == 2
? /** @type {number} */ (stack.pop()) &
/** @type {number} */ (stack.pop())
: item
? satisfy(item, version)
: !stack.pop()
);
}
return !!stack[0];
};
/* eslint-enable eqeqeq */
exports.satisfy = satisfy;
// must be a minimized version of above
exports.satisfyRuntimeCode = runtimeTemplate =>
`var satisfy = ${runtimeTemplate.basicFunction("range, version", [
"// see webpack/lib/util/semver.js for original code",
'var r=0,e=1,n=!0;if(0 in range){var f=range[0],i=f<0;for(i&&(f=-f-1);;){var a=e<range.length?(typeof range[e])[0]:"";if(r>=version.length)return!n||("u"==a?e>f&&!i:""==a!=i);var o=version[r],t=(typeof o)[0];if(r++,"u"==t){if(!n||"u"!=a)return!1;e++}else if(n)if("s"!=a&&"n"!=a)if("o"==t){if("o"!=a)return!(e<=f)&&!i;e++}else{if(i||e<=f)return!1;n=!1}else{if("o"==t)return!(e<=f)&&i;if(a!=t)return!1;if("s"==a||e<=f){if(o!=range[e])return!1;e++}else{if(i?o>range[e]:o<range[e])return!1;o!=range[e]&&(n=!1),e++}}else{if("o"==t)return!0;"s"==a||"n"==a?e++:n=!1}}}var u=[];for(r=1;r<range.length;r++){var s=range[r];u.push(1==s?u.pop()|u.pop():2==s?u.pop()&u.pop():s?satisfy(s,version):!u.pop())}return!!u[0]'
])}`;
exports.stringifyHoley = json => {
switch (typeof json) {
case "undefined":
return "";
case "object":
if (Array.isArray(json)) {
let str = "[";
for (let i = 0; i < json.length; i++) {
if (i !== 0) str += ",";
str += this.stringifyHoley(json[i]);
}
str += "]";
return str;
} else {
return JSON.stringify(json);
}
default:
return JSON.stringify(json);
}
};

View File

@ -58,9 +58,6 @@
{
"description": "Version as string. Can be prefixed with '^' or '~' for minimum matches. Each part of the version should be separated by a dot '.'.",
"type": "string"
},
{
"$ref": "#/definitions/SharedVersionArray"
}
]
},
@ -92,9 +89,6 @@
{
"description": "Version as string. Each part of the version should be separated by a dot '.'.",
"type": "string"
},
{
"$ref": "#/definitions/SharedVersionArray"
}
]
}
@ -119,23 +113,6 @@
}
]
}
},
"SharedVersionArray": {
"description": "Version number as array. Numbers and strings are accepted. Strings are treated as tags, which only match exactly. Numbers can match higher numbers.",
"type": "array",
"items": {
"description": "An item of the version.",
"anyOf": [
{
"description": "Version number. It's assumed that the module is compatible with any higher version number.",
"type": "number"
},
{
"description": "Version tag. The module is only compatible with the exact matching version tag.",
"type": "string"
}
]
}
}
}
}

View File

@ -379,9 +379,6 @@
{
"description": "Version as string. Can be prefixed with '^' or '~' for minimum matches. Each part of the version should be separated by a dot '.'.",
"type": "string"
},
{
"$ref": "#/definitions/SharedVersionArray"
}
]
},
@ -413,9 +410,6 @@
{
"description": "Version as string. Each part of the version should be separated by a dot '.'.",
"type": "string"
},
{
"$ref": "#/definitions/SharedVersionArray"
}
]
}
@ -441,23 +435,6 @@
]
}
},
"SharedVersionArray": {
"description": "Version number as array. Numbers and strings are accepted. Strings are treated as tags, which only match exactly. Numbers can match higher numbers.",
"type": "array",
"items": {
"description": "An item of the version.",
"anyOf": [
{
"description": "Version number. It's assumed that the module is compatible with any higher version number.",
"type": "number"
},
{
"description": "Version tag. The module is only compatible with the exact matching version tag.",
"type": "string"
}
]
}
},
"UmdNamedDefine": {
"description": "If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.",
"type": "boolean"

View File

@ -58,9 +58,6 @@
{
"description": "Version as string. Can be prefixed with '^' or '~' for minimum matches. Each part of the version should be separated by a dot '.'.",
"type": "string"
},
{
"$ref": "#/definitions/SharedVersionArray"
}
]
},
@ -103,23 +100,6 @@
}
]
}
},
"SharedVersionArray": {
"description": "Version number as array. Numbers and strings are accepted. Strings are treated as tags, which only match exactly. Numbers can match higher numbers.",
"type": "array",
"items": {
"description": "An item of the version.",
"anyOf": [
{
"description": "Version number. It's assumed that the module is compatible with any higher version number.",
"type": "number"
},
{
"description": "Version tag. The module is only compatible with the exact matching version tag.",
"type": "string"
}
]
}
}
},
"title": "ConsumeSharedPluginOptions",

View File

@ -51,9 +51,6 @@
{
"description": "Version as string. Each part of the version should be separated by a dot '.'.",
"type": "string"
},
{
"$ref": "#/definitions/SharedVersionArray"
}
]
}
@ -78,23 +75,6 @@
}
]
}
},
"SharedVersionArray": {
"description": "Version number as array. Numbers and strings are accepted. Strings are treated as tags, which only match exactly. Numbers can match higher numbers.",
"type": "array",
"items": {
"description": "An item of the version.",
"anyOf": [
{
"description": "Version number. It's assumed that the module is compatible with any higher version number.",
"type": "number"
},
{
"description": "Version tag. The module is only compatible with the exact matching version tag.",
"type": "string"
}
]
}
}
},
"title": "ProvideSharedPluginOptions",

View File

@ -58,9 +58,6 @@
{
"description": "Version as string. Can be prefixed with '^' or '~' for minimum matches. Each part of the version should be separated by a dot '.'.",
"type": "string"
},
{
"$ref": "#/definitions/SharedVersionArray"
}
]
},
@ -92,9 +89,6 @@
{
"description": "Version as string. Each part of the version should be separated by a dot '.'.",
"type": "string"
},
{
"$ref": "#/definitions/SharedVersionArray"
}
]
}
@ -119,23 +113,6 @@
}
]
}
},
"SharedVersionArray": {
"description": "Version number as array. Numbers and strings are accepted. Strings are treated as tags, which only match exactly. Numbers can match higher numbers.",
"type": "array",
"items": {
"description": "An item of the version.",
"anyOf": [
{
"description": "Version number. It's assumed that the module is compatible with any higher version number.",
"type": "number"
},
{
"description": "Version tag. The module is only compatible with the exact matching version tag.",
"type": "string"
}
]
}
}
},
"title": "SharePluginOptions",

492
test/SemVer.unittest.js Normal file
View File

@ -0,0 +1,492 @@
"use strict";
const {
parseVersion,
versionToString,
versionLt,
parseRange,
rangeToString,
satisfy
} = require("../lib/util/semver");
describe("SemVer", () => {
it("should parseVersion correctly", () => {
expect(parseVersion("1")).toEqual([1]);
expect(parseVersion("1.2.3")).toEqual([1, 2, 3]);
expect(parseVersion("1.2.3.4.999")).toEqual([1, 2, 3, 4, 999]);
// eslint-disable-next-line no-sparse-arrays
expect(parseVersion("1.2.3-beta")).toEqual([1, 2, 3, , "beta"]);
// eslint-disable-next-line no-sparse-arrays
expect(parseVersion("1.2.3-beta.1.2")).toEqual([1, 2, 3, , "beta", 1, 2]);
// eslint-disable-next-line no-sparse-arrays
expect(parseVersion("1.2.3-alpha.beta-42")).toEqual([
1,
2,
3,
,
"alpha",
"beta-42"
]);
// eslint-disable-next-line no-sparse-arrays
expect(parseVersion("1.2.3-beta.1.alpha.0+5343")).toEqual([
1,
2,
3,
,
"beta",
1,
"alpha",
0,
[],
5343
]);
expect(parseVersion("1.2.3+5343.beta+1")).toEqual([
1,
2,
3,
[],
5343,
"beta+1"
]);
expect(parseVersion("1.2.3+5343.beta+1")).toEqual([
1,
2,
3,
[],
5343,
"beta+1"
]);
});
describe("versionToString", () => {
const cases = [
"0.0.0",
"0.0.1",
"0.1.2",
"1.2.3",
"1.0.0",
"1.2.3.4.5.6.7.8",
"1.2",
"1",
"1.2.3-beta",
"1.2.3-beta.15",
"1.2.3-beta.15+45",
"1.2.3-beta.15+45.67",
"1.2.3+45",
"1.2.3+45.67",
"1.2.3-beta-gamma-test+x+y+z"
];
for (const key of cases) {
it(`should ${key} stringify correctly`, () => {
expect(versionToString(parseVersion(key))).toEqual(key);
});
}
});
describe("versionLt", () => {
const cases = [
"1 < 2",
"99 < 100",
"1 < 1.2",
"1 < 1.2.3",
"1.2 < 1.2.3",
"1.2.2 < 1.2.3",
"1.1.3 < 1.2.0",
"1.1.3 < 2.0.0",
"1.1.3 < 2",
"1.1.3 < 2.0",
"1.2.3 < 1.2.3+0",
"1.2.3+23 < 1.2.3+123",
"1.2+2 < 1.2.3+1",
"1.2.3-beta < 1.2.3",
"1.2.3 < 1.2.4-beta",
"1.2.3 < 1.3.0-beta",
"1.2.3 < 2.0.0-beta",
"1.2.3-alpha < 1.2.3-beta",
"1.2.3-beta < 1.2.3.1",
"1.2.3-beta < 1.2.3-beta.0",
"1.2.3-beta.0 < 1.2.3-beta.1",
"1.2.3-0 < 1.2.3-beta",
"1.2.3-beta < 1.2.3-beta+123",
"1.2.3-beta+123 < 1.2.3-beta+234",
"1.2.3-beta+99 < 1.2.3-beta+111"
];
for (const c of cases) {
it(c, () => {
const parts = c.split(" < ");
const a = parseVersion(parts[0]);
const b = parseVersion(parts[1]);
expect(versionLt(a, a)).toBe(false);
expect(versionLt(b, b)).toBe(false);
expect(versionLt(a, b)).toBe(true);
expect(versionLt(b, a)).toBe(false);
});
}
});
describe("parseRange", () => {
const cases = {
"=3": ["3", "v3", "3.x", "3.X", "3.x.x", "3.*", "3.*.*", "^3", "^3.x"],
"=3.0": ["3.0", "v3.0", "3.0.x", "3.0.X", "3.0.*", "~3.0"],
"^3.4": ["^3.4.*"],
"3.4 - 6.5": [">=3.4 <=6.5"],
"<=3.4": ["<3.4 || =3.4"],
">3.4": [">=3.4 !3.4"]
};
for (const key of Object.keys(cases)) {
describe(key, () => {
for (const c of cases[key])
it(`should be equal ${c}`, () => {
expect(parseRange(c)).toEqual(parseRange(key));
});
});
}
});
describe("rangeToString", () => {
const cases = {
"1": "^1",
"1.2": "~1.2",
"1.2.3": "=1.2.3",
"^1.2.3": "^1.2.3",
"~1.2.3": "~1.2.3",
"0.0.1": "=0.0.1",
"^0.0.1": "=0.0.1",
"^0.1.2": "~0.1.2",
"~0.0.1": "~0.0.1",
"~0.1.2": "~0.1.2",
">=1.2.3": ">=1.2.3",
"1.2.3-beta.25": "=1.2.3-beta.25",
"1.2.3-beta.25+12.34": "=1.2.3-beta.25+12.34",
"1.2.3+12.34": "=1.2.3+12.34",
">=1.2.3-beta.25": ">=1.2.3-beta.25",
">=1.2.3-beta.25+12.34": ">=1.2.3-beta.25+12.34",
">=1.2.3+12.34": ">=1.2.3+12.34",
"<1.2.3-beta.25": "<1.2.3-beta.25",
"<1.2.3-beta.25+12.34": "<1.2.3-beta.25+12.34",
"<1.2.3+12.34": "<1.2.3+12.34",
"1.2.3 - 3.2.1": ">=1.2.3 (<3.2.1 || =3.2.1)",
">3.4": ">=3.4 not(~3.4)",
"1 || 2 || 3": "^1 || ^2 || ^3",
"1.2.3 - 3.2.1 || >3 <=4 || 1":
">=1.2.3 (<3.2.1 || =3.2.1) || >=3 not(^3) (<4 || ^4) || ^1"
};
for (const key of Object.keys(cases)) {
const expected = cases[key];
it(`should ${key} stringify to ${expected}`, () => {
expect(rangeToString(parseRange(key))).toEqual(expected);
});
}
});
describe("satisfies", () => {
const cases = {
// table cases
">=1": [
"1",
"2",
"!1-beta",
"!2-beta",
"1.2",
"!1.2-beta",
"2.2",
"!2.2-beta",
"1.beta",
"!1.beta-beta",
"!2.beta-beta"
],
">=1-beta": [
"1",
"2",
"1-beta",
"!1-gamma",
"!1-alpha",
"!2-beta",
"1.2",
"!1.2-beta",
"2.2",
"!2.2-beta",
"1.beta",
"!1.beta-beta",
"2.beta",
"!2.beta-beta"
],
">=1.2": [
"!1",
"2",
"!1-beta",
"!2-beta",
"!1.1",
"1.2",
"1.3",
"2.1",
"2.2",
"2.3",
"!1.beta",
"2.beta"
],
"~1.2": [
"!1",
"!2",
"!10",
"!1-beta",
"!2-beta",
"!1.1",
"1.2",
"!1.3",
"!1.20"
],
">=1.beta": [
"!1",
"2",
"!1-beta",
"!2-beta",
"!1.2",
"2.2",
"!1.alpha",
"1.beta",
"!1.gamma",
"2.beta"
],
// fixed cases
"2": [
"2",
"2.0.0",
"2.99.99",
"!2.3.4-beta",
"!2.3.4-beta.1",
"!2.3.4-beta+123",
"2.3.4+123",
"!1",
"!1.2.3",
"!3",
"!3.4.5"
],
"1.2.3-beta.1.2+33.44": [
"1.2.3-beta.1.2+33.44",
"!1.2.3-beta.1.2+33.44.55",
"!1.2.3-beta.1.2.3+33.44",
"!1.2.3.4-beta.1.2+33.44",
"!1.2.3-beta.1.2+33",
"!1.2.3-beta.1.2",
"!1.2.3-beta",
"!1.2-beta.1.2+33.44",
"!1.2.3+33.44",
"!1.2.3",
"!1"
],
"1.2.3+33.44": [
"1.2.3+33.44",
"!1.2.4+33.44",
"!1.2.3+33.55",
"!1.2.3-beta+33.44",
"!1.2.3+33.44.55",
"!1.2.3+33",
"!1.2+33.44",
"!1.2.3.4+33.44",
"!1.2.3",
"!1.2.4",
"!1.3",
"!1",
"!2"
],
"1.2.3-beta.1.2": [
"1.2.3-beta.1.2",
"!1.2.3-beta.1.2+33",
"!1.2.3-beta.1.2.3",
"!1.2.3.4-beta.1.2",
"!1.2.3-beta",
"!1.2-beta.1.2",
"!1.2.3+33",
"!1.2.3",
"!1"
],
"^2.3.4": [
"2.3.4",
"2.3.5",
"2.4.0",
"!3.3.4",
"!1.5.6",
"!2.3.3",
"!2.3.4-beta",
"!2.3.5-beta",
"2.3.4.test",
"!2.3.test",
"2.3.4+33",
"2.3.5+33",
"2.4.0+33",
"2.3.4.5"
],
"~2.3.4": [
"2.3.4",
"2.3.5",
"!2.4.0",
"!3.3.4",
"!1.5.6",
"!2.3.3",
"!2.3.4-beta",
"!2.3.5-beta",
"2.3.4.test",
"!2.3.test",
"2.3.4+33",
"2.3.5+33",
"!2.4.0+33",
"2.3.4.5"
],
"!2.3": [
"!2.3",
"!2.3.4",
"2.2",
"2.2.2",
"2.4",
"2.4.4",
"2.3-beta",
"2.3.4-beta"
],
"<2.3": [
"!2.3",
"!2.3.4",
"2",
"2.2",
"2.2.1",
"1.5",
"0.1",
"!2.2-beta",
"!2.3-beta"
],
"<4.5-beta.14": [
"4.5-beta.13",
"!4.5-beta.14",
"!4.5-beta.15",
"!4.5-beta.14.1",
"4.5-beta.13.1",
"4.5-beta.13+15",
"!4.5-beta.14+15",
"!4.5-alpha",
"!4.5-gamma"
],
"2.3 - 4.5": [
"2.3",
"2.4",
"!2.3-beta",
"4.5",
"3.0.0",
"!3.5.7-beta.1",
"4.4",
"4.5",
"4.5.1",
"!4.5.2-beta",
"4.5+123"
],
">7.8-beta.4": [
"!7.8-beta.3",
"!7.8-beta.4",
"7.8-beta.4+55",
"7.8-beta.4.1",
"7.8-beta.5",
"7.8-beta.5.1",
"!7.8-gamma",
"7.8",
"7.8.0",
"7.8.1",
"7.9",
"8.1",
"10"
],
"^0.0.3": [
"!0.0.2",
"0.0.3",
"!0.0.4",
"!0.1.0",
"!0.1.3",
"!1.1.3",
"!1.0.0"
],
"^0.3.3": [
"!0.0.3",
"!0.3.2",
"0.3.3",
"0.3.4",
"!0.4.0",
"!0.4.3",
"!0.5.10",
"!1.0.0",
"!1.3.3"
],
">=1.0.0+42": [
"1.0.0+42",
"!1.0+42",
"!1.0+43",
"1.0.0+43",
"!1.0.0+5",
"1.0.0+100",
"2.0.0+10",
"!1.0.0",
"!1.0.0-beta"
],
"<1.0.0+42": [
"!1.0.0+42",
"!1.0.0+43",
"1.0.0+9",
"1.0.0+5",
"!1.0.0+100",
"!2.0.0+10",
"1.0.0",
"0.5.0",
"!1.0.0-beta"
],
"=1.0.0+42": [
"1.0.0+42",
"!1.0+42",
"!1.0.0+43",
"!1.0.0+9",
"!1.0.0+5",
"!1.0.0+100",
"!2.0.0+10",
"!1.0.0",
"!0.5.0",
"!1.0.0-beta"
],
"!1.0.0+42": [
"!1.0.0+42",
"1.0.0+43",
"1.0.0+9",
"1.0.0+5",
"1.0.0+100",
"2.0.0+10",
"1.0.0",
"0.5.0",
"1.0.0-beta"
],
"*": [
"0.0.0",
"0.0.1",
"0.1.0",
"1.0.0",
"!1.0.0-beta",
"!1.0.0-beta.1",
"1.0.0+55"
]
};
for (const name of Object.keys(cases)) {
describe(name, () => {
it(`should be able to parse ${name}`, () => {
parseRange(name);
});
for (const item of cases[name]) {
if (item.startsWith("!")) {
it(`should not be satisfied by ${item.slice(1)}`, () => {
expect(
satisfy(parseRange(name), parseVersion(item.slice(1)))
).toBe(false);
});
} else {
it(`should be satisfied by ${item}`, () => {
expect(satisfy(parseRange(name), parseVersion(item))).toBe(true);
});
}
}
});
}
});
});

View File

@ -30,7 +30,7 @@ const expectWarning = regexp => {
it("should load the component from container", () => {
return import("./App").then(({ default: App }) => {
expectWarning(
/Unsatisfied version of shared singleton module react@8 \(required react@2\)/
/Unsatisfied version 8 of shared singleton module react \(required \^2\)/
);
const rendered = App();
expect(rendered).toBe(

View File

@ -4,15 +4,17 @@ it("should expose modules from the container", async () => {
expect(container.init).toBeTypeOf("function");
container.init({
value: {
get: () =>
new Promise(resolve => {
setTimeout(() => {
resolve(() => ({
__esModule: true,
default: "overridden-value"
}));
}, 100);
})
"": {
get: () =>
new Promise(resolve => {
setTimeout(() => {
resolve(() => ({
__esModule: true,
default: "overridden-value"
}));
}, 100);
})
}
}
});
const testFactory = await container.get("./test");

View File

@ -3,7 +3,7 @@ module.exports = {
let ss;
scope.ABC = {
async get(module) {
const testFactory = await ss.test.get();
const testFactory = await ss.test[Object.keys(ss.test)[0]].get();
const test = testFactory();
return () => {
return test(module);

View File

@ -30,49 +30,69 @@ const expectWarning = regexp => {
it("should load the shared modules", async () => {
__webpack_share_scopes__["test-scope"] = {
package: {
get: () => () => "shared package"
"": {
get: () => () => "shared package"
}
},
"@scoped/package": {
get: () => Promise.resolve(() => "shared @scoped/package")
"": {
get: () => Promise.resolve(() => "shared @scoped/package")
}
},
"prefix/a": {
get: () => () => "shared prefix/a"
"": {
get: () => () => "shared prefix/a"
}
},
"prefix/deep/c": {
get: () => () => "shared prefix/deep/c"
"": {
get: () => () => "shared prefix/deep/c"
}
},
"./relative1": {
get: () => () => "shared relative1"
"": {
get: () => () => "shared relative1"
}
}
};
__webpack_share_scopes__["other-scope"] = {
"advanced/123": {
get: () => () => "123",
version: [1, 3, "0-beta", 1]
"1,2,0-beta,1": {
get: () => () => "123",
version: [1, 3, "0-beta", 1]
}
},
"advanced/error1": {
get: () => {
throw new Error("error1");
},
version: [1, 2, 3]
"1,2,3": {
get: () => {
throw new Error("error1");
},
version: [1, 2, 3]
}
},
"advanced/error2": {
get: () =>
Promise.resolve().then(() => {
throw new Error("error2");
}),
version: [1, 2, 3]
"1,2,3": {
get: () =>
Promise.resolve().then(() => {
throw new Error("error2");
}),
version: [1, 2, 3]
}
},
"advanced/error3": {
get: () =>
Promise.resolve().then(() => () => {
throw new Error("error3");
}),
version: [1, 2, 3]
"1,2,3": {
get: () =>
Promise.resolve().then(() => () => {
throw new Error("error3");
}),
version: [1, 2, 3]
}
},
"advanced/error4": {
get: () => () => "wrong",
version: [1, 0, 0]
"1,0,0": {
get: () => () => "wrong",
version: [1, 0, 0]
}
}
};
{
@ -147,32 +167,46 @@ it("should load the shared modules", async () => {
it("should handle version matching correctly in strict and singleton mode", async () => {
__webpack_share_scopes__["default"] = {
strict0: {
get: () => () => "shared strict0",
version: [1, 1, 1]
"1,1,1": {
get: () => () => "shared strict0",
version: [1, 1, 1]
}
},
strict1: {
get: () => () => "shared strict1",
version: [1, 1, 1]
"1,1,1": {
get: () => () => "shared strict1",
version: [1, 1, 1]
}
},
strict2: {
get: () => () => "shared strict2",
version: [1, 1, 1]
"1,1,1": {
get: () => () => "shared strict2",
version: [1, 1, 1]
}
},
strict3: {
get: () => () => "shared strict3",
version: [1, 1, 1]
"1,1,1": {
get: () => () => "shared strict3",
version: [1, 1, 1]
}
},
strict4: {
get: () => () => "shared strict4",
version: [1, 1, 1]
"1,1,1": {
get: () => () => "shared strict4",
version: [1, 1, 1]
}
},
strict5: {
get: () => () => "shared strict5",
version: [1, 1, 1]
"1,1,1": {
get: () => () => "shared strict5",
version: [1, 1, 1]
}
},
singleton: {
get: () => () => "shared singleton",
version: [1, 1, 1]
"1,1,1": {
get: () => () => "shared singleton",
version: [1, 1, 1]
}
}
};
{
@ -183,22 +217,18 @@ it("should handle version matching correctly in strict and singleton mode", asyn
{
const result = await import("strict1");
expect(result.default).toBe("strict");
expectWarning(/strict1@1\.1\.1 \(required strict1@1\.2\.0\)/);
}
{
const result = await import("strict2");
expect(result.default).toBe("strict");
expectWarning(/strict2@1\.1\.1 \(required strict2@1\.1\.0\)/);
}
{
const result = await import("strict3");
expect(result.default).toBe("strict");
expectWarning(/strict3@1\.1\.1 \(required strict3@1\.0\.0\)/);
}
{
const result = await import("strict4");
expect(result.default).toBe("strict");
expectWarning(/strict4@1\.1\.1 \(required strict4@2\.2\.3\)/);
}
{
await expect(() => import("strict5")).rejects.toEqual(
@ -211,6 +241,8 @@ it("should handle version matching correctly in strict and singleton mode", asyn
{
const result = await import("singleton");
expect(result.default).toBe("shared singleton");
expectWarning(/singleton@1\.1\.1 \(required singleton@1\.1\.0\)/);
expectWarning(
/Unsatisfied version 1\.1\.1 of shared singleton module singleton \(required =1\.1\.0\)/
);
}
});

View File

@ -52,6 +52,7 @@ module.exports = {
},
singleton: {
requiredVersion: "1.1.0",
singleton: true,
strictVersion: false
}
}

View File

@ -30,48 +30,58 @@ const expectWarning = regexp => {
it("should be able to consume different shared module version depending on context", async () => {
__webpack_share_scopes__["default"] = {
shared: {
get: () => () => "shared@9.9.9",
version: [9, 9, 9]
},
"shared`1": {
get: () => () => "shared@1.9.9",
version: [1, 9, 9]
},
"shared`1`2": {
get: () => () => "shared@1.2.9",
version: [1, 2, 9]
},
"shared`1`2`3": {
get: () => () => "shared@1.2.3",
version: [1, 2, 3]
},
"shared`2": {
get: () => () => "shared@2.9.9",
version: [2, 9, 9]
},
"shared`2`3": {
get: () => () => "shared@2.3.9",
version: [2, 3, 9]
},
"shared`2`3`4": {
get: () => () => "shared@2.3.4",
version: [2, 3, 4]
},
"shared`3": {
get: () => () => "shared@3.0.0",
version: [3, 0, 0]
"9,9,9": {
get: () => () => "shared@9.9.9",
version: [9, 9, 9]
},
"1,9,9": {
get: () => () => "shared@1.9.9",
version: [1, 9, 9]
},
"1,2,9": {
get: () => () => "shared@1.2.9",
version: [1, 2, 9]
},
"1,2,3": {
get: () => () => "shared@1.2.3",
version: [1, 2, 3],
from: "mfe1"
},
"2,9,9": {
get: () => () => "shared@2.9.9",
version: [2, 9, 9]
},
"2,3,9": {
get: () => () => "shared@2.3.9",
version: [2, 3, 9]
},
"2,3,4": {
get: () => () => "shared@2.3.4",
version: [2, 3, 4]
},
"3,0,0": {
get: () => () => "shared@3.0.0",
version: [3, 0, 0]
}
},
shared2: {
get: () => () => "shared2@9.9.9",
version: [9, 9, 9]
"9,9,9": {
get: () => () => "shared2@9.9.9",
version: [9, 9, 9]
}
}
};
expect(require("shared")).toBe("shared@1.9.9");
expect(require("my-module")).toBe("shared@2.9.9");
expect(require("my-module2")).toBe("shared@2.3.9");
expect(() => require("my-module3")).toThrowError(
"Unsatisfied version of shared module shared@3.0.0 (required shared@3.4.5)"
"No satisfying version (^3.4.5) of shared module shared found in shared scope default.\n" +
"Available versions: 9.9.9 from undefined, 1.9.9 from undefined, 1.2.9 from undefined, 1.2.3 from mfe1, 2.9.9 from undefined, 2.3.9 from undefined, 2.3.4 from undefined, 3.0.0 from undefined"
);
expect(require("my-module4")).toBe("shared@9.9.9");
expectWarning();
expect(require("shared2")).toBe("shared2@9.9.9");
expectWarning(
/No satisfying version \(=1\.2\.3 =3\.2\.1\) of shared module shared2 found in shared scope default/
);
});

View File

@ -1,6 +1,6 @@
{
"dependencies": {
"shared2": "1.2.3 && 3.2.1"
"shared2": "1.2.3 3.2.1"
},
"peerDependencies": {
"shared": "^1.0.0"

View File

@ -1,5 +0,0 @@
module.exports = [
[
/Required version in description file \("1\.2\.3 && 3\.2\.1"\) is unsupported/
]
];

View File

@ -19,23 +19,35 @@ it("should add provided modules to the share scope on init", async () => {
expect(Object.keys(__webpack_share_scopes__["test-scope"])).toContain(
"package"
);
expect(
Object.keys(__webpack_share_scopes__["test-scope"]["package"])
).toContain("1,0,0");
expect(Object.keys(__webpack_share_scopes__["test-scope"])).toContain(
"./test1"
);
expect(
Object.keys(__webpack_share_scopes__["test-scope"]["./test1"])
).toContain("");
expect(Object.keys(__webpack_share_scopes__["other-scope"])).toContain(
"test2"
);
const test2Versions = Object.keys(
__webpack_share_scopes__["other-scope"]["test2"]
);
expect(test2Versions).toContain("1,3,0");
expect(test2Versions).toContain("1,1,9");
expect(test2Versions).toContain("1,2,3");
{
const factory = await __webpack_share_scopes__["test-scope"][
"./test1"
const factory = await __webpack_share_scopes__["test-scope"]["./test1"][
""
].get();
expect(factory()).toBe("test1");
}
{
const factory = await __webpack_share_scopes__["other-scope"][
"test2"
const factory = await __webpack_share_scopes__["other-scope"]["test2"][
"1,3,0"
].get();
expect(factory()).toBe("test2");
}

View File

@ -26,7 +26,7 @@ module.exports = {
provides: {
"./test2": {
shareKey: "test2",
version: [1, 3, 0]
version: "1.3.0"
}
}
}),
@ -35,7 +35,7 @@ module.exports = {
"./test2-wrong": {
shareKey: "test2",
shareScope: "other-scope",
version: [1, 1, 9]
version: "1.1.9"
}
}
})

View File

@ -1,10 +1,31 @@
import "shared";
import "my-module";
import { version } from "shared";
import { version as innerVersion } from "my-module";
it("should provide both shared versions, but not the unused one", async () => {
await __webpack_init_sharing__("default");
expect(Object.keys(__webpack_share_scopes__.default)).toContain("shared`1");
expect(Object.keys(__webpack_share_scopes__.default)).toContain("shared`2");
expect(Object.keys(__webpack_share_scopes__.default)).toContain("shared");
expect(__webpack_share_scopes__.default.shared.version).toEqual([2, 0, 0]);
expect(Object.keys(__webpack_share_scopes__.default.shared)).toContain(
"1,0,0"
);
expect(Object.keys(__webpack_share_scopes__.default.shared)).toContain(
"2,0,0"
);
expect(Object.keys(__webpack_share_scopes__.default.shared)).not.toContain(
"3,0,0"
);
expect(__webpack_share_scopes__.default.shared["1,0,0"].version).toEqual([
1,
0,
0
]);
expect(__webpack_share_scopes__.default.shared["2,0,0"].version).toEqual([
2,
0,
0
]);
});
it("should import the correct versions", () => {
expect(version).toBe("1.0.0");
expect(innerVersion).toBe("2.0.0");
});

8
types.d.ts vendored
View File

@ -1599,7 +1599,7 @@ declare interface ConsumesConfig {
/**
* Version requirement from module in share scope.
*/
requiredVersion?: string | false | (string | number)[];
requiredVersion?: DevTool;
/**
* Module is looked up under this key from the share scope.
@ -5561,7 +5561,7 @@ declare interface ProvidesConfig {
/**
* Version of the provided module. Will replace lower matching versions, but not higher.
*/
version?: string | false | (string | number)[];
version?: DevTool;
}
/**
@ -7079,7 +7079,7 @@ declare interface SharedConfig {
/**
* Version requirement from module in share scope.
*/
requiredVersion?: string | false | (string | number)[];
requiredVersion?: DevTool;
/**
* Module is looked up under this key from the share scope.
@ -7104,7 +7104,7 @@ declare interface SharedConfig {
/**
* Version of the provided module. Will replace lower matching versions, but not higher.
*/
version?: string | false | (string | number)[];
version?: DevTool;
}
/**