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

Method handler

lib/JavascriptMetaInfoPlugin.js:38–65  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

36 * @returns {void}
37 */
38 const handler = (parser) => {
39 parser.hooks.call.for("eval").tap(PLUGIN_NAME, () => {
40 const buildInfo =
41 /** @type {JavascriptModuleBuildInfo} */
42 (parser.state.module.buildInfo);
43 buildInfo.moduleConcatenationBailout = "eval()";
44 const currentSymbol = innerGraph.getTopLevelSymbol(parser.state);
45 if (currentSymbol) {
46 innerGraph.addUsage(parser.state, null, currentSymbol);
47 } else {
48 innerGraph.bailout(parser.state);
49 }
50 });
51 parser.hooks.finish.tap(PLUGIN_NAME, () => {
52 const buildInfo =
53 /** @type {BuildInfo} */
54 (parser.state.module.buildInfo);
55 let topLevelDeclarations = buildInfo.topLevelDeclarations;
56 if (topLevelDeclarations === undefined) {
57 topLevelDeclarations = buildInfo.topLevelDeclarations = new Set();
58 }
59 for (const name of parser.scope.definitions.asSet()) {
60 if (parser.isVariableDefined(name)) {
61 topLevelDeclarations.add(name);
62 }
63 }
64 });
65 };
66
67 normalModuleFactory.hooks.parser
68 .for(JAVASCRIPT_MODULE_TYPE_AUTO)

Callers

nothing calls this directly

Calls 5

tapMethod · 0.80
bailoutMethod · 0.80
asSetMethod · 0.80
isVariableDefinedMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected