MCPcopy
hub / github.com/webpack/webpack / getReturnModuleObjectSource

Method getReturnModuleObjectSource

lib/ContextModule.js:812–831  ·  view source on GitHub ↗

* @param {FakeMap | FakeMapType} fakeMap fake map * @param {boolean=} asyncModule is async module * @param {string=} asyncDeps async deps for deferred module * @param {string=} fakeMapDataExpression fake map data expression * @returns {string} module object source

(
		fakeMap,
		asyncModule,
		asyncDeps,
		fakeMapDataExpression = "fakeMap[id]"
	)

Source from the content-addressed store, hash-verified

810 * @returns {string} module object source
811 */
812 getReturnModuleObjectSource(
813 fakeMap,
814 asyncModule,
815 asyncDeps,
816 fakeMapDataExpression = "fakeMap[id]"
817 ) {
818 const source =
819 typeof fakeMap === "number"
820 ? this.getReturn(fakeMap, asyncModule)
821 : `${RuntimeGlobals.createFakeNamespaceObject}(id, ${fakeMapDataExpression}${asyncModule ? " | 16" : ""})`;
822 if (asyncDeps) {
823 if (!asyncModule) {
824 throw new Error("Must be async when module is deferred");
825 }
826 const type =
827 typeof fakeMap === "number" ? fakeMap : fakeMapDataExpression;
828 return `${asyncDeps} ? ${asyncDeps}.length ? ${RuntimeGlobals.deferredModuleAsyncTransitiveDependencies}(${asyncDeps}).then(${RuntimeGlobals.makeDeferredNamespaceObject}.bind(${RuntimeGlobals.require}, id, ${type} ^ 1, true)) : ${RuntimeGlobals.makeDeferredNamespaceObject}(id, ${type} ^ 1 | 16) : ${source}`;
829 }
830 return source;
831 }
832
833 /**
834 * @param {Dependency[]} dependencies dependencies

Callers 6

getSyncSourceMethod · 0.95
getWeakSyncSourceMethod · 0.95
getAsyncWeakSourceMethod · 0.95
getEagerSourceMethod · 0.95
getLazyOnceSourceMethod · 0.95
getLazySourceMethod · 0.95

Calls 1

getReturnMethod · 0.95

Tested by

no test coverage detected