GetFullHashRuntimeModule.js 730 B

123456789101112131415161718192021222324252627282930
  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. this.fullHash = true;
  12. }
  13. /**
  14. * @returns {string | null} runtime code
  15. */
  16. generate() {
  17. const compilation = /** @type {Compilation} */ (this.compilation);
  18. const { runtimeTemplate } = compilation;
  19. return `${RuntimeGlobals.getFullHash} = ${runtimeTemplate.returningFunction(
  20. JSON.stringify(compilation.hash || "XXXX")
  21. )}`;
  22. }
  23. }
  24. module.exports = GetFullHashRuntimeModule;