source: frontend/node_modules/webpack/lib/dll/DllEntryPlugin.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: 1.9 KB
RevLine 
[9af201e]1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const DllEntryDependency = require("../dependencies/DllEntryDependency");
9const EntryDependency = require("../dependencies/EntryDependency");
10const DllModuleFactory = require("./DllModuleFactory");
11
12/** @typedef {import("../Compiler")} Compiler */
13/** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */
14
15/** @typedef {string[]} Entries */
16/** @typedef {EntryOptions & { name: string }} Options */
17
18const PLUGIN_NAME = "DllEntryPlugin";
19
20class DllEntryPlugin {
21 /**
22 * Creates an instance of DllEntryPlugin.
23 * @param {string} context context
24 * @param {Entries} entries entry names
25 * @param {Options} options options
26 */
27 constructor(context, entries, options) {
28 this.context = context;
29 this.entries = entries;
30 this.options = options;
31 }
32
33 /**
34 * Applies the plugin by registering its hooks on the compiler.
35 * @param {Compiler} compiler the compiler instance
36 * @returns {void}
37 */
38 apply(compiler) {
39 compiler.hooks.compilation.tap(
40 PLUGIN_NAME,
41 (compilation, { normalModuleFactory }) => {
42 const dllModuleFactory = new DllModuleFactory();
43 compilation.dependencyFactories.set(
44 DllEntryDependency,
45 dllModuleFactory
46 );
47 compilation.dependencyFactories.set(
48 EntryDependency,
49 normalModuleFactory
50 );
51 }
52 );
53 compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
54 compilation.addEntry(
55 this.context,
56 new DllEntryDependency(
57 this.entries.map((e, idx) => {
58 const dep = new EntryDependency(e);
59 dep.loc = {
60 name: this.options.name,
61 index: idx
62 };
63 return dep;
64 }),
65 this.options.name
66 ),
67 this.options,
68 (error) => {
69 if (error) return callback(error);
70 callback();
71 }
72 );
73 });
74 }
75}
76
77module.exports = DllEntryPlugin;
Note: See TracBrowser for help on using the repository browser.