ChunkNameRuntimeModule.js 980 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. class ChunkNameRuntimeModule extends RuntimeModule {
  8. /**
  9. * Returns true, if the runtime module should get it's own scope.
  10. * When false, `generate()` must emit complete statements ending with `;`
  11. * so a following runtime IIFE is not parsed as a call (ASI).
  12. * @returns {boolean} true, if the runtime module should get it's own scope
  13. */
  14. shouldIsolate() {
  15. return false;
  16. }
  17. /**
  18. * @param {string} chunkName the chunk's name
  19. */
  20. constructor(chunkName) {
  21. super("chunkName");
  22. /** @type {string} */
  23. this.chunkName = chunkName;
  24. }
  25. /**
  26. * Generates runtime code for this runtime module.
  27. * @returns {string | null} runtime code
  28. */
  29. generate() {
  30. return `${RuntimeGlobals.chunkName} = ${JSON.stringify(this.chunkName)};`;
  31. }
  32. }
  33. module.exports = ChunkNameRuntimeModule;