@module-federation/enhanced 0.0.4-0 → 0.2.0-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/package.json +2 -4
  2. package/src/index.js +12 -12
  3. package/src/index.js.map +1 -1
  4. package/src/lib/Constants.js +33 -33
  5. package/src/lib/Constants.js.map +1 -1
  6. package/src/lib/container/AsyncBoundaryPlugin.d.ts +11 -43
  7. package/src/lib/container/AsyncBoundaryPlugin.js +76 -86
  8. package/src/lib/container/AsyncBoundaryPlugin.js.map +1 -1
  9. package/src/lib/container/ContainerEntryModule.js +3 -1
  10. package/src/lib/container/ContainerEntryModule.js.map +1 -1
  11. package/src/lib/container/ContainerEntryModuleFactory.js +2 -1
  12. package/src/lib/container/ContainerEntryModuleFactory.js.map +1 -1
  13. package/src/lib/container/ContainerReferencePlugin.js +3 -1
  14. package/src/lib/container/ContainerReferencePlugin.js.map +1 -1
  15. package/src/lib/container/FallbackModuleFactory.js +2 -1
  16. package/src/lib/container/FallbackModuleFactory.js.map +1 -1
  17. package/src/lib/container/ModuleFederationPlugin.js +1 -1
  18. package/src/lib/container/ModuleFederationPlugin.js.map +1 -1
  19. package/src/lib/sharing/ConsumeSharedModule.js +3 -1
  20. package/src/lib/sharing/ConsumeSharedModule.js.map +1 -1
  21. package/src/lib/sharing/ConsumeSharedPlugin.js +3 -1
  22. package/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -1
  23. package/src/lib/sharing/ConsumeSharedRuntimeModule.js +3 -1
  24. package/src/lib/sharing/ConsumeSharedRuntimeModule.js.map +1 -1
  25. package/src/lib/sharing/ProvideSharedModule.js +3 -1
  26. package/src/lib/sharing/ProvideSharedModule.js.map +1 -1
  27. package/src/lib/sharing/ShareRuntimeModule.js +3 -1
  28. package/src/lib/sharing/ShareRuntimeModule.js.map +1 -1
  29. package/src/lib/sharing/utils.js +6 -6
  30. package/src/lib/sharing/utils.js.map +1 -1
  31. package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
  32. package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js +34 -0
  33. package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
  34. package/src/schemas/container/ModuleFederationPlugin.check.d.ts +10 -0
  35. package/CHANGELOG.md +0 -120
  36. package/README.md +0 -11
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ShareRuntimeModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\n\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport RuntimeModule from 'webpack/lib/RuntimeModule';\nimport Template from 'webpack/lib/Template';\nimport Compilation from 'webpack/lib/Compilation';\nimport ChunkGraph from 'webpack/lib/ChunkGraph';\nimport {\n compareModulesByIdentifier,\n compareStrings,\n} from 'webpack/lib/util/comparators';\n\nclass ShareRuntimeModule extends RuntimeModule {\n constructor() {\n super('sharing');\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate(): string | null {\n const compilation: Compilation | undefined = this.compilation;\n if (!compilation) {\n throw new Error('Compilation is undefined');\n }\n const {\n runtimeTemplate,\n codeGenerationResults,\n outputOptions: { uniqueName, ignoreBrowserWarnings },\n } = compilation;\n const chunkGraph: ChunkGraph | undefined = this.chunkGraph;\n if (!chunkGraph) {\n throw new Error('ChunkGraph is undefined');\n }\n const initCodePerScope: Map<string, Map<number, Set<string>>> = new Map();\n for (const chunk of this.chunk?.getAllReferencedChunks() || []) {\n if (!chunk) {\n continue;\n }\n const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(\n chunk,\n 'share-init',\n compareModulesByIdentifier,\n );\n if (!modules) continue;\n for (const m of modules) {\n const data = codeGenerationResults.getData(\n m,\n chunk.runtime,\n 'share-init',\n );\n if (!data) continue;\n for (const item of data) {\n const { shareScope, initStage, init } = item;\n let stages = initCodePerScope.get(shareScope);\n if (stages === undefined) {\n initCodePerScope.set(shareScope, (stages = new Map()));\n }\n let list = stages.get(initStage || 0);\n if (list === undefined) {\n stages.set(initStage || 0, (list = new Set()));\n }\n list.add(init);\n }\n }\n }\n return Template.asString([\n `${RuntimeGlobals.shareScopeMap} = {};`,\n 'var initPromises = {};',\n 'var initTokens = {};',\n `${RuntimeGlobals.initializeSharing} = ${runtimeTemplate.basicFunction(\n 'name, initScope',\n [\n 'if(!initScope) initScope = [];',\n '// handling circular init calls',\n 'var initToken = initTokens[name];',\n 'if(!initToken) initToken = initTokens[name] = {};',\n 'if(initScope.indexOf(initToken) >= 0) return;',\n 'initScope.push(initToken);',\n '// only runs once',\n 'if(initPromises[name]) return initPromises[name];',\n '// creates a new share scope if needed',\n `if(!${RuntimeGlobals.hasOwnProperty}(${RuntimeGlobals.shareScopeMap}, name)) ${RuntimeGlobals.shareScopeMap}[name] = {};`,\n '// runs all init snippets from all modules reachable',\n `var scope = ${RuntimeGlobals.shareScopeMap}[name];`,\n `var warn = ${\n ignoreBrowserWarnings\n ? runtimeTemplate.basicFunction('', '')\n : runtimeTemplate.basicFunction('msg', [\n 'if (typeof console !== \"undefined\" && console.warn) console.warn(msg);',\n ])\n };`,\n `var uniqueName = ${JSON.stringify(uniqueName || undefined)};`,\n `var register = ${runtimeTemplate.basicFunction(\n 'name, version, factory, eager',\n [\n 'var versions = scope[name] = scope[name] || {};',\n 'var activeVersion = versions[version];',\n 'if(!activeVersion || (!activeVersion.loaded && (!eager != !activeVersion.eager ? eager : uniqueName > activeVersion.from))) versions[version] = { get: factory, from: uniqueName, eager: !!eager };',\n ],\n )};`,\n `var initExternal = ${runtimeTemplate.basicFunction('id', [\n `var handleError = ${runtimeTemplate.expressionFunction(\n 'warn(\"Initialization of sharing external failed: \" + err)',\n 'err',\n )};`,\n 'try {',\n Template.indent([\n `var module = ${RuntimeGlobals.require}(id);`,\n 'if(!module) return;',\n `var initFn = ${runtimeTemplate.returningFunction(\n `module && module.init && module.init(${RuntimeGlobals.shareScopeMap}[name], initScope)`,\n 'module',\n )}`,\n 'if(module.then) return promises.push(module.then(initFn, handleError));',\n 'var initResult = initFn(module);',\n \"if(initResult && initResult.then) return promises.push(initResult['catch'](handleError));\",\n ]),\n '} catch(err) { handleError(err); }',\n ])}`,\n 'var promises = [];',\n 'switch(name) {',\n ...Array.from(initCodePerScope)\n .sort(([a], [b]) => compareStrings(a, b))\n .map(([name, stages]) =>\n Template.indent([\n `case ${JSON.stringify(name)}: {`,\n Template.indent(\n Array.from(stages)\n .sort(([a], [b]) => a - b)\n .map(([, initCode]) =>\n Template.asString(Array.from(initCode)),\n ),\n ),\n '}',\n 'break;',\n ]),\n ),\n '}',\n 'if(!promises.length) return initPromises[name] = 1;',\n `return initPromises[name] = Promise.all(promises).then(${runtimeTemplate.returningFunction(\n 'initPromises[name] = 1',\n )});`,\n ],\n )};`,\n ]);\n }\n}\n\nexport default ShareRuntimeModule;\n"],"names":["ShareRuntimeModule","RuntimeModule","generate","compilation","Error","runtimeTemplate","codeGenerationResults","outputOptions","uniqueName","ignoreBrowserWarnings","chunkGraph","initCodePerScope","Map","chunk","getAllReferencedChunks","modules","getOrderedChunkModulesIterableBySourceType","compareModulesByIdentifier","m","data","getData","runtime","item","shareScope","initStage","init","stages","get","undefined","set","list","Set","add","Template","asString","RuntimeGlobals","shareScopeMap","initializeSharing","basicFunction","hasOwnProperty","JSON","stringify","expressionFunction","indent","require","returningFunction","Array","from","sort","a","b","compareStrings","map","name","initCode","constructor"],"mappings":"AAAA;;;AAGA,GAEA;;;;+BAqJA;;;eAAA;;;wEAnJgC;sEACN;iEACL;6BAMd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,IAAA,AAAMA,qBAAN,MAAMA,2BAA2BC,sBAAa;IAK5C;;GAEC,GACD,AAASC,WAA0B;YAeb;QAdpB,MAAMC,cAAuC,IAAI,CAACA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BACjCpB,iBAAQ,CAACU,MAAM,CACbG,MAAMC,IAAI,CAACrB,QACRsB,IAAI,CAAC,CAAC,CAACC,EAAE,EAAE,CAACC,EAAE,GAAKD,IAAIC,GACvBE,GAAG,CAAC,CAAC,GAAGE,SAAS,GAChBrB,iBAAQ,CAACC,QAAQ,CAACY,MAAMC,IAAI,CAACO;wBAGnC;wBACA;qBACD;gBAEL;gBACA;gBACA,CAAC,uDAAuD,EAAEjD,gBAAgBwC,iBAAiB,CACzF,0BACA,EAAE,CAAC;aACN,EACD,CAAC,CAAC;SACL;IACH;IArIAU,aAAc;QACZ,KAAK,CAAC;IACR;AAoIF;MAEA,WAAevD"}
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ShareRuntimeModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\n\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport RuntimeModule from 'webpack/lib/RuntimeModule';\nimport Template from 'webpack/lib/Template';\nimport Compilation from 'webpack/lib/Compilation';\nimport ChunkGraph from 'webpack/lib/ChunkGraph';\nimport {\n compareModulesByIdentifier,\n compareStrings,\n} from 'webpack/lib/util/comparators';\n\nclass ShareRuntimeModule extends RuntimeModule {\n constructor() {\n super('sharing');\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate(): string | null {\n const compilation: Compilation | undefined = this.compilation;\n if (!compilation) {\n throw new Error('Compilation is undefined');\n }\n const {\n runtimeTemplate,\n codeGenerationResults,\n outputOptions: { uniqueName, ignoreBrowserWarnings },\n } = compilation;\n const chunkGraph: ChunkGraph | undefined = this.chunkGraph;\n if (!chunkGraph) {\n throw new Error('ChunkGraph is undefined');\n }\n const initCodePerScope: Map<string, Map<number, Set<string>>> = new Map();\n for (const chunk of this.chunk?.getAllReferencedChunks() || []) {\n if (!chunk) {\n continue;\n }\n const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(\n chunk,\n 'share-init',\n compareModulesByIdentifier,\n );\n if (!modules) continue;\n for (const m of modules) {\n const data = codeGenerationResults.getData(\n m,\n chunk.runtime,\n 'share-init',\n );\n if (!data) continue;\n for (const item of data) {\n const { shareScope, initStage, init } = item;\n let stages = initCodePerScope.get(shareScope);\n if (stages === undefined) {\n initCodePerScope.set(shareScope, (stages = new Map()));\n }\n let list = stages.get(initStage || 0);\n if (list === undefined) {\n stages.set(initStage || 0, (list = new Set()));\n }\n list.add(init);\n }\n }\n }\n return Template.asString([\n `${RuntimeGlobals.shareScopeMap} = {};`,\n 'var initPromises = {};',\n 'var initTokens = {};',\n `${RuntimeGlobals.initializeSharing} = ${runtimeTemplate.basicFunction(\n 'name, initScope',\n [\n 'if(!initScope) initScope = [];',\n '// handling circular init calls',\n 'var initToken = initTokens[name];',\n 'if(!initToken) initToken = initTokens[name] = {};',\n 'if(initScope.indexOf(initToken) >= 0) return;',\n 'initScope.push(initToken);',\n '// only runs once',\n 'if(initPromises[name]) return initPromises[name];',\n '// creates a new share scope if needed',\n `if(!${RuntimeGlobals.hasOwnProperty}(${RuntimeGlobals.shareScopeMap}, name)) ${RuntimeGlobals.shareScopeMap}[name] = {};`,\n '// runs all init snippets from all modules reachable',\n `var scope = ${RuntimeGlobals.shareScopeMap}[name];`,\n `var warn = ${\n ignoreBrowserWarnings\n ? runtimeTemplate.basicFunction('', '')\n : runtimeTemplate.basicFunction('msg', [\n 'if (typeof console !== \"undefined\" && console.warn) console.warn(msg);',\n ])\n };`,\n `var uniqueName = ${JSON.stringify(uniqueName || undefined)};`,\n `var register = ${runtimeTemplate.basicFunction(\n 'name, version, factory, eager',\n [\n 'var versions = scope[name] = scope[name] || {};',\n 'var activeVersion = versions[version];',\n 'if(!activeVersion || (!activeVersion.loaded && (!eager != !activeVersion.eager ? eager : uniqueName > activeVersion.from))) versions[version] = { get: factory, from: uniqueName, eager: !!eager };',\n ],\n )};`,\n `var initExternal = ${runtimeTemplate.basicFunction('id', [\n `var handleError = ${runtimeTemplate.expressionFunction(\n 'warn(\"Initialization of sharing external failed: \" + err)',\n 'err',\n )};`,\n 'try {',\n Template.indent([\n `var module = ${RuntimeGlobals.require}(id);`,\n 'if(!module) return;',\n `var initFn = ${runtimeTemplate.returningFunction(\n `module && module.init && module.init(${RuntimeGlobals.shareScopeMap}[name], initScope)`,\n 'module',\n )}`,\n 'if(module.then) return promises.push(module.then(initFn, handleError));',\n 'var initResult = initFn(module);',\n \"if(initResult && initResult.then) return promises.push(initResult['catch'](handleError));\",\n ]),\n '} catch(err) { handleError(err); }',\n ])}`,\n 'var promises = [];',\n 'switch(name) {',\n ...Array.from(initCodePerScope)\n .sort(([a], [b]) => compareStrings(a, b))\n .map(([name, stages]) =>\n Template.indent([\n `case ${JSON.stringify(name)}: {`,\n Template.indent(\n Array.from(stages)\n .sort(([a], [b]) => a - b)\n .map(([, initCode]) =>\n Template.asString(Array.from(initCode)),\n ),\n ),\n '}',\n 'break;',\n ]),\n ),\n '}',\n 'if(!promises.length) return initPromises[name] = 1;',\n `return initPromises[name] = Promise.all(promises).then(${runtimeTemplate.returningFunction(\n 'initPromises[name] = 1',\n )});`,\n ],\n )};`,\n ]);\n }\n}\n\nexport default ShareRuntimeModule;\n"],"names":["ShareRuntimeModule","RuntimeModule","generate","compilation","Error","runtimeTemplate","codeGenerationResults","outputOptions","uniqueName","ignoreBrowserWarnings","chunkGraph","initCodePerScope","Map","chunk","getAllReferencedChunks","modules","getOrderedChunkModulesIterableBySourceType","compareModulesByIdentifier","m","data","getData","runtime","item","shareScope","initStage","init","stages","get","undefined","set","list","Set","add","Template","asString","RuntimeGlobals","shareScopeMap","initializeSharing","basicFunction","hasOwnProperty","JSON","stringify","expressionFunction","indent","require","returningFunction","Array","from","sort","a","b","compareStrings","map","name","initCode","constructor"],"mappings":"AAAA;;;AAGA,GAEA;;;;+BAqJA;;;eAAA;;;wEAnJgC;sEACN;iEACL;6BAMd;;;;;;;;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AAA,2BAAc,EAACF,GAAGC,IACrCE,GAAG,CAAC,CAAC,CAACC,MAAM3B,OAAO,GAClBO,iBAAQ,CAACU,MAAM,CAAC;wBACd,CAAC,KAAK,EAAEH,KAAKC,SAAS,CAACY,MAAM,GAAG,CAAC;wBACjCpB,iBAAQ,CAACU,MAAM,CACbG,MAAMC,IAAI,CAACrB,QACRsB,IAAI,CAAC,CAAC,CAACC,EAAE,EAAE,CAACC,EAAE,GAAKD,IAAIC,GACvBE,GAAG,CAAC,CAAC,GAAGE,SAAS,GAChBrB,iBAAQ,CAACC,QAAQ,CAACY,MAAMC,IAAI,CAACO;wBAGnC;wBACA;qBACD;gBAEL;gBACA;gBACA,CAAC,uDAAuD,EAAEjD,gBAAgBwC,iBAAiB,CACzF,0BACA,EAAE,CAAC;aACN,EACD,CAAC,CAAC;SACL;IACH;IArIAU,aAAc;QACZ,KAAK,CAAC;IACR;AAoIF;MAEA,WAAevD"}
@@ -12,17 +12,17 @@ function _export(target, all) {
12
12
  });
13
13
  }
14
14
  _export(exports, {
15
- isRequiredVersion: function() {
16
- return isRequiredVersion;
17
- },
18
- normalizeVersion: function() {
19
- return normalizeVersion;
20
- },
21
15
  getDescriptionFile: function() {
22
16
  return getDescriptionFile;
23
17
  },
24
18
  getRequiredVersionFromDescriptionFile: function() {
25
19
  return getRequiredVersionFromDescriptionFile;
20
+ },
21
+ isRequiredVersion: function() {
22
+ return isRequiredVersion;
23
+ },
24
+ normalizeVersion: function() {
25
+ return normalizeVersion;
26
26
  }
27
27
  });
28
28
  const _fs = require("webpack/lib/util/fs");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/utils.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nimport { join, dirname, readJson, InputFileSystem } from 'webpack/lib/util/fs';\n\n// Extreme shorthand only for github. eg: foo/bar\nconst RE_URL_GITHUB_EXTREME_SHORT: RegExp =\n /^[^/@:.\\s][^/@:\\s]*\\/[^@:\\s]*[^/@:\\s]#\\S+/;\n\n// Short url with specific protocol. eg: github:foo/bar\nconst RE_GIT_URL_SHORT: RegExp =\n /^(github|gitlab|bitbucket|gist):\\/?[^/.]+\\/?/i;\n\n// Currently supported protocols\nconst RE_PROTOCOL: RegExp =\n /^((git\\+)?(ssh|https?|file)|git|github|gitlab|bitbucket|gist):$/i;\n\n// Has custom protocol\nconst RE_CUSTOM_PROTOCOL: RegExp = /^((git\\+)?(ssh|https?|file)|git):\\/\\//i;\n\n// Valid hash format for npm / yarn ...\nconst RE_URL_HASH_VERSION: RegExp = /#(?:semver:)?(.+)/;\n\n// Simple hostname validate\nconst RE_HOSTNAME: RegExp = /^(?:[^/.]+(\\.[^/]+)+|localhost)$/;\n\n// For hostname with colon. eg: ssh://user@github.com:foo/bar\nconst RE_HOSTNAME_WITH_COLON: RegExp =\n /([^/@#:.]+(?:\\.[^/@#:.]+)+|localhost):([^#/0-9]+)/;\n\n// Reg for url without protocol\nconst RE_NO_PROTOCOL: RegExp = /^([^/@#:.]+(?:\\.[^/@#:.]+)+)/;\n\n// RegExp for version string\nconst VERSION_PATTERN_REGEXP: RegExp = /^([\\d^=v<>~]|[*xX]$)/;\n\n// Specific protocol for short url without normal hostname\nconst PROTOCOLS_FOR_SHORT: string[] = [\n 'github:',\n 'gitlab:',\n 'bitbucket:',\n 'gist:',\n 'file:',\n];\n\n// Default protocol for git url\nconst DEF_GIT_PROTOCOL: string = 'git+ssh://';\n\n// thanks to https://github.com/npm/hosted-git-info/blob/latest/git-host-info.js\nconst extractCommithashByDomain: {\n [key: string]: (pathname: string, hash: string) => string | undefined;\n} = {\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'github.com': (pathname: string, hash: string) => {\n const [, user, project, type, commithash] = pathname.split('/', 5);\n if (type && type !== 'tree') {\n return;\n }\n\n let commithashResult = commithash;\n if (!type) {\n commithashResult = hash;\n } else {\n commithashResult = '#' + commithash;\n }\n\n let projectResult = project;\n if (project && project.endsWith('.git')) {\n projectResult = project.slice(0, -4);\n }\n\n if (!user || !projectResult) {\n return;\n }\n\n return commithashResult;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'gitlab.com': (pathname: string, hash: string) => {\n const path = pathname.slice(1);\n if (path.includes('/-/') || path.includes('/archive.tar.gz')) {\n return;\n }\n\n const segments = path.split('/');\n let project = segments.pop();\n if (project && project.endsWith('.git')) {\n project = project.slice(0, -4);\n }\n\n const user = segments.join('/');\n if (!user || !project) {\n return;\n }\n\n return hash;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'bitbucket.org': (pathname: string, hash: string) => {\n const [, user, project, aux] = pathname.split('/', 4);\n if (['get'].includes(aux)) {\n return;\n }\n\n let projectResult = project;\n if (project && project.endsWith('.git')) {\n projectResult = project.slice(0, -4);\n }\n\n if (!user || !projectResult) {\n return;\n }\n\n return hash;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'gist.github.com': (pathname: string, hash: string) => {\n const [, user, project, aux] = pathname.split('/', 4);\n if (aux === 'raw') {\n return;\n }\n\n let projectResult = project;\n if (!projectResult) {\n if (!user) {\n return;\n }\n\n projectResult = user;\n }\n\n if (projectResult.endsWith('.git')) {\n projectResult = projectResult.slice(0, -4);\n }\n\n return hash;\n },\n};\n\n/**\n * extract commit hash from parsed url\n *\n * @inner\n * @param {URL} urlParsed parsed url\n * @returns {string} commithash\n */\nfunction getCommithash(urlParsed: URL): string {\n const { hostname, pathname, hash } = urlParsed;\n const hostnameResult = hostname.replace(/^www\\./, '');\n\n let hashResult = hash;\n try {\n hashResult = decodeURIComponent(hash);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n\n if (\n /** @type {keyof extractCommithashByDomain} */ extractCommithashByDomain[\n hostnameResult\n ]\n ) {\n return (\n extractCommithashByDomain\n /** @type {keyof extractCommithashByDomain} */ [hostnameResult](\n pathname,\n hashResult,\n ) || ''\n );\n }\n\n return hashResult;\n}\n\n/**\n * make url right for URL parse\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} fixed url\n */\nfunction correctUrl(gitUrl: string): string {\n // like:\n // proto://hostname.com:user/repo -> proto://hostname.com/user/repo\n return gitUrl.replace(RE_HOSTNAME_WITH_COLON, '$1/$2');\n}\n\n/**\n * make url protocol right for URL parse\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} fixed url\n */\nfunction correctProtocol(gitUrl: string): string {\n // eg: github:foo/bar#v1.0. Should not add double slash, in case of error parsed `pathname`\n if (RE_GIT_URL_SHORT.test(gitUrl)) {\n return gitUrl;\n }\n\n // eg: user@github.com:foo/bar\n if (!RE_CUSTOM_PROTOCOL.test(gitUrl)) {\n return `${DEF_GIT_PROTOCOL}${gitUrl}`;\n }\n\n return gitUrl;\n}\n\n/**\n * extract git dep version from hash\n *\n * @inner\n * @param {string} hash hash\n * @returns {string} git dep version\n */\nfunction getVersionFromHash(hash: string): string {\n const matched = hash.match(RE_URL_HASH_VERSION);\n\n return (matched && matched[1]) || '';\n}\n\n/**\n * if string can be decoded\n *\n * @inner\n * @param {string} str str to be checked\n * @returns {boolean} if can be decoded\n */\nfunction canBeDecoded(str: string): boolean {\n try {\n decodeURIComponent(str);\n } catch (e) {\n return false;\n }\n\n return true;\n}\n\n/**\n * get right dep version from git url\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} dep version\n */\nfunction getGitUrlVersion(gitUrl: string): string {\n const oriGitUrl = gitUrl;\n // github extreme shorthand\n if (RE_URL_GITHUB_EXTREME_SHORT.test(gitUrl)) {\n gitUrl = 'github:' + gitUrl;\n } else {\n gitUrl = correctProtocol(gitUrl);\n }\n\n gitUrl = correctUrl(gitUrl);\n\n let parsed;\n try {\n parsed = new URL(gitUrl);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n\n if (!parsed) {\n return '';\n }\n\n const { protocol, hostname, pathname, username, password } = parsed;\n if (!RE_PROTOCOL.test(protocol)) {\n return '';\n }\n\n // pathname shouldn't be empty or URL malformed\n if (!pathname || !canBeDecoded(pathname)) {\n return '';\n }\n\n // without protocol, there should have auth info\n if (RE_NO_PROTOCOL.test(oriGitUrl) && !username && !password) {\n return '';\n }\n\n if (!PROTOCOLS_FOR_SHORT.includes(protocol.toLowerCase())) {\n if (!RE_HOSTNAME.test(hostname)) {\n return '';\n }\n\n const commithash = getCommithash(parsed);\n return getVersionFromHash(commithash) || commithash;\n }\n\n // for protocol short\n return getVersionFromHash(gitUrl);\n}\n\n/**\n * @param {string} str maybe required version\n * @returns {boolean} true, if it looks like a version\n */\nfunction isRequiredVersion(str: string): boolean {\n return VERSION_PATTERN_REGEXP.test(str);\n}\n\nexport { isRequiredVersion };\n\n/**\n * @see https://docs.npmjs.com/cli/v7/configuring-npm/package-json#urls-as-dependencies\n * @param {string} versionDesc version to be normalized\n * @returns {string} normalized version\n */\nfunction normalizeVersion(versionDesc: string): string {\n versionDesc = (versionDesc && versionDesc.trim()) || '';\n\n if (isRequiredVersion(versionDesc)) {\n return versionDesc;\n }\n\n // add handle for URL Dependencies\n return getGitUrlVersion(versionDesc.toLowerCase());\n}\n\nexport { normalizeVersion };\n\n/**\n *\n * @param {InputFileSystem} fs file system\n * @param {string} directory directory to start looking into\n * @param {string[]} descriptionFiles possible description filenames\n * @param {function((Error | null)=, {data: object, path: string}=): void} callback callback\n */\nconst getDescriptionFile = (\n fs: InputFileSystem,\n directory: string,\n descriptionFiles: string[],\n callback: (err: Error | null, data?: { data: object; path: string }) => void,\n) => {\n let i = 0;\n const tryLoadCurrent = () => {\n if (i >= descriptionFiles.length) {\n const parentDirectory = dirname(fs, directory);\n if (!parentDirectory || parentDirectory === directory) {\n //@ts-ignore\n return callback();\n }\n return getDescriptionFile(\n fs,\n parentDirectory,\n descriptionFiles,\n callback,\n );\n }\n const filePath = join(fs, directory, descriptionFiles[i]);\n readJson(fs, filePath, (err, data: object) => {\n if (err) {\n if ('code' in err && err.code === 'ENOENT') {\n i++;\n return tryLoadCurrent();\n }\n return callback(err);\n }\n if (!data || typeof data !== 'object' || Array.isArray(data)) {\n return callback(\n new Error(`Description file ${filePath} is not an object`),\n );\n }\n callback(null, { data, path: filePath });\n });\n };\n tryLoadCurrent();\n};\nexport { getDescriptionFile };\n/**\n * Get required version from description file\n * @param {Record<string, any>} data - The data object\n * @param {string} packageName - The package name\n * @returns {string | undefined} The normalized version\n */\nexport function getRequiredVersionFromDescriptionFile(\n data: Record<string, any>,\n packageName: string,\n): string | undefined | void {\n if (\n data['optionalDependencies'] &&\n typeof data['optionalDependencies'] === 'object' &&\n packageName in data['optionalDependencies']\n ) {\n return normalizeVersion(data['optionalDependencies'][packageName]);\n }\n if (\n data['dependencies'] &&\n typeof data['dependencies'] === 'object' &&\n packageName in data['dependencies']\n ) {\n return normalizeVersion(data['dependencies'][packageName]);\n }\n if (\n data['peerDependencies'] &&\n typeof data['peerDependencies'] === 'object' &&\n packageName in data['peerDependencies']\n ) {\n return normalizeVersion(data['peerDependencies'][packageName]);\n }\n if (\n data['devDependencies'] &&\n typeof data['devDependencies'] === 'object' &&\n packageName in data['devDependencies']\n ) {\n return normalizeVersion(data['devDependencies'][packageName]);\n }\n}\n"],"names":["isRequiredVersion","normalizeVersion","getDescriptionFile","getRequiredVersionFromDescriptionFile","RE_URL_GITHUB_EXTREME_SHORT","RE_GIT_URL_SHORT","RE_PROTOCOL","RE_CUSTOM_PROTOCOL","RE_URL_HASH_VERSION","RE_HOSTNAME","RE_HOSTNAME_WITH_COLON","RE_NO_PROTOCOL","VERSION_PATTERN_REGEXP","PROTOCOLS_FOR_SHORT","DEF_GIT_PROTOCOL","extractCommithashByDomain","pathname","hash","user","project","type","commithash","split","commithashResult","projectResult","endsWith","slice","path","includes","segments","pop","join","aux","getCommithash","urlParsed","hostname","hostnameResult","replace","hashResult","decodeURIComponent","e","correctUrl","gitUrl","correctProtocol","test","getVersionFromHash","matched","match","canBeDecoded","str","getGitUrlVersion","oriGitUrl","parsed","URL","protocol","username","password","toLowerCase","versionDesc","trim","fs","directory","descriptionFiles","callback","i","tryLoadCurrent","length","parentDirectory","dirname","filePath","readJson","err","data","code","Array","isArray","Error","packageName"],"mappings":"AAAA;;;AAGA;;;;;;;;;;;IA4TSA,iBAAiB;eAAjBA;;IAkBAC,gBAAgB;eAAhBA;;IAiDAC,kBAAkB;eAAlBA;;IAOOC,qCAAqC;eAArCA;;;oBApYyC;AAEzD,iDAAiD;AACjD,MAAMC,8BACJ;AAEF,uDAAuD;AACvD,MAAMC,mBACJ;AAEF,gCAAgC;AAChC,MAAMC,cACJ;AAEF,sBAAsB;AACtB,MAAMC,qBAA6B;AAEnC,uCAAuC;AACvC,MAAMC,sBAA8B;AAEpC,2BAA2B;AAC3B,MAAMC,cAAsB;AAE5B,6DAA6D;AAC7D,MAAMC,yBACJ;AAEF,+BAA+B;AAC/B,MAAMC,iBAAyB;AAE/B,4BAA4B;AAC5B,MAAMC,yBAAiC;AAEvC,0DAA0D;AAC1D,MAAMC,sBAAgC;IACpC;IACA;IACA;IACA;IACA;CACD;AAED,+BAA+B;AAC/B,MAAMC,mBAA2B;AAEjC,gFAAgF;AAChF,MAAMC,4BAEF;IACF;;;;GAIC,GACD,cAAc,CAACC,UAAkBC;QAC/B,MAAM,GAAGC,MAAMC,SAASC,MAAMC,WAAW,GAAGL,SAASM,KAAK,CAAC,KAAK;QAChE,IAAIF,QAAQA,SAAS,QAAQ;YAC3B;QACF;QAEA,IAAIG,mBAAmBF;QACvB,IAAI,CAACD,MAAM;YACTG,mBAAmBN;QACrB,OAAO;YACLM,mBAAmB,MAAMF;QAC3B;QAEA,IAAIG,gBAAgBL;QACpB,IAAIA,WAAWA,QAAQM,QAAQ,CAAC,SAAS;YACvCD,gBAAgBL,QAAQO,KAAK,CAAC,GAAG,CAAC;QACpC;QAEA,IAAI,CAACR,QAAQ,CAACM,eAA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CK,eAAeL,IAAI,CAAC,kBAAkB,EACtC;QACA,OAAOvE,iBAAiBuE,IAAI,CAAC,kBAAkB,CAACK,YAAY;IAC9D;AACF"}
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/utils.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nimport { join, dirname, readJson, InputFileSystem } from 'webpack/lib/util/fs';\n\n// Extreme shorthand only for github. eg: foo/bar\nconst RE_URL_GITHUB_EXTREME_SHORT: RegExp =\n /^[^/@:.\\s][^/@:\\s]*\\/[^@:\\s]*[^/@:\\s]#\\S+/;\n\n// Short url with specific protocol. eg: github:foo/bar\nconst RE_GIT_URL_SHORT: RegExp =\n /^(github|gitlab|bitbucket|gist):\\/?[^/.]+\\/?/i;\n\n// Currently supported protocols\nconst RE_PROTOCOL: RegExp =\n /^((git\\+)?(ssh|https?|file)|git|github|gitlab|bitbucket|gist):$/i;\n\n// Has custom protocol\nconst RE_CUSTOM_PROTOCOL: RegExp = /^((git\\+)?(ssh|https?|file)|git):\\/\\//i;\n\n// Valid hash format for npm / yarn ...\nconst RE_URL_HASH_VERSION: RegExp = /#(?:semver:)?(.+)/;\n\n// Simple hostname validate\nconst RE_HOSTNAME: RegExp = /^(?:[^/.]+(\\.[^/]+)+|localhost)$/;\n\n// For hostname with colon. eg: ssh://user@github.com:foo/bar\nconst RE_HOSTNAME_WITH_COLON: RegExp =\n /([^/@#:.]+(?:\\.[^/@#:.]+)+|localhost):([^#/0-9]+)/;\n\n// Reg for url without protocol\nconst RE_NO_PROTOCOL: RegExp = /^([^/@#:.]+(?:\\.[^/@#:.]+)+)/;\n\n// RegExp for version string\nconst VERSION_PATTERN_REGEXP: RegExp = /^([\\d^=v<>~]|[*xX]$)/;\n\n// Specific protocol for short url without normal hostname\nconst PROTOCOLS_FOR_SHORT: string[] = [\n 'github:',\n 'gitlab:',\n 'bitbucket:',\n 'gist:',\n 'file:',\n];\n\n// Default protocol for git url\nconst DEF_GIT_PROTOCOL: string = 'git+ssh://';\n\n// thanks to https://github.com/npm/hosted-git-info/blob/latest/git-host-info.js\nconst extractCommithashByDomain: {\n [key: string]: (pathname: string, hash: string) => string | undefined;\n} = {\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'github.com': (pathname: string, hash: string) => {\n const [, user, project, type, commithash] = pathname.split('/', 5);\n if (type && type !== 'tree') {\n return;\n }\n\n let commithashResult = commithash;\n if (!type) {\n commithashResult = hash;\n } else {\n commithashResult = '#' + commithash;\n }\n\n let projectResult = project;\n if (project && project.endsWith('.git')) {\n projectResult = project.slice(0, -4);\n }\n\n if (!user || !projectResult) {\n return;\n }\n\n return commithashResult;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'gitlab.com': (pathname: string, hash: string) => {\n const path = pathname.slice(1);\n if (path.includes('/-/') || path.includes('/archive.tar.gz')) {\n return;\n }\n\n const segments = path.split('/');\n let project = segments.pop();\n if (project && project.endsWith('.git')) {\n project = project.slice(0, -4);\n }\n\n const user = segments.join('/');\n if (!user || !project) {\n return;\n }\n\n return hash;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'bitbucket.org': (pathname: string, hash: string) => {\n const [, user, project, aux] = pathname.split('/', 4);\n if (['get'].includes(aux)) {\n return;\n }\n\n let projectResult = project;\n if (project && project.endsWith('.git')) {\n projectResult = project.slice(0, -4);\n }\n\n if (!user || !projectResult) {\n return;\n }\n\n return hash;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'gist.github.com': (pathname: string, hash: string) => {\n const [, user, project, aux] = pathname.split('/', 4);\n if (aux === 'raw') {\n return;\n }\n\n let projectResult = project;\n if (!projectResult) {\n if (!user) {\n return;\n }\n\n projectResult = user;\n }\n\n if (projectResult.endsWith('.git')) {\n projectResult = projectResult.slice(0, -4);\n }\n\n return hash;\n },\n};\n\n/**\n * extract commit hash from parsed url\n *\n * @inner\n * @param {URL} urlParsed parsed url\n * @returns {string} commithash\n */\nfunction getCommithash(urlParsed: URL): string {\n const { hostname, pathname, hash } = urlParsed;\n const hostnameResult = hostname.replace(/^www\\./, '');\n\n let hashResult = hash;\n try {\n hashResult = decodeURIComponent(hash);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n\n if (\n /** @type {keyof extractCommithashByDomain} */ extractCommithashByDomain[\n hostnameResult\n ]\n ) {\n return (\n extractCommithashByDomain\n /** @type {keyof extractCommithashByDomain} */ [hostnameResult](\n pathname,\n hashResult,\n ) || ''\n );\n }\n\n return hashResult;\n}\n\n/**\n * make url right for URL parse\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} fixed url\n */\nfunction correctUrl(gitUrl: string): string {\n // like:\n // proto://hostname.com:user/repo -> proto://hostname.com/user/repo\n return gitUrl.replace(RE_HOSTNAME_WITH_COLON, '$1/$2');\n}\n\n/**\n * make url protocol right for URL parse\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} fixed url\n */\nfunction correctProtocol(gitUrl: string): string {\n // eg: github:foo/bar#v1.0. Should not add double slash, in case of error parsed `pathname`\n if (RE_GIT_URL_SHORT.test(gitUrl)) {\n return gitUrl;\n }\n\n // eg: user@github.com:foo/bar\n if (!RE_CUSTOM_PROTOCOL.test(gitUrl)) {\n return `${DEF_GIT_PROTOCOL}${gitUrl}`;\n }\n\n return gitUrl;\n}\n\n/**\n * extract git dep version from hash\n *\n * @inner\n * @param {string} hash hash\n * @returns {string} git dep version\n */\nfunction getVersionFromHash(hash: string): string {\n const matched = hash.match(RE_URL_HASH_VERSION);\n\n return (matched && matched[1]) || '';\n}\n\n/**\n * if string can be decoded\n *\n * @inner\n * @param {string} str str to be checked\n * @returns {boolean} if can be decoded\n */\nfunction canBeDecoded(str: string): boolean {\n try {\n decodeURIComponent(str);\n } catch (e) {\n return false;\n }\n\n return true;\n}\n\n/**\n * get right dep version from git url\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} dep version\n */\nfunction getGitUrlVersion(gitUrl: string): string {\n const oriGitUrl = gitUrl;\n // github extreme shorthand\n if (RE_URL_GITHUB_EXTREME_SHORT.test(gitUrl)) {\n gitUrl = 'github:' + gitUrl;\n } else {\n gitUrl = correctProtocol(gitUrl);\n }\n\n gitUrl = correctUrl(gitUrl);\n\n let parsed;\n try {\n parsed = new URL(gitUrl);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n\n if (!parsed) {\n return '';\n }\n\n const { protocol, hostname, pathname, username, password } = parsed;\n if (!RE_PROTOCOL.test(protocol)) {\n return '';\n }\n\n // pathname shouldn't be empty or URL malformed\n if (!pathname || !canBeDecoded(pathname)) {\n return '';\n }\n\n // without protocol, there should have auth info\n if (RE_NO_PROTOCOL.test(oriGitUrl) && !username && !password) {\n return '';\n }\n\n if (!PROTOCOLS_FOR_SHORT.includes(protocol.toLowerCase())) {\n if (!RE_HOSTNAME.test(hostname)) {\n return '';\n }\n\n const commithash = getCommithash(parsed);\n return getVersionFromHash(commithash) || commithash;\n }\n\n // for protocol short\n return getVersionFromHash(gitUrl);\n}\n\n/**\n * @param {string} str maybe required version\n * @returns {boolean} true, if it looks like a version\n */\nfunction isRequiredVersion(str: string): boolean {\n return VERSION_PATTERN_REGEXP.test(str);\n}\n\nexport { isRequiredVersion };\n\n/**\n * @see https://docs.npmjs.com/cli/v7/configuring-npm/package-json#urls-as-dependencies\n * @param {string} versionDesc version to be normalized\n * @returns {string} normalized version\n */\nfunction normalizeVersion(versionDesc: string): string {\n versionDesc = (versionDesc && versionDesc.trim()) || '';\n\n if (isRequiredVersion(versionDesc)) {\n return versionDesc;\n }\n\n // add handle for URL Dependencies\n return getGitUrlVersion(versionDesc.toLowerCase());\n}\n\nexport { normalizeVersion };\n\n/**\n *\n * @param {InputFileSystem} fs file system\n * @param {string} directory directory to start looking into\n * @param {string[]} descriptionFiles possible description filenames\n * @param {function((Error | null)=, {data: object, path: string}=): void} callback callback\n */\nconst getDescriptionFile = (\n fs: InputFileSystem,\n directory: string,\n descriptionFiles: string[],\n callback: (err: Error | null, data?: { data: object; path: string }) => void,\n) => {\n let i = 0;\n const tryLoadCurrent = () => {\n if (i >= descriptionFiles.length) {\n const parentDirectory = dirname(fs, directory);\n if (!parentDirectory || parentDirectory === directory) {\n //@ts-ignore\n return callback();\n }\n return getDescriptionFile(\n fs,\n parentDirectory,\n descriptionFiles,\n callback,\n );\n }\n const filePath = join(fs, directory, descriptionFiles[i]);\n readJson(fs, filePath, (err, data: object) => {\n if (err) {\n if ('code' in err && err.code === 'ENOENT') {\n i++;\n return tryLoadCurrent();\n }\n return callback(err);\n }\n if (!data || typeof data !== 'object' || Array.isArray(data)) {\n return callback(\n new Error(`Description file ${filePath} is not an object`),\n );\n }\n callback(null, { data, path: filePath });\n });\n };\n tryLoadCurrent();\n};\nexport { getDescriptionFile };\n/**\n * Get required version from description file\n * @param {Record<string, any>} data - The data object\n * @param {string} packageName - The package name\n * @returns {string | undefined} The normalized version\n */\nexport function getRequiredVersionFromDescriptionFile(\n data: Record<string, any>,\n packageName: string,\n): string | undefined | void {\n if (\n data['optionalDependencies'] &&\n typeof data['optionalDependencies'] === 'object' &&\n packageName in data['optionalDependencies']\n ) {\n return normalizeVersion(data['optionalDependencies'][packageName]);\n }\n if (\n data['dependencies'] &&\n typeof data['dependencies'] === 'object' &&\n packageName in data['dependencies']\n ) {\n return normalizeVersion(data['dependencies'][packageName]);\n }\n if (\n data['peerDependencies'] &&\n typeof data['peerDependencies'] === 'object' &&\n packageName in data['peerDependencies']\n ) {\n return normalizeVersion(data['peerDependencies'][packageName]);\n }\n if (\n data['devDependencies'] &&\n typeof data['devDependencies'] === 'object' &&\n packageName in data['devDependencies']\n ) {\n return normalizeVersion(data['devDependencies'][packageName]);\n }\n}\n"],"names":["getDescriptionFile","getRequiredVersionFromDescriptionFile","isRequiredVersion","normalizeVersion","RE_URL_GITHUB_EXTREME_SHORT","RE_GIT_URL_SHORT","RE_PROTOCOL","RE_CUSTOM_PROTOCOL","RE_URL_HASH_VERSION","RE_HOSTNAME","RE_HOSTNAME_WITH_COLON","RE_NO_PROTOCOL","VERSION_PATTERN_REGEXP","PROTOCOLS_FOR_SHORT","DEF_GIT_PROTOCOL","extractCommithashByDomain","pathname","hash","user","project","type","commithash","split","commithashResult","projectResult","endsWith","slice","path","includes","segments","pop","join","aux","getCommithash","urlParsed","hostname","hostnameResult","replace","hashResult","decodeURIComponent","e","correctUrl","gitUrl","correctProtocol","test","getVersionFromHash","matched","match","canBeDecoded","str","getGitUrlVersion","oriGitUrl","parsed","URL","protocol","username","password","toLowerCase","versionDesc","trim","fs","directory","descriptionFiles","callback","i","tryLoadCurrent","length","parentDirectory","dirname","filePath","readJson","err","data","code","Array","isArray","Error","packageName"],"mappings":"AAAA;;;AAGA;;;;;;;;;;;IA+XSA,kBAAkB;eAAlBA;;IAOOC,qCAAqC;eAArCA;;IA1EPC,iBAAiB;eAAjBA;;IAkBAC,gBAAgB;eAAhBA;;;oBA5UgD;AAEzD,iDAAiD;AACjD,MAAMC,8BACJ;AAEF,uDAAuD;AACvD,MAAMC,mBACJ;AAEF,gCAAgC;AAChC,MAAMC,cACJ;AAEF,sBAAsB;AACtB,MAAMC,qBAA6B;AAEnC,uCAAuC;AACvC,MAAMC,sBAA8B;AAEpC,2BAA2B;AAC3B,MAAMC,cAAsB;AAE5B,6DAA6D;AAC7D,MAAMC,yBACJ;AAEF,+BAA+B;AAC/B,MAAMC,iBAAyB;AAE/B,4BAA4B;AAC5B,MAAMC,yBAAiC;AAEvC,0DAA0D;AAC1D,MAAMC,sBAAgC;IACpC;IACA;IACA;IACA;IACA;CACD;AAED,+BAA+B;AAC/B,MAAMC,mBAA2B;AAEjC,gFAAgF;AAChF,MAAMC,4BAEF;IACF;;;;GAIC,GACD,cAAc,CAACC,UAAkBC;QAC/B,MAAM,GAAGC,MAAMC,SAASC,M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YAChCK,eAAeL,IAAI,CAAC,eAAe,EACnC;QACA,OAAOrE,iBAAiBqE,IAAI,CAAC,eAAe,CAACK,YAAY;IAC3D;IACA,IACEL,IAAI,CAAC,mBAAmB,IACxB,OAAOA,IAAI,CAAC,mBAAmB,KAAK,YACpCK,eAAeL,IAAI,CAAC,mBAAmB,EACvC;QACA,OAAOrE,iBAAiBqE,IAAI,CAAC,mBAAmB,CAACK,YAAY;IAC/D;IACA,IACEL,IAAI,CAAC,kBAAkB,IACvB,OAAOA,IAAI,CAAC,kBAAkB,KAAK,YACnCK,eAAeL,IAAI,CAAC,kBAAkB,EACtC;QACA,OAAOrE,iBAAiBqE,IAAI,CAAC,kBAAkB,CAACK,YAAY;IAC9D;AACF"}
@@ -0,0 +1,5 @@
1
+ import { Compiler } from 'webpack';
2
+ export declare class AddRuntimeRequirementToPromiseExternal {
3
+ apply(compiler: Compiler): void;
4
+ }
5
+ export default AddRuntimeRequirementToPromiseExternal;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ AddRuntimeRequirementToPromiseExternal: function() {
13
+ return AddRuntimeRequirementToPromiseExternal;
14
+ },
15
+ default: function() {
16
+ return _default;
17
+ }
18
+ });
19
+ let AddRuntimeRequirementToPromiseExternal = class AddRuntimeRequirementToPromiseExternal {
20
+ apply(compiler) {
21
+ compiler.hooks.compilation.tap('AddRuntimeRequirementToPromiseExternal', (compilation)=>{
22
+ const { RuntimeGlobals } = compiler.webpack;
23
+ compilation.hooks.additionalModuleRuntimeRequirements.tap('AddRuntimeRequirementToPromiseExternal', (module, set)=>{
24
+ if (module.externalType === 'promise') {
25
+ set.add(RuntimeGlobals.loadScript);
26
+ set.add(RuntimeGlobals.require);
27
+ }
28
+ });
29
+ });
30
+ }
31
+ };
32
+ const _default = AddRuntimeRequirementToPromiseExternal;
33
+
34
+ //# sourceMappingURL=AddRuntimeRequirementToPromiseExternalPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../packages/enhanced/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.ts"],"sourcesContent":["import { Compiler } from 'webpack';\n\nexport class AddRuntimeRequirementToPromiseExternal {\n apply(compiler: Compiler) {\n compiler.hooks.compilation.tap(\n 'AddRuntimeRequirementToPromiseExternal',\n (compilation) => {\n const { RuntimeGlobals } = compiler.webpack;\n compilation.hooks.additionalModuleRuntimeRequirements.tap(\n 'AddRuntimeRequirementToPromiseExternal',\n (module, set) => {\n if ((module as any).externalType === 'promise') {\n set.add(RuntimeGlobals.loadScript);\n set.add(RuntimeGlobals.require);\n }\n },\n );\n },\n );\n }\n}\n\nexport default AddRuntimeRequirementToPromiseExternal;\n"],"names":["AddRuntimeRequirementToPromiseExternal","apply","compiler","hooks","compilation","tap","RuntimeGlobals","webpack","additionalModuleRuntimeRequirements","module","set","externalType","add","loadScript","require"],"mappings":";;;;;;;;;;;IAEaA,sCAAsC;eAAtCA;;IAoBb,OAAsD;eAAtD;;;AApBO,IAAA,AAAMA,yCAAN,MAAMA;IACXC,MAAMC,QAAkB,EAAE;QACxBA,SAASC,KAAK,CAACC,WAAW,CAACC,GAAG,CAC5B,0CACA,CAACD;YACC,MAAM,EAAEE,cAAc,EAAE,GAAGJ,SAASK,OAAO;YAC3CH,YAAYD,KAAK,CAACK,mCAAmC,CAACH,GAAG,CACvD,0CACA,CAACI,QAAQC;gBACP,IAAI,AAACD,OAAeE,YAAY,KAAK,WAAW;oBAC9CD,IAAIE,GAAG,CAACN,eAAeO,UAAU;oBACjCH,IAAIE,GAAG,CAACN,eAAeQ,OAAO;gBAChC;YACF;QAEJ;IAEJ;AACF;MAEA,WAAed"}
@@ -0,0 +1,10 @@
1
+ export = D;
2
+ declare function D(n: any, { instancePath: s, parentData: a, parentDataProperty: i, rootData: l, }?: {
3
+ instancePath?: string | undefined;
4
+ parentData: any;
5
+ parentDataProperty: any;
6
+ rootData?: any;
7
+ }): boolean;
8
+ declare namespace D {
9
+ export { D as default };
10
+ }
package/CHANGELOG.md DELETED
@@ -1,120 +0,0 @@
1
- # Changelog
2
-
3
- This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
-
5
- ## [0.0.4-0](https://github.com/module-federation/nextjs-mf/compare/enhanced-0.0.3...enhanced-0.0.4-0) (2023-10-03)
6
-
7
-
8
- ### Bug Fixes
9
-
10
- * no external helpers ([6c47fd4](https://github.com/module-federation/nextjs-mf/commit/6c47fd4ce19f2292f6718d201005fba4a8552252))
11
-
12
-
13
-
14
- ## [0.0.3](https://github.com/module-federation/nextjs-mf/compare/enhanced-0.0.2...enhanced-0.0.3) (2023-10-03)
15
-
16
-
17
-
18
- ## [0.0.2](https://github.com/module-federation/nextjs-mf/compare/enhanced-0.0.1...enhanced-0.0.2) (2023-10-03)
19
-
20
-
21
-
22
- ## [0.0.1](https://github.com/module-federation/nextjs-mf/compare/enhanced-0.0.1-rc.0...enhanced-0.0.1) (2023-10-03)
23
-
24
-
25
-
26
- ## 0.0.1-rc.0 (2023-10-03)
27
-
28
-
29
- ### Bug Fixes
30
-
31
- * add missing serialize method on RemoteModule ([e7ac801](https://github.com/module-federation/nextjs-mf/commit/e7ac801151b08dbb5ca025bd8ac03683f792f92f))
32
- * add override to remoteModule ([875038a](https://github.com/module-federation/nextjs-mf/commit/875038ad68dfed05822c1bc7c68ae91e57282f4f))
33
- * bad impleentation during federation port ([cc2e53f](https://github.com/module-federation/nextjs-mf/commit/cc2e53f0351fb94c9068223ad6b8d990a913ab53))
34
- * broken versioning issues in consumes ([e7fada2](https://github.com/module-federation/nextjs-mf/commit/e7fada211b1e58dc52eafeff4210a9ce62636f9d))
35
- * change exports for module info runtime ([f40c538](https://github.com/module-federation/nextjs-mf/commit/f40c538221353a61938cadf624c9235ec8eb4cce))
36
- * **enhanced:** module info duplication ([49b4a57](https://github.com/module-federation/nextjs-mf/commit/49b4a5736714c1db4510d10cdd5fe0277123caa8))
37
- * **enhanced:** syntax issue in proxy ([2e5848b](https://github.com/module-federation/nextjs-mf/commit/2e5848b4be3e3bba46508a427c1bc8f2d3043c8d))
38
- * improve backward compat __remote_scope__ global ([ac0efa3](https://github.com/module-federation/nextjs-mf/commit/ac0efa37d975a130aa3badc657fa66d723865a5b))
39
- * improve logic in runtime module info proxy ([8eea1a8](https://github.com/module-federation/nextjs-mf/commit/8eea1a84ae6a12f69dbb16d00f52ec902efbdda6))
40
- * legacy scope duplication on recreation ([347e4c9](https://github.com/module-federation/nextjs-mf/commit/347e4c96e87ff4f28dce319fc6b2fe40f1cbabee))
41
- * package data ([992d298](https://github.com/module-federation/nextjs-mf/commit/992d2985c29d0bf86de6739f728fbf64749e7fd0))
42
- * remote global share scope ([e05d32f](https://github.com/module-federation/nextjs-mf/commit/e05d32f489880d6b4e0fc21a3807e619a40bc5b3))
43
- * Ts import error ([6e7974c](https://github.com/module-federation/nextjs-mf/commit/6e7974c22874378122ab31eea27dddd0604505db))
44
- * TS imports to webpack ([d506b49](https://github.com/module-federation/nextjs-mf/commit/d506b492b724ccfb7fdcf6234196ac421564c153))
45
- * TS imports, missing module methods ([8eb422d](https://github.com/module-federation/nextjs-mf/commit/8eb422d30e149cb0d96835f036ec73ce1ccafe53))
46
- * ts in template string ([579b341](https://github.com/module-federation/nextjs-mf/commit/579b341a5eb38ca6396da15f9667729ab84d2ff6))
47
- * ts in template string ([37e790a](https://github.com/module-federation/nextjs-mf/commit/37e790a7b46ff6d8c8fd2c12cfd5629900db1b53))
48
- * ts in template string ([0edbbea](https://github.com/module-federation/nextjs-mf/commit/0edbbeaa42503237b88132252e29a34a79bade51))
49
- * ts in template string ([1d56efd](https://github.com/module-federation/nextjs-mf/commit/1d56efdf3d0bc78d19d187fe561fbbf453bada87))
50
- * ts in template string ([113d703](https://github.com/module-federation/nextjs-mf/commit/113d7037de8238ed0bcf9418ac1bf3d082fbea66))
51
- * typescript issues ([0a07481](https://github.com/module-federation/nextjs-mf/commit/0a07481552e1df6b35506165cbc649996004c318))
52
- * use ES5 for renderStartup of entrypoint ([d14324a](https://github.com/module-federation/nextjs-mf/commit/d14324a9af856fca974a8f9945ba7d0d2a96be48))
53
-
54
-
55
- ### Features
56
-
57
- * additional plugin exports ([0604461](https://github.com/module-federation/nextjs-mf/commit/0604461ea8806d4e064955f5edef571a9a45d8d0))
58
- * AsyncBoundaryPlugin ([00227ca](https://github.com/module-federation/nextjs-mf/commit/00227cabf3a1e7286148e84d5714e020391771f7))
59
- * checkInvalidContext as tapable hook ([a3eb553](https://github.com/module-federation/nextjs-mf/commit/a3eb5537ff462ead2230615f578569ec46199f50))
60
- * **ContainerEntryModule:** fix TypeScript issue, enhance needBuild method [#398](https://github.com/module-federation/nextjs-mf/issues/398)a60e ([c561e11](https://github.com/module-federation/nextjs-mf/commit/c561e111a54b253fd194c3b75041577dda50ad4b)), closes [#398a60](https://github.com/module-federation/nextjs-mf/issues/398a60)
61
- * **enhanced:** Fork Module Federation ([8682990](https://github.com/module-federation/nextjs-mf/commit/8682990e7fec6309ce20572958916f747737af90))
62
- * **enhanced:** Refactor ContainerEntryDependency and ContainerEntryModule for better code readability and maintainability ([e93e7d2](https://github.com/module-federation/nextjs-mf/commit/e93e7d2fafe2e22f7d2c613095ce1900d7531f29))
63
- * fork module federation ([0ad7430](https://github.com/module-federation/nextjs-mf/commit/0ad7430f6170458a47144be392133b7b2fa1ade0))
64
- * improved async init ([17b1419](https://github.com/module-federation/nextjs-mf/commit/17b1419ef31ec5661fa06b9f0c297e2771e2a86c))
65
- * support lazy compilation ([29c234c](https://github.com/module-federation/nextjs-mf/commit/29c234c14315e000acefc60d635ee486205ca83e))
66
- * Use enhanced Federation Plugin ([e021d66](https://github.com/module-federation/nextjs-mf/commit/e021d6667996962f154137d164bed13f53a6a135))
67
-
68
-
69
- ### Reverts
70
-
71
- * Revert "add migration / sync steps" ([5511559](https://github.com/module-federation/nextjs-mf/commit/5511559b86937b2733ac2e8db7e0a4fb33293778))
72
-
73
-
74
-
75
- ## 0.0.1-0 (2023-10-03)
76
-
77
-
78
- ### Bug Fixes
79
-
80
- * add missing serialize method on RemoteModule ([e7ac801](https://github.com/module-federation/nextjs-mf/commit/e7ac801151b08dbb5ca025bd8ac03683f792f92f))
81
- * add override to remoteModule ([875038a](https://github.com/module-federation/nextjs-mf/commit/875038ad68dfed05822c1bc7c68ae91e57282f4f))
82
- * bad impleentation during federation port ([cc2e53f](https://github.com/module-federation/nextjs-mf/commit/cc2e53f0351fb94c9068223ad6b8d990a913ab53))
83
- * broken versioning issues in consumes ([e7fada2](https://github.com/module-federation/nextjs-mf/commit/e7fada211b1e58dc52eafeff4210a9ce62636f9d))
84
- * change exports for module info runtime ([f40c538](https://github.com/module-federation/nextjs-mf/commit/f40c538221353a61938cadf624c9235ec8eb4cce))
85
- * **enhanced:** module info duplication ([49b4a57](https://github.com/module-federation/nextjs-mf/commit/49b4a5736714c1db4510d10cdd5fe0277123caa8))
86
- * **enhanced:** syntax issue in proxy ([2e5848b](https://github.com/module-federation/nextjs-mf/commit/2e5848b4be3e3bba46508a427c1bc8f2d3043c8d))
87
- * improve backward compat __remote_scope__ global ([ac0efa3](https://github.com/module-federation/nextjs-mf/commit/ac0efa37d975a130aa3badc657fa66d723865a5b))
88
- * improve logic in runtime module info proxy ([8eea1a8](https://github.com/module-federation/nextjs-mf/commit/8eea1a84ae6a12f69dbb16d00f52ec902efbdda6))
89
- * legacy scope duplication on recreation ([347e4c9](https://github.com/module-federation/nextjs-mf/commit/347e4c96e87ff4f28dce319fc6b2fe40f1cbabee))
90
- * package data ([992d298](https://github.com/module-federation/nextjs-mf/commit/992d2985c29d0bf86de6739f728fbf64749e7fd0))
91
- * remote global share scope ([e05d32f](https://github.com/module-federation/nextjs-mf/commit/e05d32f489880d6b4e0fc21a3807e619a40bc5b3))
92
- * Ts import error ([6e7974c](https://github.com/module-federation/nextjs-mf/commit/6e7974c22874378122ab31eea27dddd0604505db))
93
- * TS imports to webpack ([d506b49](https://github.com/module-federation/nextjs-mf/commit/d506b492b724ccfb7fdcf6234196ac421564c153))
94
- * TS imports, missing module methods ([8eb422d](https://github.com/module-federation/nextjs-mf/commit/8eb422d30e149cb0d96835f036ec73ce1ccafe53))
95
- * ts in template string ([579b341](https://github.com/module-federation/nextjs-mf/commit/579b341a5eb38ca6396da15f9667729ab84d2ff6))
96
- * ts in template string ([37e790a](https://github.com/module-federation/nextjs-mf/commit/37e790a7b46ff6d8c8fd2c12cfd5629900db1b53))
97
- * ts in template string ([0edbbea](https://github.com/module-federation/nextjs-mf/commit/0edbbeaa42503237b88132252e29a34a79bade51))
98
- * ts in template string ([1d56efd](https://github.com/module-federation/nextjs-mf/commit/1d56efdf3d0bc78d19d187fe561fbbf453bada87))
99
- * ts in template string ([113d703](https://github.com/module-federation/nextjs-mf/commit/113d7037de8238ed0bcf9418ac1bf3d082fbea66))
100
- * typescript issues ([0a07481](https://github.com/module-federation/nextjs-mf/commit/0a07481552e1df6b35506165cbc649996004c318))
101
- * use ES5 for renderStartup of entrypoint ([d14324a](https://github.com/module-federation/nextjs-mf/commit/d14324a9af856fca974a8f9945ba7d0d2a96be48))
102
-
103
-
104
- ### Features
105
-
106
- * additional plugin exports ([0604461](https://github.com/module-federation/nextjs-mf/commit/0604461ea8806d4e064955f5edef571a9a45d8d0))
107
- * AsyncBoundaryPlugin ([00227ca](https://github.com/module-federation/nextjs-mf/commit/00227cabf3a1e7286148e84d5714e020391771f7))
108
- * checkInvalidContext as tapable hook ([a3eb553](https://github.com/module-federation/nextjs-mf/commit/a3eb5537ff462ead2230615f578569ec46199f50))
109
- * **ContainerEntryModule:** fix TypeScript issue, enhance needBuild method [#398](https://github.com/module-federation/nextjs-mf/issues/398)a60e ([c561e11](https://github.com/module-federation/nextjs-mf/commit/c561e111a54b253fd194c3b75041577dda50ad4b)), closes [#398a60](https://github.com/module-federation/nextjs-mf/issues/398a60)
110
- * **enhanced:** Fork Module Federation ([8682990](https://github.com/module-federation/nextjs-mf/commit/8682990e7fec6309ce20572958916f747737af90))
111
- * **enhanced:** Refactor ContainerEntryDependency and ContainerEntryModule for better code readability and maintainability ([e93e7d2](https://github.com/module-federation/nextjs-mf/commit/e93e7d2fafe2e22f7d2c613095ce1900d7531f29))
112
- * fork module federation ([0ad7430](https://github.com/module-federation/nextjs-mf/commit/0ad7430f6170458a47144be392133b7b2fa1ade0))
113
- * improved async init ([17b1419](https://github.com/module-federation/nextjs-mf/commit/17b1419ef31ec5661fa06b9f0c297e2771e2a86c))
114
- * support lazy compilation ([29c234c](https://github.com/module-federation/nextjs-mf/commit/29c234c14315e000acefc60d635ee486205ca83e))
115
- * Use enhanced Federation Plugin ([e021d66](https://github.com/module-federation/nextjs-mf/commit/e021d6667996962f154137d164bed13f53a6a135))
116
-
117
-
118
- ### Reverts
119
-
120
- * Revert "add migration / sync steps" ([5511559](https://github.com/module-federation/nextjs-mf/commit/5511559b86937b2733ac2e8db7e0a4fb33293778))
package/README.md DELETED
@@ -1,11 +0,0 @@
1
- # enhanced
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Building
6
-
7
- Run `nx build enhanced` to build the library.
8
-
9
- ## Running unit tests
10
-
11
- Run `nx test enhanced` to execute the unit tests via [Jest](https://jestjs.io).