MCPcopy
hub / github.com/webpack/webpack / getSourceForGlobalVariableExternal

Function getSourceForGlobalVariableExternal

lib/ExternalModule.js:162–176  ·  view source on GitHub ↗
(variableName, type)

Source from the content-addressed store, hash-verified

160 * @returns {SourceData} the generated source
161 */
162const getSourceForGlobalVariableExternal = (variableName, type) => {
163 if (!Array.isArray(variableName)) {
164 // make it an array as the look up works the same basically
165 variableName = [variableName];
166 }
167
168 // needed for e.g. window["some"]["thing"]
169 const objectLookup = variableName
170 .map((r) => `[${JSON.stringify(r)}]`)
171 .join("");
172 return {
173 iife: type === "this",
174 expression: `${type}${objectLookup}`
175 };
176};
177
178/** @typedef {string | string[]} ModuleAndSpecifiers */
179

Callers 1

_getSourceDataMethod · 0.85

Calls 1

isArrayMethod · 0.80

Tested by

no test coverage detected