JsonpTemplatePlugin.js 1.2 KB

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