GetFullHashRuntimeModule.js 807 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. */
  4. "use strict";
  5. const RuntimeGlobals = require("../RuntimeGlobals");
  6. const RuntimeModule = require("../RuntimeModule");
  7. /** @typedef {import("../Compilation")} Compilation */
  8. class GetFullHashRuntimeModule extends RuntimeModule {
  9. constructor() {
  10. super("getFullHash");
  11. /** @type {boolean} */
  12. this.fullHash = true;
  13. }
  14. /**
  15. * Generates runtime code for this runtime module.
  16. * @returns {string | null} runtime code
  17. */
  18. generate() {
  19. const compilation = /** @type {Compilation} */ (this.compilation);
  20. const { runtimeTemplate } = compilation;
  21. return `${RuntimeGlobals.getFullHash} = ${runtimeTemplate.returningFunction(
  22. JSON.stringify(compilation.hash || "XXXX")
  23. )}`;
  24. }
  25. }
  26. module.exports = GetFullHashRuntimeModule;