@module-federation/enhanced 0.1.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 (27) hide show
  1. package/package.json +2 -4
  2. package/src/lib/container/AsyncBoundaryPlugin.d.ts +11 -43
  3. package/src/lib/container/AsyncBoundaryPlugin.js +76 -93
  4. package/src/lib/container/AsyncBoundaryPlugin.js.map +1 -1
  5. package/src/lib/container/ContainerEntryModule.js +3 -1
  6. package/src/lib/container/ContainerEntryModule.js.map +1 -1
  7. package/src/lib/container/ContainerEntryModuleFactory.js +2 -1
  8. package/src/lib/container/ContainerEntryModuleFactory.js.map +1 -1
  9. package/src/lib/container/ContainerReferencePlugin.js +3 -1
  10. package/src/lib/container/ContainerReferencePlugin.js.map +1 -1
  11. package/src/lib/container/FallbackModuleFactory.js +2 -1
  12. package/src/lib/container/FallbackModuleFactory.js.map +1 -1
  13. package/src/lib/container/ModuleFederationPlugin.js +1 -1
  14. package/src/lib/container/ModuleFederationPlugin.js.map +1 -1
  15. package/src/lib/sharing/ConsumeSharedModule.js +3 -1
  16. package/src/lib/sharing/ConsumeSharedModule.js.map +1 -1
  17. package/src/lib/sharing/ConsumeSharedPlugin.js +3 -1
  18. package/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -1
  19. package/src/lib/sharing/ConsumeSharedRuntimeModule.js +3 -1
  20. package/src/lib/sharing/ConsumeSharedRuntimeModule.js.map +1 -1
  21. package/src/lib/sharing/ProvideSharedModule.js +3 -1
  22. package/src/lib/sharing/ProvideSharedModule.js.map +1 -1
  23. package/src/lib/sharing/ShareRuntimeModule.js +3 -1
  24. package/src/lib/sharing/ShareRuntimeModule.js.map +1 -1
  25. package/src/schemas/container/ModuleFederationPlugin.check.d.ts +10 -0
  26. package/CHANGELOG.md +0 -134
  27. package/README.md +0 -11
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ConsumeSharedModule.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 { RawSource } from 'webpack-sources';\n//@ts-ignore\nimport AsyncDependenciesBlock from 'webpack/lib/AsyncDependenciesBlock';\nimport type {\n WebpackOptions,\n Compilation,\n UpdateHashContext,\n CodeGenerationContext,\n CodeGenerationResult,\n LibIdentOptions,\n NeedBuildContext,\n RequestShortener,\n ResolverWithOptions,\n WebpackError,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n Hash,\n InputFileSystem,\n} from 'webpack/lib/Module';\n//@ts-ignore\nimport Module from 'webpack/lib/Module';\nimport { WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE } from 'webpack/lib/ModuleTypeConstants';\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\n//@ts-ignore\nimport makeSerializable from 'webpack/lib/util/makeSerializable';\nimport { rangeToString, stringifyHoley } from 'webpack/lib/util/semver';\nimport ConsumeSharedFallbackDependency from './ConsumeSharedFallbackDependency';\nexport type ConsumeOptions = {\n /**\n * fallback request\n */\n import?: string | undefined;\n /**\n * resolved fallback request\n */\n importResolved?: string | undefined;\n /**\n * global share key\n */\n shareKey: string;\n /**\n * share scope\n */\n shareScope: string;\n /**\n * version requirement\n */\n requiredVersion:\n | import('webpack/lib/util/semver').SemVerRange\n | false\n | undefined;\n /**\n * package name to determine required version automatically\n */\n packageName: string;\n /**\n * don't use shared version even if version isn't valid\n */\n strictVersion: boolean;\n /**\n * use single global version\n */\n singleton: boolean;\n /**\n * include the fallback module in a sync way\n */\n eager: boolean;\n};\n\n/**\n * @typedef {Object} ConsumeOptions\n * @property {string=} import fallback request\n * @property {string=} importResolved resolved fallback request\n * @property {string} shareKey global share key\n * @property {string} shareScope share scope\n * @property {SemVerRange | false | undefined} requiredVersion version requirement\n * @property {string} packageName package name to determine required version automatically\n * @property {boolean} strictVersion don't use shared version even if version isn't valid\n * @property {boolean} singleton use single global version\n * @property {boolean} eager include the fallback module in a sync way\n */\n\nconst TYPES = new Set(['consume-shared']);\n\nclass ConsumeSharedModule extends Module {\n options: ConsumeOptions;\n\n /**\n * @param {string} context context\n * @param {ConsumeOptions} options consume options\n */\n constructor(context: string, options: ConsumeOptions) {\n super(WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE, context);\n this.options = options;\n }\n\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n const {\n shareKey,\n shareScope,\n importResolved,\n requiredVersion,\n strictVersion,\n singleton,\n eager,\n } = this.options;\n return `${WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE}|${shareScope}|${shareKey}|${\n requiredVersion && rangeToString(requiredVersion)\n }|${strictVersion}|${importResolved}|${singleton}|${eager}`;\n }\n\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n const {\n shareKey,\n shareScope,\n importResolved,\n requiredVersion,\n strictVersion,\n singleton,\n eager,\n } = this.options;\n return `consume shared module (${shareScope}) ${shareKey}@${\n requiredVersion ? rangeToString(requiredVersion) : '*'\n }${strictVersion ? ' (strict)' : ''}${singleton ? ' (singleton)' : ''}${\n importResolved\n ? ` (fallback: ${requestShortener.shorten(importResolved)})`\n : ''\n }${eager ? ' (eager)' : ''}`;\n }\n\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n const { shareKey, shareScope, import: request } = this.options;\n return `${\n this.layer ? `(${this.layer})/` : ''\n }webpack/sharing/consume/${shareScope}/${shareKey}${\n request ? `/${request}` : ''\n }`;\n }\n\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (error?: WebpackError | null, needsRebuild?: boolean) => void,\n ): void {\n callback(null, !this.buildInfo);\n }\n\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError=): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (error?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {};\n if (this.options.import) {\n const dep = new ConsumeSharedFallbackDependency(this.options.import);\n if (this.options.eager) {\n this.addDependency(dep);\n } else {\n const block = new AsyncDependenciesBlock({});\n block.addDependency(dep);\n this.addBlock(block);\n }\n }\n callback();\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return TYPES;\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 42;\n }\n\n /**\n * @param {Hash} hash the hash used to track dependencies\n * @param {UpdateHashContext} context context\n * @returns {void}\n */\n override updateHash(hash: Hash, context: UpdateHashContext): void {\n hash.update(JSON.stringify(this.options));\n super.updateHash(hash, context);\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n override codeGeneration({\n chunkGraph,\n moduleGraph,\n runtimeTemplate,\n }: CodeGenerationContext): CodeGenerationResult {\n const runtimeRequirements = new Set([RuntimeGlobals.shareScopeMap]);\n const {\n shareScope,\n shareKey,\n strictVersion,\n requiredVersion,\n import: request,\n singleton,\n eager,\n } = this.options;\n let fallbackCode;\n if (request) {\n if (eager) {\n const dep = this.dependencies[0];\n fallbackCode = runtimeTemplate.syncModuleFactory({\n dependency: dep,\n chunkGraph,\n runtimeRequirements,\n request: this.options.import,\n });\n } else {\n const block = this.blocks[0];\n fallbackCode = runtimeTemplate.asyncModuleFactory({\n block,\n chunkGraph,\n runtimeRequirements,\n request: this.options.import,\n });\n }\n }\n let fn = 'load';\n const args = [JSON.stringify(shareScope), JSON.stringify(shareKey)];\n if (requiredVersion) {\n if (strictVersion) {\n fn += 'Strict';\n }\n if (singleton) {\n fn += 'Singleton';\n }\n args.push(stringifyHoley(requiredVersion));\n fn += 'VersionCheck';\n } else {\n if (singleton) {\n fn += 'Singleton';\n }\n }\n if (fallbackCode) {\n fn += 'Fallback';\n args.push(fallbackCode);\n }\n const code = runtimeTemplate.returningFunction(`${fn}(${args.join(', ')})`);\n const sources = new Map();\n sources.set('consume-shared', new RawSource(code));\n return {\n runtimeRequirements,\n sources,\n };\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this.options);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n */\n override deserialize(context: ObjectDeserializerContext): void {\n const { read } = context;\n this.options = read();\n super.deserialize(context);\n }\n}\n\nmakeSerializable(\n ConsumeSharedModule,\n 'enhanced/lib/sharing/ConsumeSharedModule',\n);\n\nexport default ConsumeSharedModule;\n"],"names":["TYPES","Set","ConsumeSharedModule","Module","identifier","shareKey","shareScope","importResolved","requiredVersion","strictVersion","singleton","eager","options","WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE","rangeToString","readableIdentifier","requestShortener","shorten","libIdent","import","request","layer","needBuild","context","callback","buildInfo","build","compilation","resolver","fs","buildMeta","dep","ConsumeSharedFallbackDependency","addDependency","block","AsyncDependenciesBlock","addBlock","getSourceTypes","size","type","updateHash","hash","update","JSON","stringify","codeGeneration","chunkGraph","moduleGraph","runtimeTemplate","runtimeRequirements","RuntimeGlobals","shareScopeMap","fallbackCode","dependencies","syncModuleFactory","dependency","blocks","asyncModuleFactory","fn","args","push","stringifyHoley","code","returningFunction","join","sources","Map","set","RawSource","serialize","write","deserialize","read","constructor","makeSerializable"],"mappings":"AAAA;;;AAGA,GAEA;;;;+BAuTA;;;eAAA;;;gCArT0B;+EAES;+DAkBhB;q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Q;QACzD,MAAM,EAAE+C,KAAK,EAAE,GAAG/C;QAClB+C,MAAM,IAAI,CAAC1D,OAAO;QAClB,KAAK,CAACyD,UAAU9C;IAClB;IAEA;;GAEC,GACD,AAASgD,YAAYhD,OAAkC,EAAQ;QAC7D,MAAM,EAAEiD,IAAI,EAAE,GAAGjD;QACjB,IAAI,CAACX,OAAO,GAAG4D;QACf,KAAK,CAACD,YAAYhD;IACpB;IAtNA;;;GAGC,GACDkD,YAAYlD,OAAe,EAAEX,OAAuB,CAAE;QACpD,KAAK,CAACC,8DAAyC,EAAEU;QACjD,IAAI,CAACX,OAAO,GAAGA;IACjB;AAgNF;AAEA8D,IAAAA,yBAAgB,EACdxE,qBACA;MAGF,WAAeA"}
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ConsumeSharedModule.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 { RawSource } from 'webpack-sources';\n//@ts-ignore\nimport AsyncDependenciesBlock from 'webpack/lib/AsyncDependenciesBlock';\nimport type {\n WebpackOptions,\n Compilation,\n UpdateHashContext,\n CodeGenerationContext,\n CodeGenerationResult,\n LibIdentOptions,\n NeedBuildContext,\n RequestShortener,\n ResolverWithOptions,\n WebpackError,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n Hash,\n InputFileSystem,\n} from 'webpack/lib/Module';\n//@ts-ignore\nimport Module from 'webpack/lib/Module';\nimport { WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE } from 'webpack/lib/ModuleTypeConstants';\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\n//@ts-ignore\nimport makeSerializable from 'webpack/lib/util/makeSerializable';\nimport { rangeToString, stringifyHoley } from 'webpack/lib/util/semver';\nimport ConsumeSharedFallbackDependency from './ConsumeSharedFallbackDependency';\nexport type ConsumeOptions = {\n /**\n * fallback request\n */\n import?: string | undefined;\n /**\n * resolved fallback request\n */\n importResolved?: string | undefined;\n /**\n * global share key\n */\n shareKey: string;\n /**\n * share scope\n */\n shareScope: string;\n /**\n * version requirement\n */\n requiredVersion:\n | import('webpack/lib/util/semver').SemVerRange\n | false\n | undefined;\n /**\n * package name to determine required version automatically\n */\n packageName: string;\n /**\n * don't use shared version even if version isn't valid\n */\n strictVersion: boolean;\n /**\n * use single global version\n */\n singleton: boolean;\n /**\n * include the fallback module in a sync way\n */\n eager: boolean;\n};\n\n/**\n * @typedef {Object} ConsumeOptions\n * @property {string=} import fallback request\n * @property {string=} importResolved resolved fallback request\n * @property {string} shareKey global share key\n * @property {string} shareScope share scope\n * @property {SemVerRange | false | undefined} requiredVersion version requirement\n * @property {string} packageName package name to determine required version automatically\n * @property {boolean} strictVersion don't use shared version even if version isn't valid\n * @property {boolean} singleton use single global version\n * @property {boolean} eager include the fallback module in a sync way\n */\n\nconst TYPES = new Set(['consume-shared']);\n\nclass ConsumeSharedModule extends Module {\n options: ConsumeOptions;\n\n /**\n * @param {string} context context\n * @param {ConsumeOptions} options consume options\n */\n constructor(context: string, options: ConsumeOptions) {\n super(WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE, context);\n this.options = options;\n }\n\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n const {\n shareKey,\n shareScope,\n importResolved,\n requiredVersion,\n strictVersion,\n singleton,\n eager,\n } = this.options;\n return `${WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE}|${shareScope}|${shareKey}|${\n requiredVersion && rangeToString(requiredVersion)\n }|${strictVersion}|${importResolved}|${singleton}|${eager}`;\n }\n\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n const {\n shareKey,\n shareScope,\n importResolved,\n requiredVersion,\n strictVersion,\n singleton,\n eager,\n } = this.options;\n return `consume shared module (${shareScope}) ${shareKey}@${\n requiredVersion ? rangeToString(requiredVersion) : '*'\n }${strictVersion ? ' (strict)' : ''}${singleton ? ' (singleton)' : ''}${\n importResolved\n ? ` (fallback: ${requestShortener.shorten(importResolved)})`\n : ''\n }${eager ? ' (eager)' : ''}`;\n }\n\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n const { shareKey, shareScope, import: request } = this.options;\n return `${\n this.layer ? `(${this.layer})/` : ''\n }webpack/sharing/consume/${shareScope}/${shareKey}${\n request ? `/${request}` : ''\n }`;\n }\n\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (error?: WebpackError | null, needsRebuild?: boolean) => void,\n ): void {\n callback(null, !this.buildInfo);\n }\n\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError=): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (error?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {};\n if (this.options.import) {\n const dep = new ConsumeSharedFallbackDependency(this.options.import);\n if (this.options.eager) {\n this.addDependency(dep);\n } else {\n const block = new AsyncDependenciesBlock({});\n block.addDependency(dep);\n this.addBlock(block);\n }\n }\n callback();\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return TYPES;\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 42;\n }\n\n /**\n * @param {Hash} hash the hash used to track dependencies\n * @param {UpdateHashContext} context context\n * @returns {void}\n */\n override updateHash(hash: Hash, context: UpdateHashContext): void {\n hash.update(JSON.stringify(this.options));\n super.updateHash(hash, context);\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n override codeGeneration({\n chunkGraph,\n moduleGraph,\n runtimeTemplate,\n }: CodeGenerationContext): CodeGenerationResult {\n const runtimeRequirements = new Set([RuntimeGlobals.shareScopeMap]);\n const {\n shareScope,\n shareKey,\n strictVersion,\n requiredVersion,\n import: request,\n singleton,\n eager,\n } = this.options;\n let fallbackCode;\n if (request) {\n if (eager) {\n const dep = this.dependencies[0];\n fallbackCode = runtimeTemplate.syncModuleFactory({\n dependency: dep,\n chunkGraph,\n runtimeRequirements,\n request: this.options.import,\n });\n } else {\n const block = this.blocks[0];\n fallbackCode = runtimeTemplate.asyncModuleFactory({\n block,\n chunkGraph,\n runtimeRequirements,\n request: this.options.import,\n });\n }\n }\n let fn = 'load';\n const args = [JSON.stringify(shareScope), JSON.stringify(shareKey)];\n if (requiredVersion) {\n if (strictVersion) {\n fn += 'Strict';\n }\n if (singleton) {\n fn += 'Singleton';\n }\n args.push(stringifyHoley(requiredVersion));\n fn += 'VersionCheck';\n } else {\n if (singleton) {\n fn += 'Singleton';\n }\n }\n if (fallbackCode) {\n fn += 'Fallback';\n args.push(fallbackCode);\n }\n const code = runtimeTemplate.returningFunction(`${fn}(${args.join(', ')})`);\n const sources = new Map();\n sources.set('consume-shared', new RawSource(code));\n return {\n runtimeRequirements,\n sources,\n };\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this.options);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n */\n override deserialize(context: ObjectDeserializerContext): void {\n const { read } = context;\n this.options = read();\n super.deserialize(context);\n }\n}\n\nmakeSerializable(\n ConsumeSharedModule,\n 'enhanced/lib/sharing/ConsumeSharedModule',\n);\n\nexport default ConsumeSharedModule;\n"],"names":["TYPES","Set","ConsumeSharedModule","Module","identifier","shareKey","shareScope","importResolved","requiredVersion","strictVersion","singleton","eager","options","WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE","rangeToString","readableIdentifier","requestShortener","shorten","libIdent","import","request","layer","needBuild","context","callback","buildInfo","build","compilation","resolver","fs","buildMeta","dep","ConsumeSharedFallbackDependency","addDependency","block","AsyncDependenciesBlock","addBlock","getSourceTypes","size","type","updateHash","hash","update","JSON","stringify","codeGeneration","chunkGraph","moduleGraph","runtimeTemplate","runtimeRequirements","RuntimeGlobals","shareScopeMap","fallbackCode","dependencies","syncModuleFactory","dependency","blocks","asyncModuleFactory","fn","args","push","stringifyHoley","code","returningFunction","join","sources","Map","set","RawSource","serialize","write","deserialize","read","constructor","makeSerializable"],"mappings":"AAAA;;;AAGA,GAEA;;;;+BAuTA;;;eAAA;;;gCArT0B;+EAES;+DAkBhB;qCACuC;wEAC1B;yEAEH;wBACiB;wFACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2C5C;;;;;;;;;;;CAWC,GAED,MAAMA,QAAQ,IAAIC,IAAI;IAAC;CAAiB;AAExC,IAAA,AAAMC,sBAAN,MAAMA,4BAA4BC,eAAM;IAYtC;;GAEC,GACD,AAASC,aAAqB;QAC5B,MAAM,EACJC,QAAQ,EACRC,UAAU,EACVC,cAAc,EACdC,eAAe,EACfC,aAAa,EACbC,SAAS,EACTC,KAAK,EACN,GAAG,IAAI,CAACC,OAAO;QAChB,OAAO,CAAC,EAAEC,8DAAyC,CAAC,CAAC,EAAEP,WAAW,CAAC,EAAED,SAAS,CAAC,EAC7EG,mBAAmBM,IAAAA,qBAAa,EAACN,iBAClC,CAAC,EAAEC,cAAc,CAAC,EAAEF,eAAe,CAAC,EAAEG,UAAU,CAAC,EAAEC,MAAM,CAAC;IAC7D;IAEA;;;GAGC,GACD,AAASI,mBAAmBC,gBAAkC,EAAU;QACtE,MAAM,EACJX,QAAQ,EACRC,UAAU,EACVC,cAAc,EACdC,eAAe,EACfC,aAA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AIC,eAAe;gBACjBiD,MAAM;YACR;YACA,IAAIhD,WAAW;gBACbgD,MAAM;YACR;YACAC,KAAKC,IAAI,CAACC,IAAAA,sBAAc,EAACrD;YACzBkD,MAAM;QACR,OAAO;YACL,IAAIhD,WAAW;gBACbgD,MAAM;YACR;QACF;QACA,IAAIN,cAAc;YAChBM,MAAM;YACNC,KAAKC,IAAI,CAACR;QACZ;QACA,MAAMU,OAAOd,gBAAgBe,iBAAiB,CAAC,CAAC,EAAEL,GAAG,CAAC,EAAEC,KAAKK,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1E,MAAMC,UAAU,IAAIC;QACpBD,QAAQE,GAAG,CAAC,kBAAkB,IAAIC,yBAAS,CAACN;QAC5C,OAAO;YACLb;YACAgB;QACF;IACF;IAEA;;GAEC,GACD,AAASI,UAAU9C,OAAgC,EAAQ;QACzD,MAAM,EAAE+C,KAAK,EAAE,GAAG/C;QAClB+C,MAAM,IAAI,CAAC1D,OAAO;QAClB,KAAK,CAACyD,UAAU9C;IAClB;IAEA;;GAEC,GACD,AAASgD,YAAYhD,OAAkC,EAAQ;QAC7D,MAAM,EAAEiD,IAAI,EAAE,GAAGjD;QACjB,IAAI,CAACX,OAAO,GAAG4D;QACf,KAAK,CAACD,YAAYhD;IACpB;IAtNA;;;GAGC,GACDkD,YAAYlD,OAAe,EAAEX,OAAuB,CAAE;QACpD,KAAK,CAACC,8DAAyC,EAAEU;QACjD,IAAI,CAACX,OAAO,GAAGA;IACjB;AAgNF;AAEA8D,IAAAA,yBAAgB,EACdxE,qBACA;MAGF,WAAeA"}
@@ -64,7 +64,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
64
64
  if (cache && cache.has(obj)) {
65
65
  return cache.get(obj);
66
66
  }
