feat: supports writing files to memory in CSR #3794
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thememfs
package.Details
🤖 Generated by Copilot at c84b8b2
memfs
package as a dependency to enable in-memory file system for server-side rendering (link, link)IFs
type frommemfs
and addfs
property toModernServerContext
class to store the in-memory file system instance for each request context (link, link)LruReader
class andinit
function inpackages/server/prod-server/src/libs/render/reader.ts
to use thefs
property instead of the disk for reading and updating file contents (link, link, link, link, link, link, link)packages/server/prod-server/src/libs/render/index.ts
since the file is read from the in-memory file system (link)ModernServer
class inpackages/server/prod-server/src/server/modernServer.ts
to initialize the file reader with thefs
property from the request context (link)ModernServer
class inpackages/server/prod-server/src/server/modernServer.ts
since the file reader is initialized per request (link)serverSideRender
option to theDevMiddlewareOptions
type inpackages/server/server/src/types.ts
and to the development middleware configuration inpackages/server/server/src/dev-tools/dev-middleware/index.ts
to enable the server-side rendering feature for the development middleware (link, link)ModernDevServer
class inpackages/server/server/src/server/devServer.ts
to set thefs
property of the request context to theoutputFileSystem
of the webpack development middleware (link)packages/server/server/src/server/devServer.ts
for formatting purposes (link)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
pnpm run change
.