GetFullHashRuntimeModule.js 755 B

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