67
- var newObj = {};
67
+ var newObj = {
68
+ __proto__: null
69
+ };
68
70
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
69
71
  for(var key in obj){
70
72
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ConsumeSharedPlugin.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 { parseOptions } from '../container/options';\nimport { ConsumeOptions } from './ConsumeSharedModule';\nimport { ConsumeSharedPluginOptions } from '../../declarations/plugins/sharing/ConsumeSharedPlugin';\nimport { parseRange } from 'webpack/lib/util/semver';\nimport { resolveMatchedConfigs } from './resolveMatchedConfigs';\nimport {\n isRequiredVersion,\n getDescriptionFile,\n getRequiredVersionFromDescriptionFile,\n} from './utils';\nimport type { ResolveOptionsWithDependencyType } from 'webpack/lib/ResolverFactory';\nimport ConsumeSharedFallbackDependency from './ConsumeSharedFallbackDependency';\nimport ConsumeSharedModule from './ConsumeSharedModule';\nimport ConsumeSharedRuntimeModule from './ConsumeSharedRuntimeModule';\nimport ProvideForSharedDependency from './ProvideForSharedDependency';\n//@ts-ignore\nimport ModuleNotFoundError from 'webpack/lib/ModuleNotFoundError';\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\n//@ts-ignore\nimport WebpackError from 'webpack/lib/WebpackError';\n//@ts-ignore\nimport Compiler from 'webpack/lib/Compiler';\n//@ts-ignore\nimport LazySet from 'webpack/lib/util/LazySet';\n//@ts-ignore\nimport createSchemaValidation from 'webpack/lib/util/create-schema-validation';\nimport { SemVerRange } from 'webpack/lib/util/semver';\n\nconst validate = createSchemaValidation(\n //eslint-disable-next-line\n require('webpack/schemas/plugins/sharing/ConsumeSharedPlugin.check.js'),\n () => require('webpack/schemas/plugins/sharing/ConsumeSharedPlugin.json'),\n {\n name: 'Consume Shared Plugin',\n baseDataPath: 'options',\n },\n);\n\nconst RESOLVE_OPTIONS: ResolveOptionsWithDependencyType = {\n dependencyType: 'esm',\n};\nconst PLUGIN_NAME = 'ConsumeSharedPlugin';\nclass ConsumeSharedPlugin {\n private _consumes: [string, ConsumeOptions][];\n\n constructor(options: ConsumeSharedPluginOptions) {\n if (typeof options !== 'string') {\n validate(options);\n }\n\n this._consumes = parseOptions(\n options.consumes,\n (item, key) => {\n if (Array.isArray(item)) throw new Error('Unexpected array in options');\n //@ts-ignore\n const result: ConsumeOptions =\n item === key || !isRequiredVersion(item)\n ? // item is a request/key\n {\n import: key,\n shareScope: options.shareScope || 'default',\n shareKey: key,\n requiredVersion: undefined,\n packageName: undefined,\n strictVersion: false,\n singleton: false,\n eager: false,\n }\n : // key is a request/key\n // item is a version\n {\n import: key,\n shareScope: options.shareScope || 'default',\n shareKey: key,\n requiredVersion: parseRange(item),\n strictVersion: true,\n packageName: undefined,\n singleton: false,\n eager: false,\n };\n return result;\n },\n (item, key) => ({\n import: item.import === false ? undefined : item.import || key,\n shareScope: item.shareScope || options.shareScope || 'default',\n shareKey: item.shareKey || key,\n requiredVersion:\n typeof item.requiredVersion === 'string'\n ? parseRange(item.requiredVersion)\n : item.requiredVersion,\n strictVersion:\n typeof item.strictVersion === 'boolean'\n ? item.strictVersion\n : item.import !== false && !item.singleton,\n //@ts-ignore\n packageName: item.packageName,\n singleton: !!item.singleton,\n eager: !!item.eager,\n }),\n );\n }\n\n apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n ConsumeSharedFallbackDependency,\n normalModuleFactory,\n );\n\n let unresolvedConsumes: Map<string, ConsumeOptions>,\n resolvedConsumes: Map<string, ConsumeOptions>,\n prefixedConsumes: Map<string, ConsumeOptions>;\n const promise = resolveMatchedConfigs(compilation, this._consumes).then(\n ({ resolved, unresolved, prefixed }) => {\n resolvedConsumes = resolved;\n unresolvedConsumes = unresolved;\n prefixedConsumes = prefixed;\n },\n );\n\n const resolver = compilation.resolverFactory.get(\n 'normal',\n RESOLVE_OPTIONS,\n );\n\n const createConsumeSharedModule = (\n context: string,\n request: string,\n config: ConsumeOptions,\n ): Promise<ConsumeSharedModule> => {\n const requiredVersionWarning = (details: string) => {\n const error = new WebpackError(\n `No required version specified and unable to automatically determine one. ${details}`,\n );\n error.file = `shared module ${request}`;\n compilation.warnings.push(error);\n };\n const directFallback =\n config.import &&\n /^(\\.\\.?(\\/|$)|\\/|[A-Za-z]:|\\\\\\\\)/.test(config.import);\n return Promise.all([\n new Promise<string | undefined>((resolve) => {\n if (!config.import) return resolve(undefined);\n const resolveContext = {\n fileDependencies: new LazySet<string>(),\n contextDependencies: new LazySet<string>(),\n missingDependencies: new LazySet<string>(),\n };\n resolver.resolve(\n {},\n directFallback ? compiler.context : context,\n config.import,\n resolveContext,\n (err, result) => {\n compilation.contextDependencies.addAll(\n resolveContext.contextDependencies,\n );\n compilation.fileDependencies.addAll(\n resolveContext.fileDependencies,\n );\n compilation.missingDependencies.addAll(\n resolveContext.missingDependencies,\n );\n if (err) {\n compilation.errors.push(\n new ModuleNotFoundError(null, err, {\n name: `resolving fallback for shared module ${request}`,\n }),\n );\n return resolve(undefined);\n }\n //@ts-ignore\n resolve(result);\n },\n );\n }),\n new Promise<false | undefined | SemVerRange>((resolve) => {\n if (config.requiredVersion !== undefined) {\n return resolve(config.requiredVersion);\n }\n let packageName = config.packageName;\n if (packageName === undefined) {\n if (/^(\\/|[A-Za-z]:|\\\\\\\\)/.test(request)) {\n // For relative or absolute requests we don't automatically use a packageName.\n // If wished one can specify one with the packageName option.\n return resolve(undefined);\n }\n const match = /^((?:@[^\\\\/]+[\\\\/])?[^\\\\/]+)/.exec(request);\n if (!match) {\n requiredVersionWarning(\n 'Unable to extract the package name from request.',\n );\n return resolve(undefined);\n }\n packageName = match[0];\n }\n\n getDescriptionFile(\n compilation.inputFileSystem,\n context,\n ['package.json'],\n (err, result) => {\n if (err) {\n requiredVersionWarning(\n `Unable to read description file: ${err}`,\n );\n return resolve(undefined);\n }\n //@ts-ignore\n const { data, path: descriptionPath } = result;\n if (!data) {\n requiredVersionWarning(\n `Unable to find description file in ${context}.`,\n );\n return resolve(undefined);\n }\n //@ts-ignore\n if (data.name === packageName) {\n // Package self-referencing\n return resolve(undefined);\n }\n const requiredVersion = getRequiredVersionFromDescriptionFile(\n data,\n packageName,\n );\n if (typeof requiredVersion !== 'string') {\n requiredVersionWarning(\n `Unable to find required version for \"${packageName}\" in description file (${descriptionPath}). It need to be in dependencies, devDependencies or peerDependencies.`,\n );\n return resolve(undefined);\n }\n resolve(parseRange(requiredVersion));\n },\n );\n }),\n ]).then(([importResolved, requiredVersion]) => {\n return new ConsumeSharedModule(\n directFallback ? compiler.context : context,\n {\n ...config,\n importResolved,\n import: importResolved ? config.import : undefined,\n requiredVersion,\n },\n );\n });\n };\n\n normalModuleFactory.hooks.factorize.tapPromise(\n PLUGIN_NAME,\n ({ context, request, dependencies }) =>\n // wait for resolving to be complete\n //@ts-ignore\n promise.then(() => {\n if (\n dependencies[0] instanceof ConsumeSharedFallbackDependency ||\n dependencies[0] instanceof ProvideForSharedDependency\n ) {\n return;\n }\n const match = unresolvedConsumes.get(request);\n if (match !== undefined) {\n return createConsumeSharedModule(context, request, match);\n }\n for (const [prefix, options] of prefixedConsumes) {\n if (request.startsWith(prefix)) {\n const remainder = request.slice(prefix.length);\n return createConsumeSharedModule(context, request, {\n ...options,\n import: options.import\n ? options.import + remainder\n : undefined,\n shareKey: options.shareKey + remainder,\n });\n }\n }\n }),\n );\n normalModuleFactory.hooks.createModule.tapPromise(\n PLUGIN_NAME,\n ({ resource }, { context, dependencies }) => {\n if (\n dependencies[0] instanceof ConsumeSharedFallbackDependency ||\n dependencies[0] instanceof ProvideForSharedDependency\n ) {\n return Promise.resolve();\n }\n if (resource) {\n const options = resolvedConsumes.get(resource);\n if (options !== undefined) {\n return createConsumeSharedModule(context, resource, options);\n }\n }\n return Promise.resolve();\n },\n );\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n PLUGIN_NAME,\n (chunk, set) => {\n set.add(RuntimeGlobals.module);\n set.add(RuntimeGlobals.moduleCache);\n set.add(RuntimeGlobals.moduleFactoriesAddOnly);\n set.add(RuntimeGlobals.shareScopeMap);\n set.add(RuntimeGlobals.initializeSharing);\n set.add(RuntimeGlobals.hasOwnProperty);\n compilation.addRuntimeModule(\n chunk,\n new ConsumeSharedRuntimeModule(set),\n );\n },\n );\n },\n );\n }\n}\n\nexport default ConsumeSharedPlugin;\n"],"names":["validate","createSchemaValidation","require","name","baseDataPath","RESOLVE_OPTIONS","dependencyType","PLUGIN_NAME","ConsumeSharedPlugin","apply","compiler","hooks","thisCompilation","tap","compilation","normalModuleFactory","dependencyFactories","set","ConsumeSharedFallbackDependency","unresolvedConsumes","resolvedConsumes","prefixedConsumes","promise","resolveMatchedConfigs","_consumes","then","resolved","unresolved","prefixed","resolver","resolverFactory","get","createConsumeSharedModule","context","request","config","requiredVersionWarning","details","error","WebpackError","file","warnings","push","directFallback","import","test","Promise","all","resolve","undefined","resolveContext","fileDependencies","LazySet","contextDependencies","missingDependencies","err","result","addAll","errors","ModuleNotFoundError","requiredVersion","packageName","match","exec","getDescriptionFile","inputFileSystem","data","path","descriptionPath","getRequiredVersionFromDescriptionFile","parseRange","importResolved","ConsumeSharedModule","factorize","tapPromise","dependencies","ProvideForSharedDependency","prefix","options","startsWith","remainder","slice","length","shareKey","createModule","resource","additionalTreeRuntimeRequirements","chunk","add","RuntimeGlobals","module","moduleCache","moduleFactoriesAddOnly","shareScopeMap","initializeSharing","hasOwnProperty","addRuntimeModule","ConsumeSharedRuntimeModule","constructor","parseOptions","consumes","item","key","Array","isArray","Error","isRequiredVersion","shareScope","strictVersion","singleton","eager"],"mappings":"AAAA;;;AAGA,GAEA;;;;+BAgUA;;;eAAA;;;yBA9T6B;wBAGF;uCACW;uBAK/B;wFAEqC;4EACZ;mFACO;mFACA;4EAEP;wEACA;qEAEP;gEAIL;+EAEe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGnC,M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eSharedPlugin.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 { parseOptions } from '../container/options';\nimport { ConsumeOptions } from './ConsumeSharedModule';\nimport { ConsumeSharedPluginOptions } from '../../declarations/plugins/sharing/ConsumeSharedPlugin';\nimport { parseRange } from 'webpack/lib/util/semver';\nimport { resolveMatchedConfigs } from './resolveMatchedConfigs';\nimport {\n isRequiredVersion,\n getDescriptionFile,\n getRequiredVersionFromDescriptionFile,\n} from './utils';\nimport type { ResolveOptionsWithDependencyType } from 'webpack/lib/ResolverFactory';\nimport ConsumeSharedFallbackDependency from './ConsumeSharedFallbackDependency';\nimport ConsumeSharedModule from './ConsumeSharedModule';\nimport ConsumeSharedRuntimeModule from './ConsumeSharedRuntimeModule';\nimport ProvideForSharedDependency from './ProvideForSharedDependency';\n//@ts-ignore\nimport ModuleNotFoundError from 'webpack/lib/ModuleNotFoundError';\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\n//@ts-ignore\nimport WebpackError from 'webpack/lib/WebpackError';\n//@ts-ignore\nimport Compiler from 'webpack/lib/Compiler';\n//@ts-ignore\nimport LazySet from 'webpack/lib/util/LazySet';\n//@ts-ignore\nimport createSchemaValidation from 'webpack/lib/util/create-schema-validation';\nimport { SemVerRange } from 'webpack/lib/util/semver';\n\nconst validate = createSchemaValidation(\n //eslint-disable-next-line\n require('webpack/schemas/plugins/sharing/ConsumeSharedPlugin.check.js'),\n () => require('webpack/schemas/plugins/sharing/ConsumeSharedPlugin.json'),\n {\n name: 'Consume Shared Plugin',\n baseDataPath: 'options',\n },\n);\n\nconst RESOLVE_OPTIONS: ResolveOptionsWithDependencyType = {\n dependencyType: 'esm',\n};\nconst PLUGIN_NAME = 'ConsumeSharedPlugin';\nclass ConsumeSharedPlugin {\n private _consumes: [string, ConsumeOptions][];\n\n constructor(options: ConsumeSharedPluginOptions) {\n if (typeof options !== 'string') {\n validate(options);\n }\n\n this._consumes = parseOptions(\n options.consumes,\n (item, key) => {\n if (Array.isArray(item)) throw new Error('Unexpected array in options');\n //@ts-ignore\n const result: ConsumeOptions =\n item === key || !isRequiredVersion(item)\n ? // item is a request/key\n {\n import: key,\n shareScope: options.shareScope || 'default',\n shareKey: key,\n requiredVersion: undefined,\n packageName: undefined,\n strictVersion: false,\n singleton: false,\n eager: false,\n }\n : // key is a request/key\n // item is a version\n {\n import: key,\n shareScope: options.shareScope || 'default',\n shareKey: key,\n requiredVersion: parseRange(item),\n strictVersion: true,\n packageName: undefined,\n singleton: false,\n eager: false,\n };\n return result;\n },\n (item, key) => ({\n import: item.import === false ? undefined : item.import || key,\n shareScope: item.shareScope || options.shareScope || 'default',\n shareKey: item.shareKey || key,\n requiredVersion:\n typeof item.requiredVersion === 'string'\n ? parseRange(item.requiredVersion)\n : item.requiredVersion,\n strictVersion:\n typeof item.strictVersion === 'boolean'\n ? item.strictVersion\n : item.import !== false && !item.singleton,\n //@ts-ignore\n packageName: item.packageName,\n singleton: !!item.singleton,\n eager: !!item.eager,\n }),\n );\n }\n\n apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n ConsumeSharedFallbackDependency,\n normalModuleFactory,\n );\n\n let unresolvedConsumes: Map<string, ConsumeOptions>,\n resolvedConsumes: Map<string, ConsumeOptions>,\n prefixedConsumes: Map<string, ConsumeOptions>;\n const promise = resolveMatchedConfigs(compilation, this._consumes).then(\n ({ resolved, unresolved, prefixed }) => {\n resolvedConsumes = resolved;\n unresolvedConsumes = unresolved;\n prefixedConsumes = prefixed;\n },\n );\n\n const resolver = compilation.resolverFactory.get(\n 'normal',\n RESOLVE_OPTIONS,\n );\n\n const createConsumeSharedModule = (\n context: string,\n request: string,\n config: ConsumeOptions,\n ): Promise<ConsumeSharedModule> => {\n const requiredVersionWarning = (details: string) => {\n const error = new WebpackError(\n `No required version specified and unable to automatically determine one. ${details}`,\n );\n error.file = `shared module ${request}`;\n compilation.warnings.push(error);\n };\n const directFallback =\n config.import &&\n /^(\\.\\.?(\\/|$)|\\/|[A-Za-z]:|\\\\\\\\)/.test(config.import);\n return Promise.all([\n new Promise<string | undefined>((resolve) => {\n if (!config.import) return resolve(undefined);\n const resolveContext = {\n fileDependencies: new LazySet<string>(),\n contextDependencies: new LazySet<string>(),\n missingDependencies: new LazySet<string>(),\n };\n resolver.resolve(\n {},\n directFallback ? compiler.context : context,\n config.import,\n resolveContext,\n (err, result) => {\n compilation.contextDependencies.addAll(\n resolveContext.contextDependencies,\n );\n compilation.fileDependencies.addAll(\n resolveContext.fileDependencies,\n );\n compilation.missingDependencies.addAll(\n resolveContext.missingDependencies,\n );\n if (err) {\n compilation.errors.push(\n new ModuleNotFoundError(null, err, {\n name: `resolving fallback for shared module ${request}`,\n }),\n );\n return resolve(undefined);\n }\n //@ts-ignore\n resolve(result);\n },\n );\n }),\n new Promise<false | undefined | SemVerRange>((resolve) => {\n if (config.requiredVersion !== undefined) {\n return resolve(config.requiredVersion);\n }\n let packageName = config.packageName;\n if (packageName === undefined) {\n if (/^(\\/|[A-Za-z]:|\\\\\\\\)/.test(request)) {\n // For relative or absolute requests we don't automatically use a packageName.\n // If wished one can specify one with the packageName option.\n return resolve(undefined);\n }\n const match = /^((?:@[^\\\\/]+[\\\\/])?[^\\\\/]+)/.exec(request);\n if (!match) {\n requiredVersionWarning(\n 'Unable to extract the package name from request.',\n );\n return resolve(undefined);\n }\n packageName = match[0];\n }\n\n getDescriptionFile(\n compilation.inputFileSystem,\n context,\n ['package.json'],\n (err, result) => {\n if (err) {\n requiredVersionWarning(\n `Unable to read description file: ${err}`,\n );\n return resolve(undefined);\n }\n //@ts-ignore\n const { data, path: descriptionPath } = result;\n if (!data) {\n requiredVersionWarning(\n `Unable to find description file in ${context}.`,\n );\n return resolve(undefined);\n }\n //@ts-ignore\n if (data.name === packageName) {\n // Package self-referencing\n return resolve(undefined);\n }\n const requiredVersion = getRequiredVersionFromDescriptionFile(\n data,\n packageName,\n );\n if (typeof requiredVersion !== 'string') {\n requiredVersionWarning(\n `Unable to find required version for \"${packageName}\" in description file (${descriptionPath}). It need to be in dependencies, devDependencies or peerDependencies.`,\n );\n return resolve(undefined);\n }\n resolve(parseRange(requiredVersion));\n },\n );\n }),\n ]).then(([importResolved, requiredVersion]) => {\n return new ConsumeSharedModule(\n directFallback ? compiler.context : context,\n {\n ...config,\n importResolved,\n import: importResolved ? config.import : undefined,\n requiredVersion,\n },\n );\n });\n };\n\n normalModuleFactory.hooks.factorize.tapPromise(\n PLUGIN_NAME,\n ({ context, request, dependencies }) =>\n // wait for resolving to be complete\n //@ts-ignore\n promise.then(() => {\n if (\n dependencies[0] instanceof ConsumeSharedFallbackDependency ||\n dependencies[0] instanceof ProvideForSharedDependency\n ) {\n return;\n }\n const match = unresolvedConsumes.get(request);\n if (match !== undefined) {\n return createConsumeSharedModule(context, request, match);\n }\n for (const [prefix, options] of prefixedConsumes) {\n if (request.startsWith(prefix)) {\n const remainder = request.slice(prefix.length);\n return createConsumeSharedModule(context, request, {\n ...options,\n import: options.import\n ? options.import + remainder\n : undefined,\n shareKey: options.shareKey + remainder,\n });\n }\n }\n }),\n );\n normalModuleFactory.hooks.createModule.tapPromise(\n PLUGIN_NAME,\n ({ resource }, { context, dependencies }) => {\n if (\n dependencies[0] instanceof ConsumeSharedFallbackDependency ||\n dependencies[0] instanceof ProvideForSharedDependency\n ) {\n return Promise.resolve();\n }\n if (resource) {\n const options = resolvedConsumes.get(resource);\n if (options !== undefined) {\n return createConsumeSharedModule(context, resource, options);\n }\n }\n return Promise.resolve();\n },\n );\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n PLUGIN_NAME,\n (chunk, set) => {\n set.add(RuntimeGlobals.module);\n set.add(RuntimeGlobals.moduleCache);\n set.add(RuntimeGlobals.moduleFactoriesAddOnly);\n set.add(RuntimeGlobals.shareScopeMap);\n set.add(RuntimeGlobals.initializeSharing);\n set.add(RuntimeGlobals.hasOwnProperty);\n compilation.addRuntimeModule(\n chunk,\n new ConsumeSharedRuntimeModule(set),\n );\n },\n );\n },\n );\n }\n}\n\nexport default ConsumeSharedPlugin;\n"],"names":["validate","createSchemaValidation","require","name","baseDataPath","RESOLVE_OPTIONS","dependencyType","PLUGIN_NAME","ConsumeSharedPlugin","apply","compiler","hooks","thisCompilation","tap","compilation","normalModuleFactory","dependencyFactories","set","ConsumeSharedFallbackDependency","unresolvedConsumes","resolvedConsumes","prefixedConsumes","promise","resolveMatchedConfigs","_consumes","then","resolved","unresolved","prefixed","resolver","resolverFactory","get","createConsumeSharedModule","context","request","config","requiredVersionWarning","details","error","WebpackError","file","warnings","push","directFallback","import","test","Promise","all","resolve","undefined","resolveContext","fileDependencies","LazySet","contextDependencies","missingDependencies","err","result","addAll","errors","ModuleNotFoundError","requiredVersion","packageName","match","exec","getDescriptionFile","inputFileSystem","data","path","descriptionPath","getRequiredVersionFromDescriptionFile","parseRange","importResolved","ConsumeSharedModule","factorize","tapPromise","dependencies","ProvideForSharedDependency","prefix","options","startsWith","remainder","slice","length","shareKey","createModule","resource","additionalTreeRuntimeRequirements","chunk","add","RuntimeGlobals","module","moduleCache","moduleFactoriesAddOnly","shareScopeMap","initializeSharing","hasOwnProperty","addRuntimeModule","ConsumeSharedRuntimeModule","constructor","parseOptions","consumes","item","key","Array","isArray","Error","isRequiredVersion","shareScope","strictVersion","singleton","eager"],"mappings":"AAAA;;;AAGA,GAEA;;;;+BAgUA;;;eAAA;;;yBA9T6B;wBAGF;uCACW;uBAK/B;wFAEqC;4EACZ;mFACO;mFACA;4EAEP;wEACA;qEAEP;gEAIL;+EAEe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGnC,MAAMA,WAAWC,IAAAA,+BAAsB,EACrC,0BAA0B;AAC1BC,QAAQ,iEACR,IAAMA,QA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MC,OAAO,CAACH,OAAO,MAAM,IAAII,MAAM;YACzC,YAAY;YACZ,MAAMjD,SACJ6C,SAASC,OAAO,CAACI,IAAAA,wBAAiB,EAACL,QAE/B;gBACEzD,QAAQ0D;gBACRK,YAAY7B,QAAQ6B,UAAU,IAAI;gBAClCxB,UAAUmB;gBACV1C,iBAAiBX;gBACjBY,aAAaZ;gBACb2D,eAAe;gBACfC,WAAW;gBACXC,OAAO;YACT,IAEA,oBAAoB;YACpB;gBACElE,QAAQ0D;gBACRK,YAAY7B,QAAQ6B,UAAU,IAAI;gBAClCxB,UAAUmB;gBACV1C,iBAAiBU,IAAAA,kBAAU,EAAC+B;gBAC5BO,eAAe;gBACf/C,aAAaZ;gBACb4D,WAAW;gBACXC,OAAO;YACT;YACN,OAAOtD;QACT,GACA,CAAC6C,MAAMC,MAAS,CAAA;gBACd1D,QAAQyD,KAAKzD,MAAM,KAAK,QAAQK,YAAYoD,KAAKzD,MAAM,IAAI0D;gBAC3DK,YAAYN,KAAKM,UAAU,IAAI7B,QAAQ6B,UAAU,IAAI;gBACrDxB,UAAUkB,KAAKlB,QAAQ,IAAImB;gBAC3B1C,iBACE,OAAOyC,KAAKzC,eAAe,KAAK,WAC5BU,IAAAA,kBAAU,EAAC+B,KAAKzC,eAAe,IAC/ByC,KAAKzC,eAAe;gBAC1BgD,eACE,OAAOP,KAAKO,aAAa,KAAK,YAC1BP,KAAKO,aAAa,GAClBP,KAAKzD,MAAM,KAAK,SAAS,CAACyD,KAAKQ,SAAS;gBAC9C,YAAY;gBACZhD,aAAawC,KAAKxC,WAAW;gBAC7BgD,WAAW,CAAC,CAACR,KAAKQ,SAAS;gBAC3BC,OAAO,CAAC,CAACT,KAAKS,KAAK;YACrB,CAAA;IAEJ;AAwNF;MAEA,WAAetG"}
@@ -41,7 +41,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
41
41
  if (cache && cache.has(obj)) {
42
42
  return cache.get(obj);
43
43
  }
44
- var newObj = {};
44
+ var newObj = {
45
+ __proto__: null
46
+ };
45
47
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
46
48
  for(var key in obj){
47
49
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ConsumeSharedRuntimeModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport Template from 'webpack/lib/Template';\nimport {\n parseVersionRuntimeCode,\n versionLtRuntimeCode,\n rangeToStringRuntimeCode,\n satisfyRuntimeCode,\n} from 'webpack/lib/util/semver';\nimport RuntimeModule from 'webpack/lib/RuntimeModule';\nimport Module from 'webpack/lib/Module';\nimport ConsumeSharedModule from './ConsumeSharedModule';\nimport type ChunkGraph from 'webpack/lib/ChunkGraph';\nimport type Compilation from 'webpack/lib/Compilation';\nimport type Chunk from 'webpack/lib/Chunk';\nimport { Source } from 'webpack-sources';\n\nclass ConsumeSharedRuntimeModule extends RuntimeModule {\n private _runtimeRequirements: ReadonlySet<string>;\n\n /**\n * @param {ReadonlySet<string>} runtimeRequirements runtime requirements\n */\n constructor(runtimeRequirements: ReadonlySet<string>) {\n super('consumes', RuntimeModule.STAGE_ATTACH);\n this._runtimeRequirements = runtimeRequirements;\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate(): string | null {\n const compilation: Compilation = this.compilation!;\n const chunkGraph: ChunkGraph = this.chunkGraph!;\n const { runtimeTemplate, codeGenerationResults } = compilation;\n const chunkToModuleMapping: Record<string, any> = {};\n const moduleIdToSourceMapping: Map<string | number, Source> = new Map();\n const initialConsumes: (string | number)[] = [];\n /**\n *\n * @param {Iterable<Module>} modules modules\n * @param {Chunk} chunk the chunk\n * @param {(string | number)[]} list list of ids\n */\n const addModules = (\n modules: Iterable<Module>,\n chunk: Chunk,\n list: (string | number)[],\n ) => {\n for (const m of modules) {\n const module: ConsumeSharedModule = m as ConsumeSharedModule;\n const id = chunkGraph.getModuleId(module);\n list.push(id);\n moduleIdToSourceMapping.set(\n id,\n codeGenerationResults.getSource(\n module,\n chunk.runtime,\n 'consume-shared',\n ),\n );\n }\n };\n const allChunks = [\n ...(this.chunk?.getAllAsyncChunks() || []),\n ...(this.chunk?.getAllInitialChunks() || []),\n ];\n for (const chunk of allChunks) {\n const modules = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'consume-shared',\n );\n if (!modules) continue;\n if (!chunk.id) continue;\n\n addModules(\n modules,\n chunk,\n (chunkToModuleMapping[chunk.id.toString()] = []),\n );\n }\n for (const chunk of [...(this.chunk?.getAllInitialChunks() || [])]) {\n const modules = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'consume-shared',\n );\n if (!modules) continue;\n addModules(modules, chunk, initialConsumes);\n }\n\n if (moduleIdToSourceMapping.size === 0) return null;\n\n return Template.asString([\n parseVersionRuntimeCode(runtimeTemplate),\n versionLtRuntimeCode(runtimeTemplate),\n rangeToStringRuntimeCode(runtimeTemplate),\n satisfyRuntimeCode(runtimeTemplate),\n `var ensureExistence = ${runtimeTemplate.basicFunction('scopeName, key', [\n `var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) throw new Error(\"Shared module \" + key + \" doesn't exist in shared scope \" + scopeName);`,\n 'return scope;',\n ])};`,\n `var findVersion = ${runtimeTemplate.basicFunction('scope, key', [\n 'var versions = scope[key];',\n `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n ['return !a || versionLt(a, b) ? b : a;'],\n )}, 0);`,\n 'return key && versions[key]',\n ])};`,\n `var findSingletonVersionKey = ${runtimeTemplate.basicFunction(\n 'scope, key',\n [\n 'var versions = scope[key];',\n `return Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n ['return !a || (!versions[a].loaded && versionLt(a, b)) ? b : a;'],\n )}, 0);`,\n ],\n )};`,\n `var getInvalidSingletonVersionMessage = ${runtimeTemplate.basicFunction(\n 'scope, key, version, requiredVersion',\n [\n `return \"Unsatisfied version \" + version + \" from \" + (version && scope[key][version].from) + \" of shared singleton module \" + key + \" (required \" + rangeToString(requiredVersion) + \")\"`,\n ],\n )};`,\n `var getSingleton = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var getSingletonVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'if (!satisfy(requiredVersion, version)) warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var getStrictSingletonVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'if (!satisfy(requiredVersion, version)) ' +\n 'throw new Error(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var findValidVersion = ${runtimeTemplate.basicFunction(\n 'scope, key, requiredVersion',\n [\n 'var versions = scope[key];',\n `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n [\n 'if (!satisfy(requiredVersion, b)) return a;',\n 'return !a || versionLt(a, b) ? b : a;',\n ],\n )}, 0);`,\n 'return key && versions[key]',\n ],\n )};`,\n `var getInvalidVersionMessage = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var versions = scope[key];',\n 'return \"No satisfying version (\" + rangeToString(requiredVersion) + \") of shared module \" + key + \" found in shared scope \" + scopeName + \".\\\\n\" +',\n `\\t\"Available versions: \" + Object.keys(versions).map(${runtimeTemplate.basicFunction(\n 'key',\n ['return key + \" from \" + versions[key].from;'],\n )}).join(\", \");`,\n ],\n )};`,\n `var getValidVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var entry = findValidVersion(scope, key, requiredVersion);',\n 'if(entry) return get(entry);',\n 'throw new Error(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));',\n ],\n )};`,\n `var warn = ${\n compilation.outputOptions.ignoreBrowserWarnings\n ? runtimeTemplate.basicFunction('', '')\n : runtimeTemplate.basicFunction('msg', [\n 'if (typeof console !== \"undefined\" && console.warn) console.warn(msg);',\n ])\n };`,\n `var warnInvalidVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));',\n ],\n )};`,\n `var get = ${runtimeTemplate.basicFunction('entry', [\n 'entry.loaded = 1;',\n 'return entry.get()',\n ])};`,\n `var init = ${runtimeTemplate.returningFunction(\n Template.asString([\n 'function(scopeName, a, b, c) {',\n Template.indent([\n `var promise = ${RuntimeGlobals.initializeSharing}(scopeName);`,\n `if (promise && promise.then) return promise.then(fn.bind(fn, scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c));`,\n `return fn(scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c);`,\n ]),\n '}',\n ]),\n 'fn',\n )};`,\n '',\n `var load = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key',\n [\n 'ensureExistence(scopeName, key);',\n 'return get(findVersion(scope, key));',\n ],\n )});`,\n `var loadFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, fallback',\n [\n `return scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) ? get(findVersion(scope, key)) : fallback();`,\n ],\n )});`,\n `var loadVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));',\n ],\n )});`,\n `var loadSingleton = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key',\n [\n 'ensureExistence(scopeName, key);',\n 'return getSingleton(scope, scopeName, key);',\n ],\n )});`,\n `var loadSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getValidVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getStrictSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));',\n ],\n )});`,\n `var loadSingletonFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getSingleton(scope, scopeName, key);',\n ],\n )});`,\n `var loadSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `var entry = scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) && findValidVersion(scope, key, version);`,\n `return entry ? get(entry) : fallback();`,\n ],\n )});`,\n `var loadStrictSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getStrictSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n 'var installedModules = {};',\n 'var moduleToHandlerMapping = {',\n Template.indent(\n Array.from(\n moduleIdToSourceMapping,\n ([key, source]) => `${JSON.stringify(key)}: ${source.source()}`,\n ).join(',\\n'),\n ),\n '};',\n\n initialConsumes.length > 0\n ? Template.asString([\n `var initialConsumes = ${JSON.stringify(initialConsumes)};`,\n `initialConsumes.forEach(${runtimeTemplate.basicFunction('id', [\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n '// Handle case when module is used sync',\n 'installedModules[id] = 0;',\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'var factory = moduleToHandlerMapping[id]();',\n 'if(typeof factory !== \"function\") throw new Error(\"Shared module is not available for eager consumption: \" + id);',\n `module.exports = factory();`,\n ])}`,\n ])});`,\n ])\n : '// no consumes in initial chunks',\n this._runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? Template.asString([\n `var chunkMapping = ${JSON.stringify(\n chunkToModuleMapping,\n null,\n '\\t',\n )};`,\n `${\n RuntimeGlobals.ensureChunkHandlers\n }.consumes = ${runtimeTemplate.basicFunction('chunkId, promises', [\n `if(${RuntimeGlobals.hasOwnProperty}(chunkMapping, chunkId)) {`,\n Template.indent([\n `chunkMapping[chunkId].forEach(${runtimeTemplate.basicFunction(\n 'id',\n [\n `if(${RuntimeGlobals.hasOwnProperty}(installedModules, id)) return promises.push(installedModules[id]);`,\n `var onFactory = ${runtimeTemplate.basicFunction(\n 'factory',\n [\n 'installedModules[id] = 0;',\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'module.exports = factory();',\n ])}`,\n ],\n )};`,\n `var onError = ${runtimeTemplate.basicFunction('error', [\n 'delete installedModules[id];',\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'throw error;',\n ])}`,\n ])};`,\n 'try {',\n Template.indent([\n 'var promise = moduleToHandlerMapping[id]();',\n 'if(promise.then) {',\n Template.indent(\n \"promises.push(installedModules[id] = promise.then(onFactory)['catch'](onError));\",\n ),\n '} else onFactory(promise);',\n ]),\n '} catch(e) { onError(e); }',\n ],\n )});`,\n ]),\n '}',\n ])}`,\n ])\n : '// no chunk loading of consumes',\n ]);\n }\n}\n\nexport default ConsumeSharedRuntimeModule;\n"],"names":["ConsumeSharedRuntimeModule","RuntimeModule","generate","compilation","chunkGraph","runtimeTemplate","codeGenerationResults","chunkToModuleMapping","moduleIdToSourceMapping","Map","initialConsumes","addModules","modules","chunk","list","m","module","id","getModuleId","push","set","getSource","runtime","allChunks","getAllAsyncChunks","getAllInitialChunks","getChunkModulesIterableBySourceType","toString","size","Template","asString","parseVersionRuntimeCode","versionLtRuntimeCode","rangeToStringRuntimeCode","satisfyRuntimeCode","basicFunction","RuntimeGlobals","shareScopeMap","hasOwnProperty","outputOptions","ignoreBrowserWarnings","returningFunction","indent","initializeSharing","Array","from","key","source","JSON","stringify","join","length","moduleFactories","moduleCache","_runtimeRequirements","has","ensureChunkHandlers","constructor","runtimeRequirements","STAGE_ATTACH"],"mappings":"AAAA;;;AAGA;;;;+BA8XA;;;eAAA;;;wEA5XgC;iEACX;wBAMd;sEACmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQ1B,IA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C,gBAAgB8B,aAAa,CAC9C,WACA;gCACE;gCACA,CAAC,EACCC,gBAAegB,eAAe,CAC/B,OAAO,EAAE/C,gBAAgB8B,aAAa,CAAC,UAAU;oCAChD,CAAC,OAAO,EAAEC,gBAAeiB,WAAW,CAAC,KAAK,CAAC;oCAC3C;iCACD,EAAE,CAAC;6BACL,EACD,CAAC,CAAC;4BACJ,CAAC,cAAc,EAAEhD,gBAAgB8B,aAAa,CAAC,SAAS;gCACtD;gCACA,CAAC,EACCC,gBAAegB,eAAe,CAC/B,OAAO,EAAE/C,gBAAgB8B,aAAa,CAAC,UAAU;oCAChD,CAAC,OAAO,EAAEC,gBAAeiB,WAAW,CAAC,KAAK,CAAC;oCAC3C;iCACD,EAAE,CAAC;6BACL,EAAE,CAAC,CAAC;4BACL;4BACAxB,iBAAQ,CAACa,MAAM,CAAC;gCACd;gCACA;gCACAb,iBAAQ,CAACa,MAAM,CACb;gCAEF;6BACD;4BACD;yBACD,EACD,EAAE,CAAC;qBACN;oBACD;iBACD,EAAE,CAAC;aACL,IACD;SACL;IACH;IAtWA;;GAEC,GACDe,YAAYC,mBAAwC,CAAE;QACpD,KAAK,CAAC,YAAYzD,sBAAa,CAAC0D,YAAY;QAC5C,IAAI,CAACL,oBAAoB,GAAGI;IAC9B;AAiWF;MAEA,WAAe1D"}
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ConsumeSharedRuntimeModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport Template from 'webpack/lib/Template';\nimport {\n parseVersionRuntimeCode,\n versionLtRuntimeCode,\n rangeToStringRuntimeCode,\n satisfyRuntimeCode,\n} from 'webpack/lib/util/semver';\nimport RuntimeModule from 'webpack/lib/RuntimeModule';\nimport Module from 'webpack/lib/Module';\nimport ConsumeSharedModule from './ConsumeSharedModule';\nimport type ChunkGraph from 'webpack/lib/ChunkGraph';\nimport type Compilation from 'webpack/lib/Compilation';\nimport type Chunk from 'webpack/lib/Chunk';\nimport { Source } from 'webpack-sources';\n\nclass ConsumeSharedRuntimeModule extends RuntimeModule {\n private _runtimeRequirements: ReadonlySet<string>;\n\n /**\n * @param {ReadonlySet<string>} runtimeRequirements runtime requirements\n */\n constructor(runtimeRequirements: ReadonlySet<string>) {\n super('consumes', RuntimeModule.STAGE_ATTACH);\n this._runtimeRequirements = runtimeRequirements;\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate(): string | null {\n const compilation: Compilation = this.compilation!;\n const chunkGraph: ChunkGraph = this.chunkGraph!;\n const { runtimeTemplate, codeGenerationResults } = compilation;\n const chunkToModuleMapping: Record<string, any> = {};\n const moduleIdToSourceMapping: Map<string | number, Source> = new Map();\n const initialConsumes: (string | number)[] = [];\n /**\n *\n * @param {Iterable<Module>} modules modules\n * @param {Chunk} chunk the chunk\n * @param {(string | number)[]} list list of ids\n */\n const addModules = (\n modules: Iterable<Module>,\n chunk: Chunk,\n list: (string | number)[],\n ) => {\n for (const m of modules) {\n const module: ConsumeSharedModule = m as ConsumeSharedModule;\n const id = chunkGraph.getModuleId(module);\n list.push(id);\n moduleIdToSourceMapping.set(\n id,\n codeGenerationResults.getSource(\n module,\n chunk.runtime,\n 'consume-shared',\n ),\n );\n }\n };\n const allChunks = [\n ...(this.chunk?.getAllAsyncChunks() || []),\n ...(this.chunk?.getAllInitialChunks() || []),\n ];\n for (const chunk of allChunks) {\n const modules = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'consume-shared',\n );\n if (!modules) continue;\n if (!chunk.id) continue;\n\n addModules(\n modules,\n chunk,\n (chunkToModuleMapping[chunk.id.toString()] = []),\n );\n }\n for (const chunk of [...(this.chunk?.getAllInitialChunks() || [])]) {\n const modules = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'consume-shared',\n );\n if (!modules) continue;\n addModules(modules, chunk, initialConsumes);\n }\n\n if (moduleIdToSourceMapping.size === 0) return null;\n\n return Template.asString([\n parseVersionRuntimeCode(runtimeTemplate),\n versionLtRuntimeCode(runtimeTemplate),\n rangeToStringRuntimeCode(runtimeTemplate),\n satisfyRuntimeCode(runtimeTemplate),\n `var ensureExistence = ${runtimeTemplate.basicFunction('scopeName, key', [\n `var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) throw new Error(\"Shared module \" + key + \" doesn't exist in shared scope \" + scopeName);`,\n 'return scope;',\n ])};`,\n `var findVersion = ${runtimeTemplate.basicFunction('scope, key', [\n 'var versions = scope[key];',\n `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n ['return !a || versionLt(a, b) ? b : a;'],\n )}, 0);`,\n 'return key && versions[key]',\n ])};`,\n `var findSingletonVersionKey = ${runtimeTemplate.basicFunction(\n 'scope, key',\n [\n 'var versions = scope[key];',\n `return Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n ['return !a || (!versions[a].loaded && versionLt(a, b)) ? b : a;'],\n )}, 0);`,\n ],\n )};`,\n `var getInvalidSingletonVersionMessage = ${runtimeTemplate.basicFunction(\n 'scope, key, version, requiredVersion',\n [\n `return \"Unsatisfied version \" + version + \" from \" + (version && scope[key][version].from) + \" of shared singleton module \" + key + \" (required \" + rangeToString(requiredVersion) + \")\"`,\n ],\n )};`,\n `var getSingleton = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var getSingletonVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'if (!satisfy(requiredVersion, version)) warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var getStrictSingletonVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var version = findSingletonVersionKey(scope, key);',\n 'if (!satisfy(requiredVersion, version)) ' +\n 'throw new Error(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));',\n 'return get(scope[key][version]);',\n ],\n )};`,\n `var findValidVersion = ${runtimeTemplate.basicFunction(\n 'scope, key, requiredVersion',\n [\n 'var versions = scope[key];',\n `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(\n 'a, b',\n [\n 'if (!satisfy(requiredVersion, b)) return a;',\n 'return !a || versionLt(a, b) ? b : a;',\n ],\n )}, 0);`,\n 'return key && versions[key]',\n ],\n )};`,\n `var getInvalidVersionMessage = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var versions = scope[key];',\n 'return \"No satisfying version (\" + rangeToString(requiredVersion) + \") of shared module \" + key + \" found in shared scope \" + scopeName + \".\\\\n\" +',\n `\\t\"Available versions: \" + Object.keys(versions).map(${runtimeTemplate.basicFunction(\n 'key',\n ['return key + \" from \" + versions[key].from;'],\n )}).join(\", \");`,\n ],\n )};`,\n `var getValidVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'var entry = findValidVersion(scope, key, requiredVersion);',\n 'if(entry) return get(entry);',\n 'throw new Error(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));',\n ],\n )};`,\n `var warn = ${\n compilation.outputOptions.ignoreBrowserWarnings\n ? runtimeTemplate.basicFunction('', '')\n : runtimeTemplate.basicFunction('msg', [\n 'if (typeof console !== \"undefined\" && console.warn) console.warn(msg);',\n ])\n };`,\n `var warnInvalidVersion = ${runtimeTemplate.basicFunction(\n 'scope, scopeName, key, requiredVersion',\n [\n 'warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));',\n ],\n )};`,\n `var get = ${runtimeTemplate.basicFunction('entry', [\n 'entry.loaded = 1;',\n 'return entry.get()',\n ])};`,\n `var init = ${runtimeTemplate.returningFunction(\n Template.asString([\n 'function(scopeName, a, b, c) {',\n Template.indent([\n `var promise = ${RuntimeGlobals.initializeSharing}(scopeName);`,\n `if (promise && promise.then) return promise.then(fn.bind(fn, scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c));`,\n `return fn(scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c);`,\n ]),\n '}',\n ]),\n 'fn',\n )};`,\n '',\n `var load = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key',\n [\n 'ensureExistence(scopeName, key);',\n 'return get(findVersion(scope, key));',\n ],\n )});`,\n `var loadFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, fallback',\n [\n `return scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) ? get(findVersion(scope, key)) : fallback();`,\n ],\n )});`,\n `var loadVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));',\n ],\n )});`,\n `var loadSingleton = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key',\n [\n 'ensureExistence(scopeName, key);',\n 'return getSingleton(scope, scopeName, key);',\n ],\n )});`,\n `var loadSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getValidVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version',\n [\n 'ensureExistence(scopeName, key);',\n 'return getStrictSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));',\n ],\n )});`,\n `var loadSingletonFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getSingleton(scope, scopeName, key);',\n ],\n )});`,\n `var loadSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n `var loadStrictVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `var entry = scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) && findValidVersion(scope, key, version);`,\n `return entry ? get(entry) : fallback();`,\n ],\n )});`,\n `var loadStrictSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(\n 'scopeName, scope, key, version, fallback',\n [\n `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,\n 'return getStrictSingletonVersion(scope, scopeName, key, version);',\n ],\n )});`,\n 'var installedModules = {};',\n 'var moduleToHandlerMapping = {',\n Template.indent(\n Array.from(\n moduleIdToSourceMapping,\n ([key, source]) => `${JSON.stringify(key)}: ${source.source()}`,\n ).join(',\\n'),\n ),\n '};',\n\n initialConsumes.length > 0\n ? Template.asString([\n `var initialConsumes = ${JSON.stringify(initialConsumes)};`,\n `initialConsumes.forEach(${runtimeTemplate.basicFunction('id', [\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n '// Handle case when module is used sync',\n 'installedModules[id] = 0;',\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'var factory = moduleToHandlerMapping[id]();',\n 'if(typeof factory !== \"function\") throw new Error(\"Shared module is not available for eager consumption: \" + id);',\n `module.exports = factory();`,\n ])}`,\n ])});`,\n ])\n : '// no consumes in initial chunks',\n this._runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? Template.asString([\n `var chunkMapping = ${JSON.stringify(\n chunkToModuleMapping,\n null,\n '\\t',\n )};`,\n `${\n RuntimeGlobals.ensureChunkHandlers\n }.consumes = ${runtimeTemplate.basicFunction('chunkId, promises', [\n `if(${RuntimeGlobals.hasOwnProperty}(chunkMapping, chunkId)) {`,\n Template.indent([\n `chunkMapping[chunkId].forEach(${runtimeTemplate.basicFunction(\n 'id',\n [\n `if(${RuntimeGlobals.hasOwnProperty}(installedModules, id)) return promises.push(installedModules[id]);`,\n `var onFactory = ${runtimeTemplate.basicFunction(\n 'factory',\n [\n 'installedModules[id] = 0;',\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'module.exports = factory();',\n ])}`,\n ],\n )};`,\n `var onError = ${runtimeTemplate.basicFunction('error', [\n 'delete installedModules[id];',\n `${\n RuntimeGlobals.moduleFactories\n }[id] = ${runtimeTemplate.basicFunction('module', [\n `delete ${RuntimeGlobals.moduleCache}[id];`,\n 'throw error;',\n ])}`,\n ])};`,\n 'try {',\n Template.indent([\n 'var promise = moduleToHandlerMapping[id]();',\n 'if(promise.then) {',\n Template.indent(\n \"promises.push(installedModules[id] = promise.then(onFactory)['catch'](onError));\",\n ),\n '} else onFactory(promise);',\n ]),\n '} catch(e) { onError(e); }',\n ],\n )});`,\n ]),\n '}',\n ])}`,\n ])\n : '// no chunk loading of consumes',\n ]);\n }\n}\n\nexport default ConsumeSharedRuntimeModule;\n"],"names":["ConsumeSharedRuntimeModule","RuntimeModule","generate","compilation","chunkGraph","runtimeTemplate","codeGenerationResults","chunkToModuleMapping","moduleIdToSourceMapping","Map","initialConsumes","addModules","modules","chunk","list","m","module","id","getModuleId","push","set","getSource","runtime","allChunks","getAllAsyncChunks","getAllInitialChunks","getChunkModulesIterableBySourceType","toString","size","Template","asString","parseVersionRuntimeCode","versionLtRuntimeCode","rangeToStringRuntimeCode","satisfyRuntimeCode","basicFunction","RuntimeGlobals","shareScopeMap","hasOwnProperty","outputOptions","ignoreBrowserWarnings","returningFunction","indent","initializeSharing","Array","from","key","source","JSON","stringify","join","length","moduleFactories","moduleCache","_runtimeRequirements","has","ensureChunkHandlers","constructor","runtimeRequirements","STAGE_ATTACH"],"mappings":"AAAA;;;AAGA;;;;+BA8XA;;;eAAA;;;wEA5XgC;iEACX;wBAMd;sEACmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQ1B,IAAA,AAAMA,6BAAN,MAAMA,mCAAmCC,sBAAa;IAWpD;;GAEC,GACD,AAASC,WAA0B;YAiC3B,aACA,cAgBmB;QAjDzB,MAAMC,cAA2B,IAAI,CAACA,WAAW;QACjD,MAAMC,aAAyB,IAAI,CAACA,UAAU;QAC9C,MAAM,EAAEC,eAAe,EAAEC,qBAAqB,EAAE,GAAGH;QACnD,MAAMI,uBAA4C,CAAC;QACnD,MAAMC,0BAAwD,IAAIC;QAClE,MAAMC,kBAAuC,EAAE;QAC/C;;;;;KAKC,GACD,MAAMC,aAAa,CACjBC,SACAC,OACAC;YAEA,KAAK,MAAMC,KAAKH,QAAS;gBACvB,MAAMI,SAA8BD;gBACpC,MAAME,KAAKb,WAAWc,WAAW,CAACF;gBAClCF,KAAKK,IAAI,CAACF;gBACVT,wBAAwBY,GAAG,CACzBH,IACAX,sBAAsBe,SAAS,CAC7BL,QACAH,MAA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AAM,CACb;gCAEF;6BACD;4BACD;yBACD,EACD,EAAE,CAAC;qBACN;oBACD;iBACD,EAAE,CAAC;aACL,IACD;SACL;IACH;IAtWA;;GAEC,GACDe,YAAYC,mBAAwC,CAAE;QACpD,KAAK,CAAC,YAAYzD,sBAAa,CAAC0D,YAAY;QAC5C,IAAI,CAACL,oBAAoB,GAAGI;IAC9B;AAiWF;MAEA,WAAe1D"}
@@ -43,7 +43,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
43
43
  if (cache && cache.has(obj)) {
44
44
  return cache.get(obj);
45
45
  }
46
- var newObj = {};
46
+ var newObj = {
47
+ __proto__: null
48
+ };
47
49
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
48
50
  for(var key in obj){
49
51
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ProvideSharedModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\nimport AsyncDependenciesBlock from 'webpack/lib/AsyncDependenciesBlock';\nimport Module from 'webpack/lib/Module';\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport makeSerializable from 'webpack/lib/util/makeSerializable';\nimport type Compilation from 'webpack/lib/Compilation';\nimport WebpackError from 'webpack/lib/WebpackError';\nimport { WEBPACK_MODULE_TYPE_PROVIDE } from 'webpack/lib/ModuleTypeConstants';\nimport type {\n CodeGenerationContext,\n CodeGenerationResult,\n LibIdentOptions,\n NeedBuildContext,\n RequestShortener,\n ResolverWithOptions,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n} from 'webpack/lib/Module';\nimport { InputFileSystem } from 'webpack/lib/util/fs';\nimport ProvideForSharedDependency from './ProvideForSharedDependency';\nimport { WebpackOptionsNormalized as WebpackOptions } from 'webpack/declarations/WebpackOptions';\n\nconst TYPES = new Set(['share-init']);\n\n/**\n * @class\n * @extends {Module}\n */\nclass ProvideSharedModule extends Module {\n private _shareScope: string;\n private _name: string;\n private _version: string | false;\n private _request: string;\n private _eager: boolean;\n\n /**\n * @constructor\n * @param {string} shareScope shared scope name\n * @param {string} name shared key\n * @param {string | false} version version\n * @param {string} request request to the provided module\n * @param {boolean} eager include the module in sync way\n */\n constructor(\n shareScope: string,\n name: string,\n version: string | false,\n request: string,\n eager: boolean,\n ) {\n super(WEBPACK_MODULE_TYPE_PROVIDE);\n this._shareScope = shareScope;\n this._name = name;\n this._version = version;\n this._request = request;\n this._eager = eager;\n }\n\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n return `provide module (${this._shareScope}) ${this._name}@${this._version} = ${this._request}`;\n }\n\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return `provide shared module (${this._shareScope}) ${this._name}@${\n this._version\n } = ${requestShortener.shorten(this._request)}`;\n }\n\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/sharing/provide/${\n this._shareScope\n }/${this._name}`;\n }\n\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (error?: WebpackError | null, needsRebuild?: boolean) => void,\n ): void {\n callback(null, !this.buildInfo);\n }\n\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError=): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (error?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n };\n\n this.clearDependenciesAndBlocks();\n const dep = new ProvideForSharedDependency(this._request);\n if (this._eager) {\n this.addDependency(dep);\n } else {\n const block = new AsyncDependenciesBlock({});\n block.addDependency(dep);\n this.addBlock(block);\n }\n\n callback();\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 42;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return TYPES;\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n override codeGeneration({\n runtimeTemplate,\n moduleGraph,\n chunkGraph,\n }: CodeGenerationContext): CodeGenerationResult {\n const runtimeRequirements = new Set([RuntimeGlobals.initializeSharing]);\n const code = `register(${JSON.stringify(this._name)}, ${JSON.stringify(\n this._version || '0',\n )}, ${\n this._eager\n ? runtimeTemplate.syncModuleFactory({\n dependency: this.dependencies[0],\n chunkGraph,\n request: this._request,\n runtimeRequirements,\n })\n : runtimeTemplate.asyncModuleFactory({\n block: this.blocks[0],\n chunkGraph,\n request: this._request,\n runtimeRequirements,\n })\n }${this._eager ? ', 1' : ''});`;\n const sources = new Map();\n const data = new Map();\n data.set('share-init', [\n {\n shareScope: this._shareScope,\n initStage: 10,\n init: code,\n },\n ]);\n return { sources, data, runtimeRequirements };\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this._shareScope);\n write(this._name);\n write(this._version);\n write(this._request);\n write(this._eager);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {ProvideSharedModule} deserialize fallback dependency\n */\n static deserialize(context: ObjectDeserializerContext): ProvideSharedModule {\n const { read } = context;\n const obj = new ProvideSharedModule(read(), read(), read(), read(), read());\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(\n ProvideSharedModule,\n 'enhanced/lib/sharing/ProvideSharedModule',\n);\n\nexport default ProvideSharedModule;\n"],"names":["TYPES","Set","ProvideSharedModule","Module","identifier","_shareScope","_name","_version","_request","readableIdentifier","requestShortener","shorten","libIdent","options","layer","needBuild","context","callback","buildInfo","build","compilation","resolver","fs","buildMeta","strict","clearDependenciesAndBlocks","dep","ProvideForSharedDependency","_eager","addDependency","block","AsyncDependenciesBlock","addBlock","size","type","getSourceTypes","codeGeneration","runtimeTemplate","moduleGraph","chunkGraph","runtimeRequirements","RuntimeGlobals","initializeSharing","code","JSON","stringify","syncModuleFactory","dependency","dependencies","request","asyncModuleFactory","blocks","sources","Map","data","set","shareScope","initStage","init","serialize","write","deserialize","read","obj","constructor","name","version","eager","WEBPACK_MODULE_TYPE_PROVIDE","makeSerializable"],"mappings":"AAAA;;;AAGA;;;;+BAuNA;;;eAAA;;;+EArNmC;+DAChB;wEACa;yEACH;qCAGe;mFAYL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvC,MAAMA,QAAQ,IAAIC,IAAI;IAAC;CAAa;AAEpC;;;CAGC,GACD,IAAA,AAAMC,sBAAN,MAAMA,4BAA4BC,eAAM;IA8BtC;;GAEC,GACD,AAASC,aAAqB;QAC5B,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAACC,WAAW,CAAC,EAAE,EAAE,IAAI,CAACC,KAAK,CAAC,CAAC,EAAE,IAAI,CAACC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAACC,QAAQ,CAAC,CAAC;IACjG;IAEA;;;GAGC,GACD,AAASC,mBAAmBC,gBAAkC,EAAU;QACtE,OAAO,CAAC,uBAAuB,EAAE,IAAI,CAACL,WAAW,CAAC,EAAE,EAAE,IAAI,CAACC,KAAK,CAAC,CAAC,EAChE,IAAI,CAACC,QAAQ,CACd,GAAG,EAAEG,iBAAiBC,OAAO,CAAC,IAAI,CAACH,QAAQ,EAAE,CAAC;IACjD;IAEA;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QACnB,IAAI,CAAClD,KAAK,GAAG2D;QACb,IAAI,CAAC1D,QAAQ,GAAG2D;QAChB,IAAI,CAAC1D,QAAQ,GAAGyC;QAChB,IAAI,CAACrB,MAAM,GAAGuC;IAChB;AAuJF;AAEAE,IAAAA,yBAAgB,EACdnE,qBACA;MAGF,WAAeA"}
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ProvideSharedModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\nimport AsyncDependenciesBlock from 'webpack/lib/AsyncDependenciesBlock';\nimport Module from 'webpack/lib/Module';\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport makeSerializable from 'webpack/lib/util/makeSerializable';\nimport type Compilation from 'webpack/lib/Compilation';\nimport WebpackError from 'webpack/lib/WebpackError';\nimport { WEBPACK_MODULE_TYPE_PROVIDE } from 'webpack/lib/ModuleTypeConstants';\nimport type {\n CodeGenerationContext,\n CodeGenerationResult,\n LibIdentOptions,\n NeedBuildContext,\n RequestShortener,\n ResolverWithOptions,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n} from 'webpack/lib/Module';\nimport { InputFileSystem } from 'webpack/lib/util/fs';\nimport ProvideForSharedDependency from './ProvideForSharedDependency';\nimport { WebpackOptionsNormalized as WebpackOptions } from 'webpack/declarations/WebpackOptions';\n\nconst TYPES = new Set(['share-init']);\n\n/**\n * @class\n * @extends {Module}\n */\nclass ProvideSharedModule extends Module {\n private _shareScope: string;\n private _name: string;\n private _version: string | false;\n private _request: string;\n private _eager: boolean;\n\n /**\n * @constructor\n * @param {string} shareScope shared scope name\n * @param {string} name shared key\n * @param {string | false} version version\n * @param {string} request request to the provided module\n * @param {boolean} eager include the module in sync way\n */\n constructor(\n shareScope: string,\n name: string,\n version: string | false,\n request: string,\n eager: boolean,\n ) {\n super(WEBPACK_MODULE_TYPE_PROVIDE);\n this._shareScope = shareScope;\n this._name = name;\n this._version = version;\n this._request = request;\n this._eager = eager;\n }\n\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n return `provide module (${this._shareScope}) ${this._name}@${this._version} = ${this._request}`;\n }\n\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return `provide shared module (${this._shareScope}) ${this._name}@${\n this._version\n } = ${requestShortener.shorten(this._request)}`;\n }\n\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/sharing/provide/${\n this._shareScope\n }/${this._name}`;\n }\n\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (error?: WebpackError | null, needsRebuild?: boolean) => void,\n ): void {\n callback(null, !this.buildInfo);\n }\n\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError=): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (error?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n };\n\n this.clearDependenciesAndBlocks();\n const dep = new ProvideForSharedDependency(this._request);\n if (this._eager) {\n this.addDependency(dep);\n } else {\n const block = new AsyncDependenciesBlock({});\n block.addDependency(dep);\n this.addBlock(block);\n }\n\n callback();\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 42;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return TYPES;\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n override codeGeneration({\n runtimeTemplate,\n moduleGraph,\n chunkGraph,\n }: CodeGenerationContext): CodeGenerationResult {\n const runtimeRequirements = new Set([RuntimeGlobals.initializeSharing]);\n const code = `register(${JSON.stringify(this._name)}, ${JSON.stringify(\n this._version || '0',\n )}, ${\n this._eager\n ? runtimeTemplate.syncModuleFactory({\n dependency: this.dependencies[0],\n chunkGraph,\n request: this._request,\n runtimeRequirements,\n })\n : runtimeTemplate.asyncModuleFactory({\n block: this.blocks[0],\n chunkGraph,\n request: this._request,\n runtimeRequirements,\n })\n }${this._eager ? ', 1' : ''});`;\n const sources = new Map();\n const data = new Map();\n data.set('share-init', [\n {\n shareScope: this._shareScope,\n initStage: 10,\n init: code,\n },\n ]);\n return { sources, data, runtimeRequirements };\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this._shareScope);\n write(this._name);\n write(this._version);\n write(this._request);\n write(this._eager);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {ProvideSharedModule} deserialize fallback dependency\n */\n static deserialize(context: ObjectDeserializerContext): ProvideSharedModule {\n const { read } = context;\n const obj = new ProvideSharedModule(read(), read(), read(), read(), read());\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(\n ProvideSharedModule,\n 'enhanced/lib/sharing/ProvideSharedModule',\n);\n\nexport default ProvideSharedModule;\n"],"names":["TYPES","Set","ProvideSharedModule","Module","identifier","_shareScope","_name","_version","_request","readableIdentifier","requestShortener","shorten","libIdent","options","layer","needBuild","context","callback","buildInfo","build","compilation","resolver","fs","buildMeta","strict","clearDependenciesAndBlocks","dep","ProvideForSharedDependency","_eager","addDependency","block","AsyncDependenciesBlock","addBlock","size","type","getSourceTypes","codeGeneration","runtimeTemplate","moduleGraph","chunkGraph","runtimeRequirements","RuntimeGlobals","initializeSharing","code","JSON","stringify","syncModuleFactory","dependency","dependencies","request","asyncModuleFactory","blocks","sources","Map","data","set","shareScope","initStage","init","serialize","write","deserialize","read","obj","constructor","name","version","eager","WEBPACK_MODULE_TYPE_PROVIDE","makeSerializable"],"mappings":"AAAA;;;AAGA;;;;+BAuNA;;;eAAA;;;+EArNmC;+DAChB;wEACa;yEACH;qCAGe;mFAYL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvC,MAAMA,QAAQ,IAAIC,IAAI;IAAC;CAAa;AAEpC;;;CAGC,GACD,IAAA,AAAMC,sBAAN,MAAMA,4BAA4BC,eAAM;IA8BtC;;GAEC,GACD,AAASC,aAAqB;QAC5B,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAACC,WAAW,CAAC,EAAE,EAAE,IAAI,CAACC,KAAK,CAAC,CAAC,EAAE,IAAI,CAACC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAACC,QAAQ,CAAC,CAAC;IACjG;IAEA;;;GAGC,GACD,AAASC,mBAAmBC,gBAAkC,EAAU;QACtE,OAAO,CAAC,uBAAuB,EAAE,IAAI,CAACL,WAAW,CAAC,EAAE,EAAE,IAAI,CAACC,KAAK,CAAC,CAAC,EAChE,IAAI,CAACC,QAAQ,CACd,GAAG,EAAEG,iBAAiBC,OAAO,CAAC,IAAI,CAACH,QAAQ,EAAE,CAAC;IACjD;IAEA;;;GAGC,GACD,AAASI,SAASC,OAAwB,EAAiB;QACzD,OAAO,CAAC,EAAE,IAAI,CAACC,KAAK,GAAG,CAAC,CAAC,EAAE,IAAI,CAACA,KAAK,CAAC,EAAE,CAAC,GAAG,GAAG,wBAAwB,EACrE,IAAI,CAACT,WAAW,CACjB,CAAC,EAAE,IAAI,CAACC,KAAK,CAAC,CAAC;IAClB;IAEA;;;;GAIC,GACD,AAASS,UACPC,OAAyB,EACzBC,QAAuE,EACjE;QACNA,SAAS,MAAM,CAAC,IAAI,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AG,QAAQ,GAAG,EAAE,CAAC;QAC/B,MAAMwB,UAAU,IAAIC;QACpB,MAAMC,OAAO,IAAID;QACjBC,KAAKC,GAAG,CAAC,cAAc;YACrB;gBACEC,YAAY,IAAI,CAACnD,WAAW;gBAC5BoD,WAAW;gBACXC,MAAMf;YACR;SACD;QACD,OAAO;YAAES;YAASE;YAAMd;QAAoB;IAC9C;IAEA;;GAEC,GACD,AAASmB,UAAU3C,OAAgC,EAAQ;QACzD,MAAM,EAAE4C,KAAK,EAAE,GAAG5C;QAClB4C,MAAM,IAAI,CAACvD,WAAW;QACtBuD,MAAM,IAAI,CAACtD,KAAK;QAChBsD,MAAM,IAAI,CAACrD,QAAQ;QACnBqD,MAAM,IAAI,CAACpD,QAAQ;QACnBoD,MAAM,IAAI,CAAChC,MAAM;QACjB,KAAK,CAAC+B,UAAU3C;IAClB;IAEA;;;GAGC,GACD,OAAO6C,YAAY7C,OAAkC,EAAuB;QAC1E,MAAM,EAAE8C,IAAI,EAAE,GAAG9C;QACjB,MAAM+C,MAAM,IAAI7D,oBAAoB4D,QAAQA,QAAQA,QAAQA,QAAQA;QACpEC,IAAIF,WAAW,CAAC7C;QAChB,OAAO+C;IACT;IA3KA;;;;;;;GAOC,GACDC,YACER,UAAkB,EAClBS,IAAY,EACZC,OAAuB,EACvBjB,OAAe,EACfkB,KAAc,CACd;QACA,KAAK,CAACC,gDAA2B;QACjC,IAAI,CAAC/D,WAAW,GAAGmD;QACnB,IAAI,CAAClD,KAAK,GAAG2D;QACb,IAAI,CAAC1D,QAAQ,GAAG2D;QAChB,IAAI,CAAC1D,QAAQ,GAAGyC;QAChB,IAAI,CAACrB,MAAM,GAAGuC;IAChB;AAuJF;AAEAE,IAAAA,yBAAgB,EACdnE,qBACA;MAGF,WAAeA"}
@@ -41,7 +41,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
41
41
  if (cache && cache.has(obj)) {
42
42
  return cache.get(obj);
43
43
  }
44
- var newObj = {};
44
+ var newObj = {
45
+ __proto__: null
46
+ };
45
47
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
46
48
  for(var key in obj){
47
49
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -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,WAAW;QAC7D,IAAI,CAACA,aAAa;YAChB,MAAM,IAAIC,MAAM;QAClB;QACA,MAAM,EACJC,eAAe,EACfC,qBAA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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,IAAA,AAAMA,qBAAN,MAAMA,2BAA2BC,sBAAa;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,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"}
@@ -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
+ }