Skip to content

Commit

Permalink
revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Dec 7, 2023
1 parent 532cf11 commit bc8ee3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
16 changes: 5 additions & 11 deletions packages/waku/src/lib/middleware/rsc/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ const loadServerFile = async (
return import(fileURL);
}
const vite = await getViteServer();
console.log('fileURL', fileURL);
return vite.ssrLoadModule(fileURLToFilePath(fileURL));
};

Expand Down Expand Up @@ -396,27 +395,22 @@ export const renderHtml = async <Context>(
{},
{
get(_target, name: string) {
console.log('get', filePath, name);
const file = filePath.startsWith('/@id/')
? filePath
: filePath.slice(config.basePath.length);
const file = filePath.slice(config.basePath.length);
if (command === 'dev') {
const resolvedFilePath = file.startsWith('@fs/')
const filePath = file.startsWith('@fs/')
? decodeFilePathFromAbsolute(file.slice('@fs'.length))
: joinPath(config.rootDir, file);
const wakuDist = joinPath(
fileURLToFilePath(import.meta.url),
'../../../..',
);
if (resolvedFilePath.startsWith(wakuDist)) {
if (filePath.startsWith(wakuDist)) {
const id =
'waku' +
resolvedFilePath
.slice(wakuDist.length)
.replace(/\.\w+$/, '');
filePath.slice(wakuDist.length).replace(/\.\w+$/, '');
return { id, chunks: [id], name };
}
const id = filePathToFileURL(resolvedFilePath) + '#dev';
const id = filePathToFileURL(filePath) + '#dev';
return { id, chunks: [id], name };
}
// command !== 'dev'
Expand Down
6 changes: 1 addition & 5 deletions packages/waku/src/lib/rsc/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ const resolveClientEntry = (
return config.basePath + '@fs' + encodeFilePathToAbsolute(filePath);
}
if (!filePath.startsWith(root)) {
throw new Error(
'Resolving client module outside root is not supported.',
);
throw new Error('Resolving client module outside root is not supported.');
}
return config.basePath + relativePath(root, filePath);
};
Expand Down Expand Up @@ -139,7 +137,6 @@ export async function renderRSC(

const rsfPrefix =
joinPath(config.rootDir, isDev ? config.srcDir : config.distDir) + '/';
console.log(rsfPrefix);

const render = async (renderContext: RenderContext, input: string) => {
const elements = await renderEntries.call(renderContext, input);
Expand All @@ -159,7 +156,6 @@ export async function renderRSC(
{
get(_target, encodedId: string) {
const [file, name] = encodedId.split('#') as [string, string];
console.log('file', file, name);
const id = resolveClientEntry(file, config, isDev);
moduleIdCallback?.(id);
return { id, chunks: [id], name, async: true };
Expand Down

0 comments on commit bc8ee3e

Please sign in to comment.