source: imaps-frontend/node_modules/webpack/lib/DllPlugin.js

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

F4 Finalna Verzija

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