(options: RenderOptions)
| 128 | } |
| 129 | |
| 130 | renderBlock(options: RenderOptions): string { |
| 131 | const { |
| 132 | exportNamesByVariable, |
| 133 | format, |
| 134 | freeze, |
| 135 | indent: t, |
| 136 | symbols, |
| 137 | snippets: { _, cnst, getObject, getPropertyAccess, n, s } |
| 138 | } = options; |
| 139 | const memberVariables = this.module.getExportedVariablesByName(); |
| 140 | const members: [key: string | null, value: string][] = [...memberVariables.entries()] |
| 141 | .filter(([name, variable]) => !name.startsWith('*') && variable.included) |
| 142 | .map(([name, variable]) => { |
| 143 | if (this.referencedEarly || variable.isReassigned || variable === this) { |
| 144 | return [ |
| 145 | null, |
| 146 | `get ${stringifyObjectKeyIfNeeded(name)}${_}()${_}{${_}return ${variable.getName( |
| 147 | getPropertyAccess |
| 148 | )}${s}${_}}` |
| 149 | ]; |
| 150 | } |
| 151 | |
| 152 | return [name, variable.getName(getPropertyAccess)]; |
| 153 | }); |
| 154 | members.unshift([null, `__proto__:${_}null`]); |
| 155 | |
| 156 | let output = getObject(members, { lineBreakIndent: { base: '', t } }); |
| 157 | if (this.mergedNamespaces.length > 0) { |
| 158 | const assignmentArguments = this.mergedNamespaces.map(variable => |
| 159 | variable.getName(getPropertyAccess) |
| 160 | ); |
| 161 | output = `/*#__PURE__*/${MERGE_NAMESPACES_VARIABLE}(${output},${_}[${assignmentArguments.join( |
| 162 | `,${_}` |
| 163 | )}])`; |
| 164 | } else { |
| 165 | // The helper to merge namespaces will also take care of freezing and toStringTag |
| 166 | if (symbols) { |
| 167 | output = `/*#__PURE__*/Object.defineProperty(${output},${_}Symbol.toStringTag,${_}${getToStringTagValue( |
| 168 | getObject |
| 169 | )})`; |
| 170 | } |
| 171 | if (freeze) { |
| 172 | output = `/*#__PURE__*/Object.freeze(${output})`; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | const name = this.getName(getPropertyAccess); |
| 177 | output = `${cnst} ${name}${_}=${_}${output};`; |
| 178 | |
| 179 | if (format === 'system' && exportNamesByVariable.has(this)) { |
| 180 | output += `${n}${getSystemExportStatement([this], options)};`; |
| 181 | } |
| 182 | |
| 183 | return output; |
| 184 | } |
| 185 | |
| 186 | renderFirst(): boolean { |
| 187 | return this.referencedEarly; |
no test coverage detected