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

feat: supports writing files to memory in CSR #3794

Merged
merged 2 commits into from
May 31, 2023
Merged

Conversation

zllkjc
Copy link
Member

@zllkjc zllkjc commented May 29, 2023

Summary

#3343

🤖 Generated by Copilot at c84b8b2

Added server-side rendering feature with in-memory file system for improved performance and reliability. Refactored the file reader and the server context to use memfs package. Added a handler to the development server and middleware to enable the feature. Added a new integration test project to verify the feature without writing to disk. Updated the dependencies and types for the memfs package.

Details

🤖 Generated by Copilot at c84b8b2

  • Add memfs package as a dependency to enable in-memory file system for server-side rendering (link, link)
  • Import IFs type from memfs and add fs property to ModernServerContext class to store the in-memory file system instance for each request context (link, link)
  • Modify LruReader class and init function in packages/server/prod-server/src/libs/render/reader.ts to use the fs property instead of the disk for reading and updating file contents (link, link, link, link, link, link, link)
  • Remove the check for template file existence on the disk in packages/server/prod-server/src/libs/render/index.ts since the file is read from the in-memory file system (link)
  • Add a handler to the ModernServer class in packages/server/prod-server/src/server/modernServer.ts to initialize the file reader with the fs property from the request context (link)
  • Remove the code that initializes the file reader in the constructor of the ModernServer class in packages/server/prod-server/src/server/modernServer.ts since the file reader is initialized per request (link)
  • Add the serverSideRender option to the DevMiddlewareOptions type in packages/server/server/src/types.ts and to the development middleware configuration in packages/server/server/src/dev-tools/dev-middleware/index.ts to enable the server-side rendering feature for the development middleware (link, link)
  • Add a handler to the ModernDevServer class in packages/server/server/src/server/devServer.ts to set the fs property of the request context to the outputFileSystem of the webpack development middleware (link)
  • Add an empty line to packages/server/server/src/server/devServer.ts for formatting purposes (link)
  • Add a new integration test project in tests/integration/write-to-dist to verify the server-side rendering feature without writing to disk (link, link, link, link, link, 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.

@changeset-bot
Copy link

changeset-bot bot commented May 29, 2023

⚠️ No Changeset found

Latest commit: ce2c8ee

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

@zllkjc zllkjc force-pushed the feat/memory-html branch 2 times, most recently from 63a5b4c to 2144164 Compare May 30, 2023 11:47
@zllkjc zllkjc changed the title WIP feat: supports writing files to memory in CSR feat: supports writing files to memory in CSR May 30, 2023
@codecov
Copy link

codecov bot commented May 30, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01 ⚠️

Comparison is base (99693f0) 57.59% compared to head (ce2c8ee) 57.58%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3794      +/-   ##
==========================================
- Coverage   57.59%   57.58%   -0.01%     
==========================================
  Files         672      649      -23     
  Lines       17794    17413     -381     
  Branches     3876     3800      -76     
==========================================
- Hits        10249    10028     -221     
+ Misses       6934     6770     -164     
- Partials      611      615       +4     

see 290 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@chenjiahan chenjiahan merged commit fdd8e6d into main May 31, 2023
6 checks passed
@chenjiahan chenjiahan deleted the feat/memory-html branch May 31, 2023 02:23
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.

None yet

2 participants