Skip to content
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

rename rscPrefix to rscPath #160

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- breaking: switch to full SSR from RSC-only SSR #147
### Changed
- fix: support node 20 #159
- rename rscPrefix to rscPath #160

## [0.16.0] - 2023-10-25
### Changed
Expand Down
4 changes: 2 additions & 2 deletions packages/waku/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export interface Config {
entriesJs?: string;
/**
* Prefix for HTTP requests to indicate RSC requests.
* Defaults to "RSC/".
* Defaults to "RSC".
*/
rscPrefix?: string;
rscPath?: string;
/**
* ssr middleware specific configs.
*/
Expand Down
9 changes: 5 additions & 4 deletions packages/waku/src/lib/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,9 @@ const emitRscFiles = async (
config.rootDir,
config.distDir,
config.publicDir,
config.rscPath,
// HACK to support windows filesystem
(config.rscPrefix + encodeInput(input)).replaceAll("/", path.sep),
encodeInput(input).replaceAll("/", path.sep),
);
if (!rscFileSet.has(destFile)) {
rscFileSet.add(destFile);
Expand All @@ -276,7 +277,7 @@ const emitHtmlFiles = async (
getClientModules: (input: string) => string[],
ssr: boolean,
) => {
const basePrefix = config.basePath + config.rscPrefix;
const basePrefix = config.basePath + config.rscPath + "/";
const publicIndexHtmlFile = path.join(
config.rootDir,
config.distDir,
Expand Down Expand Up @@ -364,7 +365,7 @@ const emitVercelOutput = (
const serverlessDir = path.join(
dstDir,
"functions",
config.rscPrefix.replace(/\/$/, ".func"),
config.rscPath + ".func",
);
fs.mkdirSync(path.join(serverlessDir, config.distDir), {
recursive: true,
Expand Down Expand Up @@ -424,7 +425,7 @@ export default async function handler(req, res) {
{ contentType: "text/html" },
]),
]);
const basePrefix = config.basePath + config.rscPrefix;
const basePrefix = config.basePath + config.rscPath + "/";
const routes = [{ src: basePrefix + "(.*)", dest: basePrefix }];
const configJson = { version: 3, overrides, routes };
fs.mkdirSync(dstDir, { recursive: true });
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function resolveConfig() {
publicDir: "public",
indexHtml: "index.html",
entriesJs: "entries.js",
rscPrefix: "RSC/",
rscPath: "RSC",
...config,
ssr: {
splitHTML,
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/middleware/rsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function rsc<Context>(options: {

return async (req, res, next) => {
const config = await configPromise;
const basePrefix = config.basePath + config.rscPrefix;
const basePrefix = config.basePath + config.rscPath + "/";
const pathStr = req.url || "";
const handleError = (err: unknown) => {
if (hasStatusCode(err)) {
Expand Down
Loading