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

Introducing Multi-threading #487

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open

Introducing Multi-threading #487

wants to merge 59 commits into from

Conversation

vezaynk
Copy link
Contributor

@vezaynk vezaynk commented May 5, 2023

Introducing multi-threading to off-load React SSR to work threads.

  • Multi-threaded rendering available in production mode only.
  • Worker pooling is setup using resource-pooler
  • Transform All hooks are no longer a function, but a path to import a function to use

I will leave comments on the diff discussing every important part for easier reviewing

Todos:

  • make nonces work
  • unit tests for hooks

packages/fastify-renderer/package.json Outdated Show resolved Hide resolved
packages/fastify-renderer/package.json Outdated Show resolved Hide resolved
packages/fastify-renderer/src/node/Plugin.ts Show resolved Hide resolved
packages/fastify-renderer/src/node/types.ts Outdated Show resolved Hide resolved
packages/fastify-renderer/test/routes.spec.ts Outdated Show resolved Hide resolved
packages/test-apps/simple-react/server.ts Show resolved Hide resolved
@vezaynk
Copy link
Contributor Author

vezaynk commented May 8, 2023

I'm updating most dev dependencies to make the linter accept satisfies.

@vezaynk
Copy link
Contributor Author

vezaynk commented May 8, 2023

@airhorns wds needs to have a version bump to @swc/core applied. satisfies doesn't build without it.

packages/fastify-renderer/test/routes.spec.ts Outdated Show resolved Hide resolved
packages/fastify-renderer/test/routes.spec.ts Show resolved Hide resolved
transpileOnly: true,
})
require(tsWorkerPath)
} catch {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this catch is going to catch any errors importing the actual target file, like syntax errors or runtime issues. Could we drive the decision to use ts-node or not with an environment variable or some other explicit instruction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think magic flags should be avoided imo, especially given that it only matters in development of this package itself.

.ts files will never appear in the built package, which will make this always throw when distributed, and always load the js file instead.

It's safe in that respect.

I can do it based on the existence of a .ts file instead. Would that be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@airhorns Actually this can be handled really nicely via vite, but I can't do that right now because the test app doesn't use vite. It could be a small project for later if you like.

packages/fastify-renderer/test/routes.spec.ts Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
@vezaynk vezaynk requested a review from airhorns November 19, 2023 19:02
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