Write Vite HTTPS config wrapper to node_modules/.aspire instead of node_modules/.bin#15857
Open
Write Vite HTTPS config wrapper to node_modules/.aspire instead of node_modules/.bin#15857
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15857Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15857" |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Vite HTTPS config wrapper generation in monorepos with hoisted dependencies by no longer writing the generated wrapper under node_modules/.bin (which may not exist), and by deferring HTTPS endpoint scheme changes until wrapper generation succeeds.
Changes:
- Generate the Vite HTTPS wrapper under the nearest
node_modules/.aspirefound by walking up from the app directory. - Move wrapper generation into
SubscribeHttpsEndpointsUpdateand have the cert callback only apply--config+ TLS env vars when wrapper generation succeeded. - Update JavaScript hosting tests to reflect the new “wrapper path is precomputed” flow.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/Aspire.Hosting.JavaScript.Tests/AddViteAppTests.cs | Updates tests to set AspireHttpsConfigPath and validate argument/env mutation based on that path. |
| src/Aspire.Hosting.JavaScript/ViteAppResource.cs | Adds AspireHttpsConfigPath to store the generated wrapper path for later use. |
| src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs | Implements nearest-node_modules discovery and writes wrapper into node_modules/.aspire; restructures HTTPS callbacks. |
d30f08f to
55a2a4d
Compare
…de_modules/.bin The generated aspire.vite.config wrapper was written to node_modules/.bin/ which doesn't exist when package managers hoist dependencies (e.g. yarn workspaces monorepos). Walk up from the app directory to find the nearest node_modules and write the wrapper to a .aspire subdirectory inside it. This ensures Node.js module resolution can find bare imports like 'vite' while also handling hoisted dependency trees. The import for the user's original config uses a relative path from the wrapper location. The SubscribeHttpsEndpointsUpdate callback unconditionally flips the endpoint scheme to HTTPS (the user opted in). The cert config callback retains the original precedence for determining which config to wrap: explicit --config argument > WithViteConfig > auto-detect default config files. Fixes #15853 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
55a2a4d to
71ec0a8
Compare
Contributor
|
🎬 CLI E2E Test Recordings — 55 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23960833521 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The generated aspire.vite.config wrapper was written to node_modules/.bin/ which doesn't exist when package managers hoist dependencies (e.g. yarn workspaces monorepos).
Walk up from the app directory to find the nearest node_modules and write the wrapper to a .aspire subdirectory inside it. This ensures Node.js module resolution can find bare imports like 'vite' while also handling hoisted dependency trees. The import for the user's original config uses an absolute path so it resolves correctly regardless of where the wrapper lives.
The config wrapper generation is moved to the SubscribeHttpsEndpointsUpdate callback (which runs before the cert config callback) so the endpoint scheme is only changed to HTTPS when the wrapper was successfully created. If no node_modules directory is found, a warning is logged and HTTPS config is skipped gracefully.
Fixes #15853
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: