source: frontend/node_modules/webpack/lib/dll/DllPlugin.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • 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 FlagAllModulesAsUsedPlugin = require("../FlagAllModulesAsUsedPlugin");
9const DllEntryPlugin = require("./DllEntryPlugin");
10const LibManifestPlugin = require("./LibManifestPlugin");
11
12/** @typedef {import("../../declarations/plugins/dll/DllPlugin").DllPluginOptions} DllPluginOptions */
13/** @typedef {import("../Compiler")} Compiler */
14/** @typedef {import("./DllEntryPlugin").Entries} Entries */
15/** @typedef {import("./DllEntryPlugin").Options} Options */
16
17const PLUGIN_NAME = "DllPlugin";
18
19class DllPlugin {
20 /**
21 * Creates an instance of DllPlugin.
22 * @param {DllPluginOptions} options options object
23 */
24 constructor(options) {
25 /** @type {DllPluginOptions} */
26 this.options = options;
27 }
28
29 /**
30 * Applies the plugin by registering its hooks on the compiler.
31 * @param {Compiler} compiler the compiler instance
32 * @returns {void}
33 */
34 apply(compiler) {
35 compiler.hooks.validate.tap(PLUGIN_NAME, () => {
36 compiler.validate(
37 () => require("../../schemas/plugins/dll/DllPlugin.json"),
38 this.options,
39 {
40 name: "Dll Plugin",
41 baseDataPath: "options"
42 },
43 (options) =>
44 require("../../schemas/plugins/dll/DllPlugin.check")(options)
45 );
46 });
47
48 const entryOnly = this.options.entryOnly !== false;
49 compiler.hooks.entryOption.tap(PLUGIN_NAME, (context, entry) => {
50 if (typeof entry !== "function") {
51 for (const name of Object.keys(entry)) {
52 /** @type {Options} */
53 const options = { name };
54 new DllEntryPlugin(
55 context,
56 /** @type {Entries} */
57 (entry[name].import),
58 options
59 ).apply(compiler);
60 }
61 } else {
62 throw new Error(
63 `${PLUGIN_NAME} doesn't support dynamic entry (function) yet`
64 );
65 }
66 return true;
67 });
68 new LibManifestPlugin({ ...this.options, entryOnly }).apply(compiler);
69 if (!entryOnly) {
70 new FlagAllModulesAsUsedPlugin(PLUGIN_NAME).apply(compiler);
71 }
72 }
73}
74
75module.exports = DllPlugin;
Note: See TracBrowser for help on using the repository browser.