UNPKG

1.24 kBJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const ArrayPushCallbackChunkFormatPlugin = require("../javascript/ArrayPushCallbackChunkFormatPlugin");
9const EnableChunkLoadingPlugin = require("../javascript/EnableChunkLoadingPlugin");
10const JsonpChunkLoadingRuntimeModule = require("./JsonpChunkLoadingRuntimeModule");
11
12/** @typedef {import("../Chunk")} Chunk */
13/** @typedef {import("../Compilation")} Compilation */
14/** @typedef {import("../Compiler")} Compiler */
15
16class JsonpTemplatePlugin {
17 /**
18 * @deprecated use JsonpChunkLoadingRuntimeModule.getCompilationHooks instead
19 * @param {Compilation} compilation the compilation
20 * @returns {JsonpChunkLoadingRuntimeModule.JsonpCompilationPluginHooks} hooks
21 */
22 static getCompilationHooks(compilation) {
23 return JsonpChunkLoadingRuntimeModule.getCompilationHooks(compilation);
24 }
25
26 /**
27 * Apply the plugin
28 * @param {Compiler} compiler the compiler instance
29 * @returns {void}
30 */
31 apply(compiler) {
32 compiler.options.output.chunkLoading = "jsonp";
33 new ArrayPushCallbackChunkFormatPlugin().apply(compiler);
34 new EnableChunkLoadingPlugin("jsonp").apply(compiler);
35 }
36}
37
38module.exports = JsonpTemplatePlugin;