source: imaps-frontend/node_modules/webpack/lib/dependencies/RequireIncludePlugin.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.8 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 {
9 JAVASCRIPT_MODULE_TYPE_AUTO,
10 JAVASCRIPT_MODULE_TYPE_DYNAMIC
11} = require("../ModuleTypeConstants");
12const RequireIncludeDependency = require("./RequireIncludeDependency");
13const RequireIncludeDependencyParserPlugin = require("./RequireIncludeDependencyParserPlugin");
14
15/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
16/** @typedef {import("../Compiler")} Compiler */
17/** @typedef {import("../javascript/JavascriptParser")} Parser */
18
19const PLUGIN_NAME = "RequireIncludePlugin";
20
21class RequireIncludePlugin {
22 /**
23 * Apply the plugin
24 * @param {Compiler} compiler the compiler instance
25 * @returns {void}
26 */
27 apply(compiler) {
28 compiler.hooks.compilation.tap(
29 PLUGIN_NAME,
30 (compilation, { normalModuleFactory }) => {
31 compilation.dependencyFactories.set(
32 RequireIncludeDependency,
33 normalModuleFactory
34 );
35 compilation.dependencyTemplates.set(
36 RequireIncludeDependency,
37 new RequireIncludeDependency.Template()
38 );
39
40 /**
41 * @param {Parser} parser parser parser
42 * @param {JavascriptParserOptions} parserOptions parserOptions
43 * @returns {void}
44 */
45 const handler = (parser, parserOptions) => {
46 if (parserOptions.requireInclude === false) return;
47 const warn = parserOptions.requireInclude === undefined;
48
49 new RequireIncludeDependencyParserPlugin(warn).apply(parser);
50 };
51
52 normalModuleFactory.hooks.parser
53 .for(JAVASCRIPT_MODULE_TYPE_AUTO)
54 .tap(PLUGIN_NAME, handler);
55 normalModuleFactory.hooks.parser
56 .for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
57 .tap(PLUGIN_NAME, handler);
58 }
59 );
60 }
61}
62module.exports = RequireIncludePlugin;
Note: See TracBrowser for help on using the repository browser.