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

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

F4 Finalna Verzija

  • 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 DllModuleFactory = require("./DllModuleFactory");
9const DllEntryDependency = require("./dependencies/DllEntryDependency");
10const EntryDependency = require("./dependencies/EntryDependency");
11
12/** @typedef {import("./Compiler")} Compiler */
13/** @typedef {string[]} Entries */
14/** @typedef {{ name: string, filename: TODO }} Options */
15
16class DllEntryPlugin {
17 /**
18 * @param {string} context context
19 * @param {Entries} entries entry names
20 * @param {Options} options options
21 */
22 constructor(context, entries, options) {
23 this.context = context;
24 this.entries = entries;
25 this.options = options;
26 }
27
28 /**
29 * Apply the plugin
30 * @param {Compiler} compiler the compiler instance
31 * @returns {void}
32 */
33 apply(compiler) {
34 compiler.hooks.compilation.tap(
35 "DllEntryPlugin",
36 (compilation, { normalModuleFactory }) => {
37 const dllModuleFactory = new DllModuleFactory();
38 compilation.dependencyFactories.set(
39 DllEntryDependency,
40 dllModuleFactory
41 );
42 compilation.dependencyFactories.set(
43 EntryDependency,
44 normalModuleFactory
45 );
46 }
47 );
48 compiler.hooks.make.tapAsync("DllEntryPlugin", (compilation, callback) => {
49 compilation.addEntry(
50 this.context,
51 new DllEntryDependency(
52 this.entries.map((e, idx) => {
53 const dep = new EntryDependency(e);
54 dep.loc = {
55 name: this.options.name,
56 index: idx
57 };
58 return dep;
59 }),
60 this.options.name
61 ),
62 this.options,
63 error => {
64 if (error) return callback(error);
65 callback();
66 }
67 );
68 });
69 }
70}
71
72module.exports = DllEntryPlugin;
Note: See TracBrowser for help on using the repository browser.