next-client-pages-loader.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _stringifyRequest = require("../stringify-request");
  7. // this parameter: https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters
  8. function nextClientPagesLoader() {
  9. const pagesLoaderSpan = this.currentTraceSpan.traceChild("next-client-pages-loader");
  10. return pagesLoaderSpan.traceFn(()=>{
  11. const { absolutePagePath , page } = this.getOptions();
  12. pagesLoaderSpan.setAttribute("absolutePagePath", absolutePagePath);
  13. const stringifiedPageRequest = (0, _stringifyRequest).stringifyRequest(this, absolutePagePath);
  14. const stringifiedPage = JSON.stringify(page);
  15. return `
  16. (window.__NEXT_P = window.__NEXT_P || []).push([
  17. ${stringifiedPage},
  18. function () {
  19. return require(${stringifiedPageRequest});
  20. }
  21. ]);
  22. if(module.hot) {
  23. module.hot.dispose(function () {
  24. window.__NEXT_P.push([${stringifiedPage}])
  25. });
  26. }
  27. `;
  28. });
  29. }
  30. var _default = nextClientPagesLoader;
  31. exports.default = _default;
  32. //# sourceMappingURL=next-client-pages-loader.js.map