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: hybrid output #6991

Merged
merged 54 commits into from
May 17, 2023
Merged

feat: hybrid output #6991

merged 54 commits into from
May 17, 2023

Conversation

MoustaphaDev
Copy link
Member

@MoustaphaDev MoustaphaDev commented May 4, 2023

Changes

Implementation of the hybrid rendering RFC.

This introduces the hybrid output format which enables prerendering by default and allows opting out of it with export const prerender = false.

Testing

We will use the existing prerendering test fixtures, but we will make prerendering a function of a PRERENDER environment variable, doing export const prerender = import.meta.env.PRERENDER so that we can set prerendering to false or true depending on which feature we're testing.

Docs

There's an open docs issue withastro/docs#3226

@changeset-bot
Copy link

changeset-bot bot commented May 4, 2023

🦋 Changeset detected

Latest commit: eb55a43

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 4, 2023
const ssr = opts.settings.config.output === 'server';
const ssr =
opts.settings.config.output === 'server' ||
(opts.settings.config.experimental.hybridOutput && opts.settings.config.output === 'hybrid');
Copy link
Contributor

Choose a reason for hiding this comment

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

This code seems to be repeated a lot in the PR. What do you think about a src/core/prerender/ folder where we can have a bunch of utility functions that do this sort of thing?

Copy link
Member Author

@MoustaphaDev MoustaphaDev May 15, 2023

Choose a reason for hiding this comment

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

Sounds like a good idea, I'll refactor this

// TODO: remove after the experimetal phase when
// it won't be needed to edit two config fields to enable the feature
function isHybridMalconfigured(config: AstroConfig) {
return config.experimental.hybridOutput ? config.output !== 'hybrid' : config.output === 'hybrid';
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an example of another function that might be nice to live in a prerender folder.

@matthewp
Copy link
Contributor

Code looks really great overall. I left some comments more about code organization. But functionality looks perfect. Really appreciate how much work this was and how thorough the testing is.

@matthewp
Copy link
Contributor

Also @MoustaphaDev can you add a changeset via pnpm changeset?

@MoustaphaDev
Copy link
Member Author

Sure, I'll add that

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

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

Comment on lines +3 to +8
'@astrojs/cloudflare': patch
'@astrojs/netlify': patch
'@astrojs/vercel': patch
'@astrojs/image': patch
'@astrojs/deno': patch
'@astrojs/node': patch
Copy link
Member Author

Choose a reason for hiding this comment

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

Marked these as 'patch' because I updated the warning we get when using these adapters with an unexpected output mode.

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Approving the docs edits!

@MoustaphaDev
Copy link
Member Author

Nice, thanks your reviews @sarah11918!

@matthewp matthewp merged commit 719002c into main May 17, 2023
@matthewp matthewp deleted the mk-feat/output-hybrid branch May 17, 2023 13:23
@astrobot-houston astrobot-houston mentioned this pull request May 17, 2023
This was referenced May 31, 2023
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) pkg: integration Related to any renderer integration (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants