From c7d26ef0c988f7feefe688315ee63318140d6fd8 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Thu, 6 Jun 2024 07:52:33 +0200 Subject: [PATCH] only one dist/ssr/entry-server --- .../ogimage-gen/src/OgImageMiddleware.test.ts | 10 ++--- .../src/__tests__/paths.test.ts | 38 +++---------------- packages/project-config/src/paths.ts | 7 ++-- .../middleware/createMiddlewareRouter.test.ts | 10 ++--- 4 files changed, 19 insertions(+), 46 deletions(-) diff --git a/packages/ogimage-gen/src/OgImageMiddleware.test.ts b/packages/ogimage-gen/src/OgImageMiddleware.test.ts index 155cdcc43639..5a87d067775b 100644 --- a/packages/ogimage-gen/src/OgImageMiddleware.test.ts +++ b/packages/ogimage-gen/src/OgImageMiddleware.test.ts @@ -171,7 +171,7 @@ describe('OgImageMiddleware', () => { } const expectedFilePath = - '/redwood-app/web/dist/server/ogImage/pages/Contact/ContactPage/ContactPage.og.mjs' + '/redwood-app/web/dist/ssr/ogImage/pages/Contact/ContactPage/ContactPage.og.mjs' const tsxResult = middleware.getOgComponentPath(tsxRoute) const jsxResult = middleware.getOgComponentPath(jsxRoute) @@ -227,7 +227,7 @@ describe('OgImageMiddleware', () => { // The memfs mocks don't seem to work for this file vi.mock( - '/redwood-app/web/dist/server/ogImage/pages/Contact/ContactPage/ContactPage.og.mjs', + '/redwood-app/web/dist/ssr/ogImage/pages/Contact/ContactPage/ContactPage.og.mjs', () => ({ data: () => 'mocked data function', output: () => 'Mocked component render', @@ -262,7 +262,7 @@ describe('OgImageMiddleware', () => { // The memfs mocks don't seem to work for this file vi.mock( - '/redwood-app/web/dist/server/ogImage/pages/HomePage/HomePage.og.mjs', + '/redwood-app/web/dist/ssr/ogImage/pages/HomePage/HomePage.og.mjs', () => ({ data: () => 'mocked data function', output: () => 'Mocked component render', @@ -289,7 +289,7 @@ describe('OgImageMiddleware', () => { // The memfs mocks don't seem to work for this file vi.mock( - '/redwood-app/web/dist/server/ogImage/pages/HomePage/HomePage.og.mjs', + '/redwood-app/web/dist/ssr/ogImage/pages/HomePage/HomePage.og.mjs', () => ({ data: () => 'mocked data function', output: () => 'Mocked component render', @@ -314,7 +314,7 @@ describe('OgImageMiddleware', () => { // The memfs mocks don't seem to work for this file vi.mock( - '/redwood-app/web/dist/server/ogImage/pages/Contact/ContactPage/ContactPage.og.mjs', + '/redwood-app/web/dist/ssr/ogImage/pages/Contact/ContactPage/ContactPage.og.mjs', () => ({ data: () => 'mocked data function', output: () => 'Mocked component render', diff --git a/packages/project-config/src/__tests__/paths.test.ts b/packages/project-config/src/__tests__/paths.test.ts index e9f1de4c5bc6..7c83d20e6fe0 100644 --- a/packages/project-config/src/__tests__/paths.test.ts +++ b/packages/project-config/src/__tests__/paths.test.ts @@ -142,13 +142,6 @@ describe('paths', () => { 'storybook.manager.js', ), dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'), - distEntryServer: path.join( - FIXTURE_BASEDIR, - 'web', - 'dist', - 'ssr', - 'entry.server.mjs', - ), distSsrEntryServer: path.join( FIXTURE_BASEDIR, 'web', @@ -426,12 +419,12 @@ describe('paths', () => { 'storybook.manager.js', ), dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'), - distEntryServer: path.join( + distSsrDocument: path.join( FIXTURE_BASEDIR, 'web', 'dist', 'ssr', - 'entry.server.mjs', + 'Document.mjs', ), distSsrEntryServer: path.join( FIXTURE_BASEDIR, @@ -440,13 +433,6 @@ describe('paths', () => { 'ssr', 'entry.server.mjs', ), - distSsrDocument: path.join( - FIXTURE_BASEDIR, - 'web', - 'dist', - 'ssr', - 'Document.mjs', - ), distRouteHooks: path.join( FIXTURE_BASEDIR, 'web', @@ -758,13 +744,13 @@ describe('paths', () => { entryClient: null, entryServer: null, dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'), - distEntryServer: path.join( + distSsrDocument: path.join( FIXTURE_BASEDIR, 'web', 'dist', 'ssr', - 'entry.server.mjs', - ), + 'Document.mjs', + ), // this is constructed regardless of presence of src/Document distSsrEntryServer: path.join( FIXTURE_BASEDIR, 'web', @@ -772,13 +758,6 @@ describe('paths', () => { 'ssr', 'entry.server.mjs', ), - distSsrDocument: path.join( - FIXTURE_BASEDIR, - 'web', - 'dist', - 'ssr', - 'Document.mjs', - ), // this is constructed regardless of presence of src/Document distRouteHooks: path.join( FIXTURE_BASEDIR, 'web', @@ -1043,13 +1022,6 @@ describe('paths', () => { 'storybook.manager.js', ), dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'), - distEntryServer: path.join( - FIXTURE_BASEDIR, - 'web', - 'dist', - 'ssr', - 'entry.server.mjs', - ), distSsrEntryServer: path.join( FIXTURE_BASEDIR, 'web', diff --git a/packages/project-config/src/paths.ts b/packages/project-config/src/paths.ts index 8aa6358d79b9..35d89374ee7c 100644 --- a/packages/project-config/src/paths.ts +++ b/packages/project-config/src/paths.ts @@ -51,7 +51,6 @@ export interface WebPaths { distClient: string distRsc: string distSsr: string - distEntryServer: string distSsrDocument: string distSsrEntryServer: string distRouteHooks: string @@ -247,9 +246,11 @@ export const getPaths = (BASE_DIR: string = getBaseDir()): Paths => { distClient: path.join(BASE_DIR, PATH_WEB_DIR_DIST_CLIENT), distRsc: path.join(BASE_DIR, PATH_WEB_DIR_DIST_RSC), distSsr: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SSR), - distEntryServer: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SSR_ENTRY_SERVER), distSsrDocument: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SSR_DOCUMENT), - distSsrEntryServer: path.join(BASE_DIR, 'web/dist/ssr/entry.server.mjs'), + distSsrEntryServer: path.join( + BASE_DIR, + PATH_WEB_DIR_DIST_SSR_ENTRY_SERVER, + ), distRouteHooks: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SSR_ROUTEHOOKS), distRscEntries: path.join(BASE_DIR, PATH_WEB_DIR_DIST_RSC_ENTRIES), routeManifest: path.join(BASE_DIR, PATH_WEB_DIR_ROUTE_MANIFEST), diff --git a/packages/vite/src/middleware/createMiddlewareRouter.test.ts b/packages/vite/src/middleware/createMiddlewareRouter.test.ts index 8914cbbda8ab..706f8ac27028 100644 --- a/packages/vite/src/middleware/createMiddlewareRouter.test.ts +++ b/packages/vite/src/middleware/createMiddlewareRouter.test.ts @@ -8,7 +8,7 @@ vi.mock('@redwoodjs/project-config', async () => { web: { base: 'C:\\proj\\web', dist: 'C:\\proj\\web\\dist', - distEntryServer: 'C:\\proj\\web\\dist\\entry-server.mjs', + distSsrEntryServer: 'C:\\proj\\web\\dist\\ssr\\entry-server.mjs', entryServer: 'C:\\proj\\web\\entry-server.tsx', }, } @@ -16,7 +16,7 @@ vi.mock('@redwoodjs/project-config', async () => { web: { base: '/proj/web', dist: '/proj/web/dist', - distEntryServer: '/proj/web/dist/entry-server.mjs', + distSsrEntryServer: '/proj/web/dist/ssr/entry-server.mjs', entryServer: '/proj/web/entry-server.tsx', }, } @@ -30,19 +30,19 @@ vi.mock('@redwoodjs/project-config', async () => { }) const distRegisterMwMock = vi.fn() -vi.mock('/proj/web/dist/entry-server.mjs', () => { +vi.mock('/proj/web/dist/ssr/entry-server.mjs', () => { console.log('using unix mock') return { registerMiddleware: distRegisterMwMock, } }) -vi.mock('/C:/proj/web/dist/entry-server.mjs', () => { +vi.mock('/C:/proj/web/dist/ssr/entry-server.mjs', () => { console.log('using win32 mock') return { registerMiddleware: distRegisterMwMock, } }) -vi.mock('/C:/proj/web/dist/entry-server.mjs', () => { +vi.mock('/C:/proj/web/dist/ssr/entry-server.mjs', () => { return { registerMiddleware: distRegisterMwMock, }