[WIP] feat(server): support ssr running in vm
Summary
🤖 Generated by Copilot at 1d351d4
Refactored and improved server-side rendering logic for prod-server. Extracted rendering code to runServerRender function in libs/render/ssr/utils.ts and added VM mode support for better isolation and security. Moved utils.ts to ssr folder for better organization.
Details
🤖 Generated by Copilot at 1d351d4
- Simplify and enable VM mode for server-side rendering logic (link, link, link, link)
- Remove unused
SERVER_RENDER_FUNCTION_NAMEimport fromssr.tsand addrunServerRenderimport fromutils.ts(link) - Replace bundleJS require and serverRender call with
runServerRenderfunction inrenderfunction inssr.ts(link) - Move
utils.tsfile fromlibs/rendertolibs/render/ssrand add or remove imports accordingly (link) - Add
runServerRenderfunction toutils.tsto handle the server-side rendering logic with or without VM mode (link)
Related Issue
Checklist
- [ ] I have added changeset via
pnpm run change. - [ ] I have updated the documentation.
- [ ] I have added tests to cover my changes.
⚠️ No Changeset found
Latest commit: 08a945ce2d3fd3ed4ab7eadca60204d7af0bff30
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
Do you mean a natural raw JavaScript Context without no API support by "VM"?
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
99693f0) 57.59% compared to head (08a945c) 51.05%. Report is 1424 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #4420 +/- ##
==========================================
- Coverage 57.59% 51.05% -6.55%
==========================================
Files 672 672
Lines 17794 18607 +813
Branches 3876 4296 +420
==========================================
- Hits 10249 9500 -749
- Misses 6934 8401 +1467
- Partials 611 706 +95
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Do you mean a natural raw JavaScript Context without no API support by "VM"?
The main purpose is to achieve environment isolation. In some business scenarios, we've observed that some business users attach variables to the window object, and certain dependencies directly retrieve values from the window. However, this approach often requires rendering the entire process within a VM to keep the isolation.
However, we don't highly recommend businesses to run SSR within a VM.
Closed as the PR is outdated, feel free to reopen it if it is still needed.