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

fix: edge case when rsa depends on another rsa #785

Merged
merged 19 commits into from
Jul 11, 2024

Conversation

himself65
Copy link
Sponsor Contributor

No description provided.

Copy link

vercel bot commented Jul 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
waku ✅ Ready (Inspect) Visit Preview Jul 11, 2024 3:10am

Copy link

codesandbox-ci bot commented Jul 10, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@himself65 himself65 marked this pull request as ready for review July 10, 2024 06:30
@himself65
Copy link
Sponsor Contributor Author

@dai-shi ready to review

@@ -28,6 +28,12 @@ export const runner = (options: MiddlewareOptions): MiddlewareHandler => {
.map(async (middleware) => (await middleware).default(options)),
),
);

(globalThis as any).__WAKU_HACK_IMPORT__ = async (id: string) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__WAKU_HACK_IMPORT__ is unused, right?

btw, I don't like this hack. there must be a better way.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, React will read buildConfig and use WAKU_HACK_IMPORT to load the react server action

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, __WAKU_HACK_IMPORT__ should only be required for client. Let me see if I can do something.

@@ -189,9 +189,9 @@ export async function renderRsc(
) {
// XXX This doesn't support streaming unlike busboy
const formData = parseFormData(bodyStr, contentType);
args = await decodeReply(formData);
args = await decodeReply(formData, bundlerConfig);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually wonder why this works. This is basically resolving client entry. Can it be used for server entry?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's also resolving the server entry, yes

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In bundlerConfig, we use resolveClientEntry, so even if it works, it's confusing.

@@ -21,7 +21,7 @@ globalThis.__WAKU_${type}_CHUNK_LOAD__ ||= (
if (!globalThis.__WAKU_${type}_MODULE_LOADING__.has(id)) {
globalThis.__WAKU_${type}_MODULE_LOADING__.set(
id,
customImport(id).then((m) => {
(customImport ? customImport(id) : import(id)).then((m) => {
Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this won't work because node condition is not including react-server

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's why you need a vite server to load the module

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and import() doesn't support .ts(x) file in dev side

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but it should work on PRD, right?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, but ID is not correct; it is now like /path/to/file which is presented as HTTP resource

@dai-shi
Copy link
Owner

dai-shi commented Jul 11, 2024

__WAKU_HACK_IMPORT__ should be DEV only.
Can you find a solution without using it in PRD?
As I said, it feels strange to reuse bunderConfig for client for server.
Maybe, both bunderConfigForClient and bunderConfigForServer would be required.

const id = filePathToFileURL(fileId);
if (fileId.startsWith('@id/assets/')) {
const id = '.' + fileId.slice('@id'.length);
return { id, chunks: [id], name, async: true };
Copy link
Sponsor Contributor Author

@himself65 himself65 Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be ./assets/rsf0.js#func

and because rsdw.js is in dist/rsdw.js, it import() will work

Copy link
Owner

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good! Thanks for your work!

@dai-shi dai-shi merged commit fcb71df into dai-shi:main Jul 11, 2024
28 checks passed
@himself65 himself65 deleted the himself65/20240709/action branch July 11, 2024 16:28
@dai-shi dai-shi mentioned this pull request Jul 12, 2024
76 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants