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 8 commits into from Jul 11, 2022


Copy link

@bluwy bluwy commented Jul 8, 2022


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
Copy link

netlify bot commented Jul 8, 2022

Deploy Preview for vite-docs-main ready!

Name Link
🔨 Latest commit bed92b5
🔍 Latest deploy log
😎 Deploy Preview
📱 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

@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 previously approved these changes Jul 8, 2022
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 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
p2-nice-to-have 🍰 Not breaking anything but nice to have (priority)
Archived in project

Successfully merging this pull request may close these issues.

None yet

3 participants