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: SSR split mode #7220

Merged
merged 20 commits into from
Jun 21, 2023
Merged

feat: SSR split mode #7220

merged 20 commits into from
Jun 21, 2023

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented May 26, 2023

Changes

This PR adds a new SSR mode, called split.

Serverless mode creates an entry point for each page, and each entry point is a self-contained application meant to render one single page.

Here's a list of changes:

  • added a new split boolean to the build object; by default, the value is false, which means that Astro will keep the current behaviour;
  • plugin-ssr.ts will emit two plugins, one to emit SSR server and one for SSR split, and they can't coexist. One is used, and the other won't. The reason why the two plugins live in the same file is that they share the majority of the code;
  • in plugin-ssr.ts the code that generates the deserialisation of the manifest was moved into a function, shared between the new plugins;
  • the shape of the manifest now changes a bit based on the split value. pageMap is kept for SSR server, while SSR split has a simple pageModule function. Because of that, I created two types: SSRServerManifest and SSRServerlessManifest;
  • I created a new option called serverlessEntryPrefix; by default it's entry

Here's an example of the emitted output

├── chunks
│   ├── @my-ssr.6147f6ca.mjs
│   ├── astro.60173704.mjs
│   └── pages
│       ├── _slug_.astro.bbdede9d.mjs
│       ├── about.astro.60a22a11.mjs
│       └── index.astro.23e80271.mjs
├── pages
│   ├── blog
│   │   ├── entry._slug_.astro.mjs
│   │   └── entry.about.astro.mjs
│   └── entry.index.astro.mjs
└── renderers.mjs

Testing

Added some test case

Docs

/cc @withastro/maintainers-docs for feedback!

If you're OK with the APIs, then I will start drafting a PR in the docs repo, because now the payload of astro:build:ssr has an additional property

@changeset-bot
Copy link

changeset-bot bot commented May 26, 2023

🦋 Changeset detected

Latest commit: cd06296

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) labels May 26, 2023
@ematipico ematipico force-pushed the feat/serverless-mode branch 2 times, most recently from e770d22 to f98d395 Compare May 29, 2023 14:50
@ematipico ematipico marked this pull request as ready for review May 29, 2023 14:50
@ematipico ematipico requested a review from a team as a code owner May 29, 2023 14:50
@ematipico ematipico requested a review from matthewp May 29, 2023 14:51
@ematipico ematipico force-pushed the feat/serverless-mode branch 2 times, most recently from 157af39 to 0e7d932 Compare June 12, 2023 13:23
@ematipico
Copy link
Member Author

ematipico commented Jun 12, 2023

I rebased the branch. The PR should be ready for review

@github-actions github-actions bot added the semver: minor Change triggers a `minor` release label Jun 12, 2023
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@matthewp
Copy link
Contributor

We discussed offline. Integrations (adapters) will need to know the mapping of routes to the entrypoint. We discussed adding this to the astro:build:ssr hook, a property named entrypoints that is a map of Map<RouteData, URL> with the latter being the file URL of the entrypoint.

@ematipico ematipico changed the title feat: SSR serverless mode feat: SSR split mode Jun 14, 2023
@ematipico ematipico force-pushed the feat/serverless-mode branch 2 times, most recently from de11b09 to d49e185 Compare June 14, 2023 14:36
@github-actions github-actions bot removed the pkg: integration Related to any renderer integration (scope) label Jun 15, 2023
@ematipico ematipico requested review from bluwy and matthewp June 15, 2023 08:19
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@ematipico ematipico force-pushed the feat/serverless-mode branch from d4279f3 to 114eec4 Compare June 21, 2023 12:11
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants