BaseUriRuntimeModule.js 653 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Ivan Kopeykin @vankop
  4. */
  5. "use strict";
  6. const RuntimeGlobals = require("../RuntimeGlobals");
  7. const RuntimeModule = require("../RuntimeModule");
  8. class BaseUriRuntimeModule extends RuntimeModule {
  9. constructor() {
  10. super("base uri", RuntimeModule.STAGE_ATTACH);
  11. }
  12. /**
  13. * @returns {string} runtime code
  14. */
  15. generate() {
  16. const { chunk } = this;
  17. const options = chunk.getEntryOptions();
  18. return `${RuntimeGlobals.baseURI} = ${
  19. options.baseUri === undefined
  20. ? "undefined"
  21. : JSON.stringify(options.baseUri)
  22. };`;
  23. }
  24. }
  25. module.exports = BaseUriRuntimeModule;