source: trip-planner-front/node_modules/webpack/lib/DllPlugin.js@ fa375fe

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

initial commit

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