@nestjs-ssr/react 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { Injectable, Logger, Optional, Inject, Global, Module, SetMetadata } fro
2
2
  import { HttpAdapterHost, APP_INTERCEPTOR, Reflector } from '@nestjs/core';
3
3
  import * as fs from 'fs';
4
4
  import { existsSync, readFileSync, realpathSync as realpathSync$1, readlinkSync, readdirSync, readdir as readdir$1, lstatSync } from 'fs';
5
- import path2, { join, win32, posix } from 'path';
5
+ import path2, { join, relative, win32, posix } from 'path';
6
6
  import serialize from 'serialize-javascript';
7
7
  import escapeHtml from 'escape-html';
8
8
  import { renderToStaticMarkup } from 'react-dom/server';
@@ -426,12 +426,20 @@ var RenderService = class _RenderService {
426
426
  serverManifest = null;
427
427
  isDevelopment;
428
428
  ssrMode;
429
+ entryServerPath;
429
430
  constructor(templateParser, streamingErrorHandler, ssrMode, defaultHead) {
430
431
  this.templateParser = templateParser;
431
432
  this.streamingErrorHandler = streamingErrorHandler;
432
433
  this.defaultHead = defaultHead;
433
434
  this.isDevelopment = process.env.NODE_ENV !== "production";
434
435
  this.ssrMode = ssrMode || process.env.SSR_MODE || "string";
436
+ const absoluteTemplatePath = join(__dirname, "../templates/entry-server.tsx");
437
+ const relativeToApp = relative(process.cwd(), absoluteTemplatePath);
438
+ if (relativeToApp.startsWith("..")) {
439
+ this.entryServerPath = absoluteTemplatePath;
440
+ } else {
441
+ this.entryServerPath = "/" + relativeToApp.replace(/\\/g, "/");
442
+ }
435
443
  let templatePath;
436
444
  if (this.isDevelopment) {
437
445
  const packageTemplatePaths = [
@@ -527,7 +535,7 @@ var RenderService = class _RenderService {
527
535
  }
528
536
  let renderModule;
529
537
  if (this.vite) {
530
- renderModule = await this.vite.ssrLoadModule("/src/entry-server.tsx");
538
+ renderModule = await this.vite.ssrLoadModule(this.entryServerPath);
531
539
  } else {
532
540
  if (this.serverManifest) {
533
541
  const manifestEntry = Object.entries(this.serverManifest).find(([key, value]) => value.isEntry && key.includes("entry-server"));
@@ -611,7 +619,7 @@ var RenderService = class _RenderService {
611
619
  const templateParts = this.templateParser.parseTemplate(template);
612
620
  let renderModule;
613
621
  if (this.vite) {
614
- renderModule = await this.vite.ssrLoadModule("/src/entry-server.tsx");
622
+ renderModule = await this.vite.ssrLoadModule(this.entryServerPath);
615
623
  } else {
616
624
  if (this.serverManifest) {
617
625
  const manifestEntry = Object.entries(this.serverManifest).find(([key, value]) => value.isEntry && key.includes("entry-server"));
@@ -7092,10 +7100,10 @@ var Ignore = class {
7092
7100
  ignored(p) {
7093
7101
  const fullpath = p.fullpath();
7094
7102
  const fullpaths = `${fullpath}/`;
7095
- const relative = p.relative() || ".";
7096
- const relatives = `${relative}/`;
7103
+ const relative2 = p.relative() || ".";
7104
+ const relatives = `${relative2}/`;
7097
7105
  for (const m of this.relative) {
7098
- if (m.match(relative) || m.match(relatives)) return true;
7106
+ if (m.match(relative2) || m.match(relatives)) return true;
7099
7107
  }
7100
7108
  for (const m of this.absolute) {
7101
7109
  if (m.match(fullpath) || m.match(fullpaths)) return true;
@@ -7104,9 +7112,9 @@ var Ignore = class {
7104
7112
  }
7105
7113
  childrenIgnored(p) {
7106
7114
  const fullpath = p.fullpath() + "/";
7107
- const relative = (p.relative() || ".") + "/";
7115
+ const relative2 = (p.relative() || ".") + "/";
7108
7116
  for (const m of this.relativeChildren) {
7109
- if (m.match(relative)) return true;
7117
+ if (m.match(relative2)) return true;
7110
7118
  }
7111
7119
  for (const m of this.absoluteChildren) {
7112
7120
  if (m.match(fullpath)) return true;