source: imaps-frontend/node_modules/webpack/lib/PrefetchPlugin.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.1 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 PrefetchDependency = require("./dependencies/PrefetchDependency");
9
10/** @typedef {import("./Compiler")} Compiler */
11
12class PrefetchPlugin {
13 /**
14 * @param {string} context context or request if context is not set
15 * @param {string} [request] request
16 */
17 constructor(context, request) {
18 if (request) {
19 this.context = context;
20 this.request = request;
21 } else {
22 this.context = null;
23 this.request = context;
24 }
25 }
26
27 /**
28 * Apply the plugin
29 * @param {Compiler} compiler the compiler instance
30 * @returns {void}
31 */
32 apply(compiler) {
33 compiler.hooks.compilation.tap(
34 "PrefetchPlugin",
35 (compilation, { normalModuleFactory }) => {
36 compilation.dependencyFactories.set(
37 PrefetchDependency,
38 normalModuleFactory
39 );
40 }
41 );
42 compiler.hooks.make.tapAsync("PrefetchPlugin", (compilation, callback) => {
43 compilation.addModuleChain(
44 this.context || compiler.context,
45 new PrefetchDependency(this.request),
46 err => {
47 callback(err);
48 }
49 );
50 });
51 }
52}
53
54module.exports = PrefetchPlugin;
Note: See TracBrowser for help on using the repository browser.