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

fix: do not override preset when prerendering #605

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

BobbieGoede
Copy link
Member

@BobbieGoede BobbieGoede commented Dec 19, 2024

๐Ÿ”— Linked issue

โ“ Type of change

  • ๐Ÿ“– Documentation (updates to the documentation or readme)
  • ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • ๐Ÿ‘Œ Enhancement (improving an existing functionality)
  • โœจ New feature (a non-breaking change that adds functionality)
  • ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

Related to #555, possibly resolves it?

We currently override any configured preset with static, instead we should let nitro resolve the appropriate preset by passing static: true since it supports several static presets.

@BobbieGoede BobbieGoede self-assigned this Dec 19, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@2d61aa1). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/commands/build.ts 0.00% 5 Missing โš ๏ธ
Additional details and impacted files
@@          Coverage Diff           @@
##             main    #605   +/-   ##
======================================
  Coverage        ?   1.31%           
======================================
  Files           ?      44           
  Lines           ?    2894           
  Branches        ?      44           
======================================
  Hits            ?      38           
  Misses          ?    2815           
  Partials        ?      41           

โ˜” View full report in Codecov by Sentry.
๐Ÿ“ข Have feedback on the report? Share it here.

const nitroPreset = ctx.args.prerender ? 'static' : ctx.args.preset || process.env.NITRO_PRESET || process.env.SERVER_PRESET
const resolvedNitroPreset
= ctx.args.preset || process.env.NITRO_PRESET || process.env.SERVER_PRESET
const nitroPreset = ctx.args.prerender ? 'static' : resolvedNitroPreset
Copy link
Member

Choose a reason for hiding this comment

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

in fact this is still not quite right - there are several static presets, including vercel-static, netlify-static, and so on, and we probably need to ignore (that is, not log warnings) for any static preset that's passed

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like nitro tries to infer the correct static preset based on the value of preset when static: true (nitrojs/nitro#2860) it's undocumented though (nitrojs/nitro#1524). I just removed the logging and only fall back to static preset if none is provided during prerender, is this what you had in mind?

Copy link
Member

Choose a reason for hiding this comment

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

we should not set the static preset but instead pass static: true

you can test by setting (for example) NETLIFY=1 nuxi build --prerender - we want it in that case to use netlify-static preset.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay I think/hope I finally understand, I removed the overriding of the preset variable and now log the resolved nitro preset instead.

@BobbieGoede BobbieGoede changed the title fix: handle prerender case for preset env variables fix: do not override preset when prerendering Dec 20, 2024
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.

3 participants