Fix twoslash in AppHostBuilder; source-control twoslash .d.ts bundle#741
Merged
IEvangelist merged 1 commit intomainfrom Apr 21, 2026
Merged
Fix twoslash in AppHostBuilder; source-control twoslash .d.ts bundle#741IEvangelist merged 1 commit intomainfrom
IEvangelist merged 1 commit intomainfrom
Conversation
The homepage AppHostBuilder component rendered a ts(2307) 'Cannot find module ./.modules/aspire.js' error in the TypeScript view on production, while MDX fenced samples on /get-started/first-app/ worked fine. Root cause: Starlight's <Code> component resolves expressive-code config through astro-expressive-code's virtual module, which loses the runtime extraFiles VFS state in production builds; MDX fences flow through rehype-expressive-code with the live ec.config.mjs instance intact. Changes: - Remove meta=twoslash from AppHostBuilder.astro (not desired there anyway). - Relocate the generated aspire.d.ts bundle from transient .twoslash-types/ to source-controlled src/frontend/src/data/twoslash/aspire.d.ts so diffs are reviewable and dev/build startup is faster (no pre-build generation step). - Chain generate-twoslash-types.ts to run at the tail of update-ts-api.ts so the bundle stays in sync with src/data/ts-modules/*.json. - Drop pnpm twoslash-types from dev/start/build scripts in package.json; keep the manual pnpm twoslash-types script for ad-hoc refreshes. - Update ec.config.mjs, the vitest generator test, .gitignore, and the update-integrations SKILL.md to match the new location and workflow. Validated: unit tests pass (6/6); Playwright crawl against localhost:4321 across 22 docs pages with twoslash blocks reports 0 twoslash errors and rendered hovers intact.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a production-only twoslash resolution issue in the homepage AppHostBuilder TypeScript view by removing twoslash from that component path and moving the generated twoslash .d.ts bundle to a source-controlled location so hover types remain stable across build modes.
Changes:
- Remove
meta="twoslash"from the homepageAppHostBuildercode panel to avoid triggering broken twoslash resolution. - Store the consolidated twoslash declaration bundle under
src/data/twoslash/aspire.d.tsand update config/tests/scripts to use it. - Chain twoslash bundle regeneration into
update-ts-apiand remove automatic generation from dev/build scripts.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/frontend/tests/unit/twoslash-types-generator.vitest.test.ts | Updates the generator test to regenerate/read the now source-controlled aspire.d.ts bundle in place. |
| src/frontend/src/components/AppHostBuilder.astro | Removes twoslash meta from the homepage code view to prevent the prod-only module resolution failure. |
| src/frontend/scripts/update-ts-api.ts | Regenerates the twoslash .d.ts bundle after updating ts-modules so hover types stay in sync. |
| src/frontend/scripts/generate-twoslash-types.ts | Redirects generator output to src/data/twoslash/aspire.d.ts and updates documentation comments. |
| src/frontend/package.json | Drops pnpm twoslash-types from dev/start/build since the bundle is now checked in. |
| src/frontend/ec.config.mjs | Points expressive-code-twoslash at the new src/data/twoslash/aspire.d.ts location. |
| .gitignore | Removes the now-unused .twoslash-types/ ignore entry. |
| .github/skills/update-integrations/SKILL.md | Documents the new bundle location and the updated regeneration workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
eerhardt
approved these changes
Apr 21, 2026
slang25
added a commit
to slang25/aspire.dev
that referenced
this pull request
Apr 21, 2026
Two small defensive changes on top of microsoft#741: - Throw instead of warn when src/data/twoslash/aspire.d.ts is missing. Since microsoft#741 source-controls the bundle, a missing file means the tree is corrupted — catching that at build time beats silently shipping samples that can't resolve `./.modules/aspire.js`. - Flip noErrorValidation to false so unannotated TS errors fail the build rather than rendering as squigglies in the shipped HTML. Samples that deliberately illustrate a compiler error can opt in with `// @errors: <codes>`; otherwise an error means the sample (or the generated SDK shape) is wrong and should be fixed, not shown to readers. Verified with a full build: zero unannotated errors across the current docs.
4 tasks
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.
Summary
The homepage
AppHostBuildercomponent rendered ats(2307) Cannot find module './.modules/aspire.js'error in the TypeScript view on aspire.dev, while MDX fenced samples (e.g./get-started/first-app/?aspire-lang=typescript) worked fine. Root cause: Starlight's<Code>component resolves expressive-code config throughastro-expressive-code's virtual module, which loses the runtimeextraFilesVFS state in production builds. MDX fences flow throughrehype-expressive-codewith the liveec.config.mjsinstance intact — which is why the two paths diverged in prod but behaved identically in dev (shared Vite module graph).Changes
meta="twoslash"fromAppHostBuilder.astro— it wasn't wanted there anyway, and the component's TS view now renders as plain syntax-highlighted code.src/frontend/src/data/twoslash/aspire.d.tsinstead of producing it transiently under.twoslash-types/. Diffs are reviewable and dev/build startup is faster (no pre-build generation step).scripts/update-ts-api.tssoaspire.d.tsstays in sync withsrc/data/ts-modules/*.jsonwhenever the SDK is re-dumped.pnpm twoslash-typesfromdev/start/buildscripts inpackage.json; the manualpnpm twoslash-typesscript is kept for ad‑hoc refreshes.ec.config.mjs, the vitest generator test,.gitignore, and theupdate-integrationsSKILL.md to match the new location and workflow.Validation
twoslash-types-generator.vitest.test.ts).localhost:4321across all 22 docs pages containing twoslash blocks: 0 twoslash errors, hovers render intact (including/app-host/container-registry/with 194 hovers and/whats-new/aspire-13-2/with 108 hovers).AppHostBuilderTS view now renders without thets(2307)error.Opened as draft for review.