-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Reworks RSC server entries and route manifest building to derive from routes and include if route info related to authentication #10572
Changes from 3 commits
ecb5faf
3e42a4c
2b6ebf1
674a725
dfdea38
6416eba
569b510
74a9694
f7e35e8
01f47f4
0f5b4f2
9e9f062
400580f
92659c3
778929a
0ace4af
2e7bf8b
ba02c65
4584164
6418794
7184362
a2ac9fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,24 @@ | ||
import path from 'node:path' | ||
|
||
import type { PagesDependency } from '@redwoodjs/project-config' | ||
import { | ||
ensurePosixPath, | ||
getPaths, | ||
processPagesDir, | ||
} from '@redwoodjs/project-config' | ||
import { ensurePosixPath, getPaths } from '@redwoodjs/project-config' | ||
import { getProject } from '@redwoodjs/structure/dist/index' | ||
import type { RWPage } from '@redwoodjs/structure/dist/model/RWPage' | ||
import type { RWRoute } from '@redwoodjs/structure/dist/model/RWRoute' | ||
|
||
import { makeFilePath } from '../utils' | ||
|
||
const getPathRelativeToSrc = (maybeAbsolutePath: string) => { | ||
// If the path is already relative | ||
if (!path.isAbsolute(maybeAbsolutePath)) { | ||
return maybeAbsolutePath | ||
} | ||
|
||
return `./${path.relative(getPaths().web.src, maybeAbsolutePath)}` | ||
} | ||
|
||
const withRelativeImports = (page: PagesDependency) => { | ||
return { | ||
...page, | ||
relativeImport: ensurePosixPath(getPathRelativeToSrc(page.importPath)), | ||
} | ||
} | ||
|
||
export function getEntries() { | ||
const entries: Record<string, string> = {} | ||
|
||
// Build the entries object based on routes and pages | ||
// Given the page's route, we can determine whether or not | ||
// the entry requires authentication checks | ||
const rwProject = getProject(getPaths().base) | ||
const routes = rwProject.getRouter().routes | ||
|
||
// Add the various pages | ||
const pages = processPagesDir().map(withRelativeImports) | ||
const pages = routes.map((route: RWRoute) => route.page) as RWPage[] | ||
|
||
for (const page of pages) { | ||
entries[page.importName] = page.path | ||
entries[page.const_] = ensurePosixPath(page.path) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsure of the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this do again? Sorry can't remember 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use on
Before, the
Whatever I think it comes from structure model File or BaseNode. |
||
|
||
// Add the ServerEntry entry, noting we use the "__rwjs__" prefix to avoid | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to keep "Private"? I think it has to be "PrivateSet" now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say lets remove
Private
in a separate PR, and remove it from exports too!