-
Notifications
You must be signed in to change notification settings - Fork 980
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(RSC): Remove
entries.ts
file (#10533)
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
- Loading branch information
1 parent
3025afc
commit f1a3c1c
Showing
12 changed files
with
117 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import path from 'node:path' | ||
|
||
import type { PagesDependency } from '@redwoodjs/project-config' | ||
import { | ||
ensurePosixPath, | ||
getPaths, | ||
processPagesDir, | ||
} from '@redwoodjs/project-config' | ||
|
||
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> = {} | ||
|
||
// Add the various pages | ||
const pages = processPagesDir().map(withRelativeImports) | ||
for (const page of pages) { | ||
entries[page.importName] = page.path | ||
} | ||
|
||
// Add the ServerEntry entry, noting we use the "__rwjs__" prefix to avoid | ||
// any potential conflicts with user-defined entries | ||
const serverEntry = getPaths().web.entryServer | ||
if (!serverEntry) { | ||
throw new Error('Server Entry file not found') | ||
} | ||
entries['__rwjs__ServerEntry'] = serverEntry | ||
|
||
return entries | ||
} | ||
|
||
export async function getEntriesFromDist(): Promise<Record<string, string>> { | ||
const entriesDist = getPaths().web.distRscEntries | ||
const { serverEntries } = await import(makeFilePath(entriesDist)) | ||
return serverEntries | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.