MCPcopy
hub / github.com/webpack/webpack / handler

Method handler

lib/WebpackIsIncludedPlugin.js:50–80  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 4

tapMethod · 0.80
evaluateExpressionMethod · 0.80
isStringMethod · 0.80
addDependencyMethod · 0.65

Tested by

no test coverage detected