source: trip-planner-front/node_modules/webpack/lib/ExportsInfoApiPlugin.js@ 59329aa

Last change on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const ConstDependency = require("./dependencies/ConstDependency");
9const ExportsInfoDependency = require("./dependencies/ExportsInfoDependency");
10
11/** @typedef {import("./Compiler")} Compiler */
12/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
13
14class ExportsInfoApiPlugin {
15 /**
16 * Apply the plugin
17 * @param {Compiler} compiler the compiler instance
18 * @returns {void}
19 */
20 apply(compiler) {
21 compiler.hooks.compilation.tap(
22 "ExportsInfoApiPlugin",
23 (compilation, { normalModuleFactory }) => {
24 compilation.dependencyTemplates.set(
25 ExportsInfoDependency,
26 new ExportsInfoDependency.Template()
27 );
28 /**
29 * @param {JavascriptParser} parser the parser
30 * @returns {void}
31 */
32 const handler = parser => {
33 parser.hooks.expressionMemberChain
34 .for("__webpack_exports_info__")
35 .tap("ExportsInfoApiPlugin", (expr, members) => {
36 const dep =
37 members.length >= 2
38 ? new ExportsInfoDependency(
39 expr.range,
40 members.slice(0, -1),
41 members[members.length - 1]
42 )
43 : new ExportsInfoDependency(expr.range, null, members[0]);
44 dep.loc = expr.loc;
45 parser.state.module.addDependency(dep);
46 return true;
47 });
48 parser.hooks.expression
49 .for("__webpack_exports_info__")
50 .tap("ExportsInfoApiPlugin", expr => {
51 const dep = new ConstDependency("true", expr.range);
52 dep.loc = expr.loc;
53 parser.state.module.addPresentationalDependency(dep);
54 return true;
55 });
56 };
57 normalModuleFactory.hooks.parser
58 .for("javascript/auto")
59 .tap("ExportsInfoApiPlugin", handler);
60 normalModuleFactory.hooks.parser
61 .for("javascript/dynamic")
62 .tap("ExportsInfoApiPlugin", handler);
63 normalModuleFactory.hooks.parser
64 .for("javascript/esm")
65 .tap("ExportsInfoApiPlugin", handler);
66 }
67 );
68 }
69}
70
71module.exports = ExportsInfoApiPlugin;
Note: See TracBrowser for help on using the repository browser.