@module-federation/enhanced 0.0.3 → 0.1.0

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 (67) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/package.json +1 -1
  3. package/src/index.js +22 -18
  4. package/src/index.js.map +1 -1
  5. package/src/lib/Constants.js +33 -33
  6. package/src/lib/Constants.js.map +1 -1
  7. package/src/lib/container/AsyncBoundaryPlugin.js +12 -5
  8. package/src/lib/container/AsyncBoundaryPlugin.js.map +1 -1
  9. package/src/lib/container/ContainerEntryDependency.js +7 -3
  10. package/src/lib/container/ContainerEntryDependency.js.map +1 -1
  11. package/src/lib/container/ContainerEntryModule.js +51 -9
  12. package/src/lib/container/ContainerEntryModule.js.map +1 -1
  13. package/src/lib/container/ContainerEntryModuleFactory.js +7 -3
  14. package/src/lib/container/ContainerEntryModuleFactory.js.map +1 -1
  15. package/src/lib/container/ContainerExposedDependency.js +7 -3
  16. package/src/lib/container/ContainerExposedDependency.js.map +1 -1
  17. package/src/lib/container/ContainerPlugin.js +9 -5
  18. package/src/lib/container/ContainerPlugin.js.map +1 -1
  19. package/src/lib/container/ContainerReferencePlugin.js +53 -11
  20. package/src/lib/container/ContainerReferencePlugin.js.map +1 -1
  21. package/src/lib/container/FallbackDependency.js +7 -3
  22. package/src/lib/container/FallbackDependency.js.map +1 -1
  23. package/src/lib/container/FallbackItemDependency.js +7 -3
  24. package/src/lib/container/FallbackItemDependency.js.map +1 -1
  25. package/src/lib/container/FallbackModule.js +10 -6
  26. package/src/lib/container/FallbackModule.js.map +1 -1
  27. package/src/lib/container/FallbackModuleFactory.js +7 -3
  28. package/src/lib/container/FallbackModuleFactory.js.map +1 -1
  29. package/src/lib/container/ModuleFederationPlugin.js +10 -6
  30. package/src/lib/container/ModuleFederationPlugin.js.map +1 -1
  31. package/src/lib/container/RemoteModule.js +10 -6
  32. package/src/lib/container/RemoteModule.js.map +1 -1
  33. package/src/lib/container/RemoteRuntimeModule.js +8 -4
  34. package/src/lib/container/RemoteRuntimeModule.js.map +1 -1
  35. package/src/lib/container/RemoteToExternalDependency.d.js +6 -2
  36. package/src/lib/container/RemoteToExternalDependency.d.js.map +1 -1
  37. package/src/lib/container/RemoteToExternalDependency.js +7 -3
  38. package/src/lib/container/RemoteToExternalDependency.js.map +1 -1
  39. package/src/lib/sharing/ConsumeSharedFallbackDependency.js +7 -3
  40. package/src/lib/sharing/ConsumeSharedFallbackDependency.js.map +1 -1
  41. package/src/lib/sharing/ConsumeSharedModule.js +49 -7
  42. package/src/lib/sharing/ConsumeSharedModule.js.map +1 -1
  43. package/src/lib/sharing/ConsumeSharedPlugin.js +69 -14
  44. package/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -1
  45. package/src/lib/sharing/ConsumeSharedRuntimeModule.js +47 -5
  46. package/src/lib/sharing/ConsumeSharedRuntimeModule.js.map +1 -1
  47. package/src/lib/sharing/ProvideForSharedDependency.js +7 -3
  48. package/src/lib/sharing/ProvideForSharedDependency.js.map +1 -1
  49. package/src/lib/sharing/ProvideSharedDependency.js +7 -3
  50. package/src/lib/sharing/ProvideSharedDependency.js.map +1 -1
  51. package/src/lib/sharing/ProvideSharedModule.js +49 -7
  52. package/src/lib/sharing/ProvideSharedModule.js.map +1 -1
  53. package/src/lib/sharing/ProvideSharedModuleFactory.js +7 -3
  54. package/src/lib/sharing/ProvideSharedModuleFactory.js.map +1 -1
  55. package/src/lib/sharing/ProvideSharedPlugin.js +25 -8
  56. package/src/lib/sharing/ProvideSharedPlugin.js.map +1 -1
  57. package/src/lib/sharing/SharePlugin.js +7 -3
  58. package/src/lib/sharing/SharePlugin.js.map +1 -1
  59. package/src/lib/sharing/ShareRuntimeModule.js +47 -5
  60. package/src/lib/sharing/ShareRuntimeModule.js.map +1 -1
  61. package/src/lib/sharing/resolveMatchedConfigs.js +7 -3
  62. package/src/lib/sharing/resolveMatchedConfigs.js.map +1 -1
  63. package/src/lib/sharing/utils.js +6 -6
  64. package/src/lib/sharing/utils.js.map +1 -1
  65. package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
  66. package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js +34 -0
  67. package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
@@ -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;AACh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uBAAuB,CAACK,YAAY;IACnE;IACA,IACEL,IAAI,CAAC,eAAe,IACpB,OAAOA,IAAI,CAAC,eAAe,KAAK,YAChCK,eAAeL,IAAI,CAAC,eAAe,EACnC;QACA,OAAOvE,iBAAiBuE,IAAI,CAAC,eAAe,CAACK,YAAY;IAC3D;IACA,IACEL,IAAI,CAAC,mBAAmB,IACxB,OAAOA,IAAI,CAAC,mBAAmB,KAAK,YACpCK,eAAeL,IAAI,CAAC,mBAAmB,EACvC;QACA,OAAOvE,iBAAiBuE,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,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,cAC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gBAC5D,OAAOT,SACL,IAAIa,MAAM,CAAC,iBAAiB,EAAEP,SAAS,iBAAiB,CAAC;YAE7D;YACAN,SAAS,MAAM;gBAAES;gBAAM7C,MAAM0C;YAAS;QACxC;IACF;IACAJ;AACF;AAQO,SAAShE,sCACduE,IAAyB,EACzBK,WAAmB;IAEnB,IACEL,IAAI,CAAC,uBAAuB,IAC5B,OAAOA,IAAI,CAAC,uBAAuB,KAAK,YACxCK,eAAeL,IAAI,CAAC,uBAAuB,EAC3C;QACA,OAAOrE,iBAAiBqE,IAAI,CAAC,uBAAuB,CAACK,YAAY;IACnE;IACA,IACEL,IAAI,CAAC,eAAe,IACpB,OAAOA,IAAI,CAAC,eAAe,KAAK,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"}