(parser)
| 48 | * @returns {void} |
| 49 | */ |
| 50 | const handler = (parser) => { |
| 51 | parser.hooks.call |
| 52 | .for("__webpack_is_included__") |
| 53 | .tap(PLUGIN_NAME, (expr) => { |
| 54 | if ( |
| 55 | expr.type !== "CallExpression" || |
| 56 | expr.arguments.length !== 1 || |
| 57 | expr.arguments[0].type === "SpreadElement" |
| 58 | ) { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | const request = parser.evaluateExpression(expr.arguments[0]); |
| 63 | |
| 64 | if (!request.isString()) return; |
| 65 | |
| 66 | const dep = new WebpackIsIncludedDependency( |
| 67 | /** @type {string} */ (request.string), |
| 68 | /** @type {Range} */ (expr.range) |
| 69 | ); |
| 70 | dep.loc = /** @type {DependencyLocation} */ (expr.loc); |
| 71 | parser.state.module.addDependency(dep); |
| 72 | return true; |
| 73 | }); |
| 74 | parser.hooks.typeof |
| 75 | .for("__webpack_is_included__") |
| 76 | .tap( |
| 77 | PLUGIN_NAME, |
| 78 | toConstantDependency(parser, JSON.stringify("function")) |
| 79 | ); |
| 80 | }; |
| 81 | normalModuleFactory.hooks.parser |
| 82 | .for(JAVASCRIPT_MODULE_TYPE_AUTO) |
| 83 | .tap(PLUGIN_NAME, handler); |
nothing calls this directly
no test coverage detected