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(nuxt): reload nitro when spa loading template updates #24036

Merged
merged 7 commits into from Oct 31, 2023

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Oct 30, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ 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

This registers the spa loading template as a path to restart nuxt for.

(I'll update this PR shortly to use watch hook so it doesn't need to restart, but opening it anyway to track.)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@stackblitz
Copy link

stackblitz bot commented Oct 30, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@danielroe danielroe requested a review from pi0 October 31, 2023 12:58
@danielroe danielroe marked this pull request as ready for review October 31, 2023 12:58
@danielroe
Copy link
Member Author

@pi0 do you think there's a way we can programmatically trigger a nitro rebuild to achieve HMR-like effect of updating spa loading template?

spaLoadingTemplate = 'app/spa-loading-template.html'
}
return [
relative(await get('rootDir'), resolve(await get('srcDir'), spaLoadingTemplate))
Copy link
Member

Choose a reason for hiding this comment

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

For future maintainability, I would create an array watchFiles and push to it (instead of directly contact edge case + filter

@pi0
Copy link
Member

pi0 commented Oct 31, 2023

do you think there's a way we can programmatically trigger a nitro rebuild to achieve HMR-like effect of updating spa loading template?

AFAIK rollup has no nice API for this and we really re-initialize rollup's watcher instance internally https://github.com/unjs/nitro/blob/main/src/build.ts#L528

@danielroe
Copy link
Member Author

If you're happy with us calling that nitro hook, we could instead just do that when we detect a change to the file. wdyt?

@pi0
Copy link
Member

pi0 commented Oct 31, 2023

Sure you can use rollup:reload too if it works πŸ‘πŸΌ (at least for Nitro 2, for Nitro 3 with other bundlers we might think of something better)

@danielroe danielroe changed the title fix(nuxt): reload nuxt when spa loading template updates fix(nuxt): reload nitro when spa loading template updates Oct 31, 2023
@danielroe danielroe merged commit 948b30d into main Oct 31, 2023
33 checks passed
@danielroe danielroe deleted the fix/reload-spa-loading branch October 31, 2023 18:05
@github-actions github-actions bot mentioned this pull request Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants