| 160 | * @returns {SourceData} the generated source |
| 161 | */ |
| 162 | const 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 | |