(expr, param)
| 173 | * @returns {boolean | void} true when handled |
| 174 | */ |
| 175 | const processRequireItem = (expr, param) => { |
| 176 | if (param.isString()) { |
| 177 | let referencedExports = getRequireReferencedExportsFromDestructuring( |
| 178 | parser, |
| 179 | expr |
| 180 | ); |
| 181 | const binding = |
| 182 | requireBindingData && |
| 183 | requireBindingData.get(/** @type {CallExpression} */ (expr)); |
| 184 | if (binding && !referencedExports) { |
| 185 | // `const NAME = require(LITERAL)` — let later member-access walks |
| 186 | // on `NAME` populate the dependency's referenced exports. |
| 187 | referencedExports = binding.referencedExports; |
| 188 | } |
| 189 | const dep = new CommonJsRequireDependency( |
| 190 | /** @type {string} */ (param.string), |
| 191 | /** @type {Range} */ (param.range), |
| 192 | getContext(), |
| 193 | referencedExports, |
| 194 | /** @type {Range} */ (expr.range) |
| 195 | ); |
| 196 | if (binding) binding.dep = dep; |
| 197 | dep.loc = /** @type {DependencyLocation} */ (expr.loc); |
| 198 | dep.optional = Boolean(parser.scope.inTry); |
| 199 | parser.state.current.addDependency(dep); |
| 200 | getHarmonyImportGuard().attachDependencyGuards(parser, dep); |
| 201 | return true; |
| 202 | } |
| 203 | }; |
| 204 | /** |
| 205 | * Process require context. |
| 206 | * @param {CallExpression | NewExpression} expr expression |
no test coverage detected