modern.js icon indicating copy to clipboard operation
modern.js copied to clipboard

[WIP] feat(server): support ssr running in vm

Open Amour1688 opened this issue 2 years ago • 5 comments

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_NAME import from ssr.ts and add runServerRender import from utils.ts (link)
  • Replace bundleJS require and serverRender call with runServerRender function in render function in ssr.ts (link)
  • Move utils.ts file from libs/render to libs/render/ssr and add or remove imports accordingly (link)
  • Add runServerRender function to utils.ts to 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.

Amour1688 avatar Aug 11 '23 07:08 Amour1688

⚠️ 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

changeset-bot[bot] avatar Aug 11 '23 07:08 changeset-bot[bot]

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 11 '23 07:08 CLAassistant

Do you mean a natural raw JavaScript Context without no API support by "VM"?

zoolsher avatar Aug 11 '23 07:08 zoolsher

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.

codecov[bot] avatar Aug 11 '23 07:08 codecov[bot]

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.

Amour1688 avatar Aug 11 '23 13:08 Amour1688

Closed as the PR is outdated, feel free to reopen it if it is still needed.

chenjiahan avatar Mar 23 '24 03:03 chenjiahan