(parser)
| 121 | * @returns {void} |
| 122 | */ |
| 123 | const handler = (parser) => { |
| 124 | // Handle nested requires |
| 125 | parser.hooks.preStatement.tap(PLUGIN_NAME, (statement) => { |
| 126 | if ( |
| 127 | statement.type === "FunctionDeclaration" && |
| 128 | statement.id && |
| 129 | statement.id.name === RuntimeGlobals.require |
| 130 | ) { |
| 131 | const newName = `__nested_webpack_require_${ |
| 132 | /** @type {Range} */ |
| 133 | (statement.range)[0] |
| 134 | }__`; |
| 135 | parser.tagVariable( |
| 136 | statement.id.name, |
| 137 | nestedWebpackIdentifierTag, |
| 138 | { |
| 139 | name: newName, |
| 140 | declaration: { |
| 141 | updated: false, |
| 142 | loc: /** @type {DependencyLocation} */ (statement.id.loc), |
| 143 | range: /** @type {Range} */ (statement.id.range) |
| 144 | } |
| 145 | } |
| 146 | ); |
| 147 | return true; |
| 148 | } |
| 149 | }); |
| 150 | parser.hooks.pattern |
| 151 | .for(RuntimeGlobals.require) |
| 152 | .tap(PLUGIN_NAME, (pattern) => { |
| 153 | const newName = `__nested_webpack_require_${ |
| 154 | /** @type {Range} */ (pattern.range)[0] |
| 155 | }__`; |
| 156 | parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, { |
| 157 | name: newName, |
| 158 | declaration: { |
| 159 | updated: false, |
| 160 | loc: /** @type {DependencyLocation} */ (pattern.loc), |
| 161 | range: /** @type {Range} */ (pattern.range) |
| 162 | } |
| 163 | }); |
| 164 | if (parser.scope.topLevelScope !== true) { |
| 165 | return true; |
| 166 | } |
| 167 | }); |
| 168 | parser.hooks.pattern |
| 169 | .for(RuntimeGlobals.exports) |
| 170 | .tap(PLUGIN_NAME, (pattern) => { |
| 171 | const newName = "__nested_webpack_exports__"; |
| 172 | parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, { |
| 173 | name: newName, |
| 174 | declaration: { |
| 175 | updated: false, |
| 176 | loc: /** @type {DependencyLocation} */ (pattern.loc), |
| 177 | range: /** @type {Range} */ (pattern.range) |
| 178 | } |
| 179 | }); |
| 180 | return true; |
nothing calls this directly
no test coverage detected