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: expose server resolved urls #8986

Merged
merged 8 commits into from
Jul 11, 2022

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jul 8, 2022

Description

Implements #8891

Expose devServer.resolvedUrls and previewServer.resolvedUrls.

This PR also removes a breaking change in Vite 3 where printUrls are async, now they are back as sync.

Additional context

This mostly refactors on how we resolve urls and print them.

Previously, printUrls handle the entire resolve and print flow. Now, we break it into two parts. Whenever the server starts/restarts, we resolve resolvedUrls. This usually happens in the listen() function which is async and we lend to avoid printUrls becoming async. Then, printUrls become a basic function that only reads resolvedUrls and prints it.

Not sure how to add tests to this, but works locally for me and for vite-plugin-qrcode.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy added the p2-nice-to-have Not breaking anything but nice to have (priority) label Jul 8, 2022
@netlify
Copy link

netlify bot commented Jul 8, 2022

Deploy Preview for vite-docs-main ready!

Name Link
🔨 Latest commit bed92b5
🔍 Latest deploy log https://app.netlify.com/sites/vite-docs-main/deploys/62cc55e3e5335800086e723b
😎 Deploy Preview https://deploy-preview-8986--vite-docs-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

one nitpick but other than that LGTM
Thanks for the refactor 👍

packages/vite/src/node/server/index.ts Show resolved Hide resolved
packages/vite/src/node/server/index.ts Outdated Show resolved Hide resolved
sapphi-red
sapphi-red previously approved these changes Jul 8, 2022
@bluwy
Copy link
Member Author

bluwy commented Jul 11, 2022

Pushed a commit to reset resolvedUrls when the dev server is closed. I didn't handle this for the preview server, as it's usually a "start-once" server (and it's coded that way), and the change is a bit tricky to implement.

sapphi-red
sapphi-red previously approved these changes Jul 11, 2022
@patak-dev patak-dev merged commit 26bcdc3 into vitejs:main Jul 11, 2022
@bluwy bluwy deleted the feat-expose-resolved-urls branch July 11, 2022 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants