Skip to content

Commit

Permalink
chore(rename): Rename output to distSsr (redwoodjs#10740)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Jun 6, 2024
1 parent fcd26b1 commit 9303d26
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 111 deletions.
10 changes: 5 additions & 5 deletions packages/ogimage-gen/src/OgImageMiddleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/ogimage-gen/src/OgImageMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export default class OgImageMiddleware {
)
} else {
return `${path.join(
getPaths().web.distServer,
getPaths().web.distSsr,
'ogImage',
currentRoute.relativeFilePath.replace(/\.([jt]sx)/, ''),
)}.og.mjs` // @MARK: Hardcoded mjs!
Expand Down
90 changes: 31 additions & 59 deletions packages/project-config/src/__tests__/paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('paths', () => {
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'route-manifest.json',
),
base: path.join(FIXTURE_BASEDIR, 'web'),
Expand Down Expand Up @@ -142,35 +142,28 @@ describe('paths', () => {
'storybook.manager.js',
),
dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'),
distEntryServer: path.join(
distSsrEntryServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'entry.server.mjs',
),
distServerEntryServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'entry.server.mjs',
),
distRouteHooks: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'routeHooks',
),
distClient: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'client'),
distRsc: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'rsc'),
distServer: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'server'),
distDocumentServer: path.join(
distSsr: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'ssr'),
distSsrDocument: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'Document.mjs',
),
distRscEntries: path.join(
Expand Down Expand Up @@ -384,7 +377,7 @@ describe('paths', () => {
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'route-manifest.json',
),
base: path.join(FIXTURE_BASEDIR, 'web'),
Expand Down Expand Up @@ -426,37 +419,30 @@ describe('paths', () => {
'storybook.manager.js',
),
dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'),
distEntryServer: path.join(
distSsrDocument: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'entry.server.mjs',
'ssr',
'Document.mjs',
),
distServerEntryServer: path.join(
distSsrEntryServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'entry.server.mjs',
),
distDocumentServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'Document.mjs',
),
distRouteHooks: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'routeHooks',
),
distClient: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'client'),
distRsc: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'rsc'),
distServer: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'server'),
distSsr: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'ssr'),
distRscEntries: path.join(
FIXTURE_BASEDIR,
'web',
Expand Down Expand Up @@ -714,7 +700,7 @@ describe('paths', () => {
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'route-manifest.json',
),
base: path.join(FIXTURE_BASEDIR, 'web'),
Expand Down Expand Up @@ -758,37 +744,30 @@ describe('paths', () => {
entryClient: null,
entryServer: null,
dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'),
distEntryServer: path.join(
distSsrDocument: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'entry.server.mjs',
),
distServerEntryServer: path.join(
'ssr',
'Document.mjs',
), // this is constructed regardless of presence of src/Document
distSsrEntryServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'entry.server.mjs',
),
distDocumentServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'Document.mjs',
), // this is constructed regardless of presence of src/Document
distRouteHooks: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'routeHooks',
),
distClient: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'client'),
distRsc: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'rsc'),
distServer: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'server'),
distSsr: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'ssr'),
distRscEntries: path.join(
FIXTURE_BASEDIR,
'web',
Expand Down Expand Up @@ -1002,7 +981,7 @@ describe('paths', () => {
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'route-manifest.json',
),
base: path.join(FIXTURE_BASEDIR, 'web'),
Expand Down Expand Up @@ -1043,37 +1022,30 @@ describe('paths', () => {
'storybook.manager.js',
),
dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'),
distEntryServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'entry.server.mjs',
),
distServerEntryServer: path.join(
distSsrEntryServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'entry.server.mjs',
),
distDocumentServer: path.join(
distSsrDocument: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'Document.mjs',
),
distRouteHooks: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'ssr',
'routeHooks',
),
distClient: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'client'),
distRsc: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'rsc'),
distServer: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'server'),
distSsr: path.join(FIXTURE_BASEDIR, 'web', 'dist', 'ssr'),
distRscEntries: path.join(
FIXTURE_BASEDIR,
'web',
Expand Down
32 changes: 13 additions & 19 deletions packages/project-config/src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ export interface WebPaths {
dist: string
distClient: string
distRsc: string
distServer: string
distEntryServer: string
distServerEntryServer: string
distDocumentServer: string
distSsr: string
distSsrDocument: string
distSsrEntryServer: string
distRouteHooks: string
distRscEntries: string
routeManifest: string
Expand Down Expand Up @@ -129,14 +128,13 @@ const PATH_WEB_DIR_DIST = 'web/dist'
// Used by Streaming & RSC builds to output to their individual folders
const PATH_WEB_DIR_DIST_CLIENT = 'web/dist/client'
const PATH_WEB_DIR_DIST_RSC = 'web/dist/rsc'
const PATH_WEB_DIR_DIST_SERVER = 'web/dist/server'
const PATH_WEB_DIR_DIST_SSR = 'web/dist/ssr'

const PATH_WEB_DIR_DIST_SERVER_ENTRY_SERVER = 'web/dist/server/entry.server.mjs'
const PATH_WEB_DIR_DIST_DOCUMENT = 'web/dist/server/Document.mjs'

const PATH_WEB_DIR_DIST_SERVER_ROUTEHOOKS = 'web/dist/server/routeHooks'
const PATH_WEB_DIR_DIST_SSR_ENTRY_SERVER = 'web/dist/ssr/entry.server.mjs'
const PATH_WEB_DIR_DIST_SSR_DOCUMENT = 'web/dist/ssr/Document.mjs'
const PATH_WEB_DIR_DIST_SSR_ROUTEHOOKS = 'web/dist/ssr/routeHooks'
const PATH_WEB_DIR_DIST_RSC_ENTRIES = 'web/dist/rsc/entries.mjs'
const PATH_WEB_DIR_ROUTE_MANIFEST = 'web/dist/server/route-manifest.json'
const PATH_WEB_DIR_ROUTE_MANIFEST = 'web/dist/ssr/route-manifest.json'

/**
* The Redwood config file is used as an anchor for the base directory of a project.
Expand Down Expand Up @@ -247,17 +245,13 @@ export const getPaths = (BASE_DIR: string = getBaseDir()): Paths => {
dist: path.join(BASE_DIR, PATH_WEB_DIR_DIST),
distClient: path.join(BASE_DIR, PATH_WEB_DIR_DIST_CLIENT),
distRsc: path.join(BASE_DIR, PATH_WEB_DIR_DIST_RSC),
distServer: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SERVER),
distEntryServer: path.join(
BASE_DIR,
PATH_WEB_DIR_DIST_SERVER_ENTRY_SERVER,
),
distServerEntryServer: path.join(
distSsr: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SSR),
distSsrDocument: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SSR_DOCUMENT),
distSsrEntryServer: path.join(
BASE_DIR,
'web/dist/server/entry.server.mjs',
PATH_WEB_DIR_DIST_SSR_ENTRY_SERVER,
),
distDocumentServer: path.join(BASE_DIR, PATH_WEB_DIR_DIST_DOCUMENT),
distRouteHooks: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SERVER_ROUTEHOOKS),
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),
types: path.join(BASE_DIR, 'web/types'),
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/buildRouteManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ export async function buildRouteManifest() {
console.log('routeManifest', JSON.stringify(routeManifest, null, 2))

const webRouteManifest = rwPaths.web.routeManifest
await fs.mkdir(rwPaths.web.distServer, { recursive: true })
await fs.mkdir(rwPaths.web.distSsr, { recursive: true })
return fs.writeFile(webRouteManifest, JSON.stringify(routeManifest, null, 2))
}

// TODO (STREAMING) Hacky work around because when you don't have a App.routeHook, esbuild doesn't create
// the pages folder in the dist/server/routeHooks directory.
// the pages folder in the dist/ssr/routeHooks directory.
// @MARK need to change to .mjs here if we use esm
const FIXME_constructRouteHookPath = (
routeHookSrcPath: string | null | undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/clientSsr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function resolveClientEntryForProd(
filePath: string,
clientEntries: Record<string, string>,
) {
const basePath = getPaths().web.distServer
const basePath = getPaths().web.distSsr
const entriesFile = getPaths().web.distRscEntries
const baseDir = path.dirname(entriesFile)
const absoluteClientEntries = Object.fromEntries(
Expand Down
10 changes: 5 additions & 5 deletions packages/vite/src/middleware/createMiddlewareRouter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ 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',
},
}
const mockUnixPaths = {
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',
},
}
Expand All @@ -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,
}
Expand Down
Loading

0 comments on commit 9303d26

Please sign in to comment.