-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat: introduce RunnableDevEnvironment #18190
feat: introduce RunnableDevEnvironment #18190
Conversation
Run & review this pull request in StackBlitz Codeflow. |
ab90883
to
1182c73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I think this should help a lot with the ssrLoadModule
migration story. I think we should merge it to keep exploring. If others think we should review this, we can later revert it before the release.
I like that this is already a part of SSR by default ❤️ Can you clarify what this means?
|
Basically, the runner doesn't exist until it's called. I don't know how else to explain it. It's evaluated lazily. It's important to know because the initialisation of the runner has side effects. More is explained in the docs. |
Description
This PR introduces a new concept to the Environment API - the
RunnableDevEnvironment
. This is the environment that has a module runner in the same process. You can access it directly asenvironment.runner
. The runner itself is evaluated eagerly when it's accessed for the first time.By default, Vite SSR dev environment is a runnable environment. Due to environments being available during the build, there are some constraints in typing. You can either cast it to
RunnableDevEnvironment
or type guard it withisRunnableDevEnvironment
.You can create your own runnable environments using the
createRunnableDevEnvironment
function:You can configure the runner with the
runner
option (the previousrunner
option was renamed toremoteRunner
):