MCPcopy
hub / github.com/webpack/webpack / getSourceForDefaultCase

Function getSourceForDefaultCase

lib/ExternalModule.js:746–760  ·  view source on GitHub ↗
(optional, request, runtimeTemplate)

Source from the content-addressed store, hash-verified

744 * @returns {SourceData} the generated source
745 */
746const getSourceForDefaultCase = (optional, request, runtimeTemplate) => {
747 if (!Array.isArray(request)) {
748 // make it an array as the look up works the same basically
749 request = [request];
750 }
751
752 const variableName = request[0];
753 const objectLookup = propertyAccess(request, 1);
754 return {
755 init: optional
756 ? checkExternalVariable(variableName, request.join("."), runtimeTemplate)
757 : undefined,
758 expression: `${variableName}${objectLookup}`
759 };
760};
761
762/** @typedef {Record<string, string | string[]>} RequestRecord */
763/** @typedef {string | string[] | RequestRecord} ExternalModuleRequest */

Callers 1

_getSourceDataMethod · 0.85

Calls 3

propertyAccessFunction · 0.85
checkExternalVariableFunction · 0.85
isArrayMethod · 0.80

Tested by

no test coverage detected