build: stop touching generated types/routes on every build#209
Merged
Conversation
The extract-ts-types.mjs and extract-routes.mjs scripts unconditionally rewrote per-module types.ts and routes.ts on every build, bumping mtimes and triggering downstream Vite rebuilds. Add a writeIfChanged guard so each file is touched only when its content actually differs. Also stop Biome from reformatting the generated routes.ts (Biome wrapping long arrow expressions then the generator re-flattening them was producing a permanent dirty working tree after a fresh build). The committed routes.ts copies are realigned with the generator's output.
Embed scripts/extract-ts-types.mjs and scripts/extract-routes.mjs as EmbeddedResources (matching the validate-pages.mjs pattern) and write them into the scaffold's scripts/ directory. Add matching generate:types and generate:routes npm scripts to the scaffolded root package.json. Also fix the scaffolded biome.json: BiomeJson() previously did a fragile single-line string-replace on the includes array that had silently failed since the monorepo biome.json became multi-line. Replace the entire files.includes block via regex and emit paths that match the scaffolded layout (src/modules/, src/*.Host/ClientApp/), including ignores for the generated types.ts and routes.ts files so Biome doesn't fight the generator in scaffolded projects either.
Deploying simplemodule-website with
|
| Latest commit: |
3148227
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e2a3a568.simplemodule-website.pages.dev |
| Branch Preview URL: | https://types-fix.simplemodule-website.pages.dev |
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
scripts/extract-ts-types.mjsandscripts/extract-routes.mjsnow skip writes when the rendered output already matches the file on disk, so a no-op build no longer bumps mtimes onmodules/*/src/*/types.tsandroutes.ts(which was triggering downstream Vite/MSBuild rebuilds).biome.jsonadds the generatedtypes.tsand bothroutes.tsfiles tofiles.includesignores. Biome had been wrapping long arrow expressions inroutes.ts; the generator then re-flattened them, leaving every working tree dirty after a fresh build. Committedroutes.tscopies are realigned with the generator's output.sm new projectnow ships the same scripts (embedded viaEmbeddedResource, matching thevalidate-pages.mjspattern) and addsgenerate:types/generate:routesnpm scripts wired to the scaffolded layout (src/<Project>.Host,src/modules).ProjectTemplates.BiomeJson(): the single-line string-replace forfiles.includeshad silently been failing since the monorepo'sbiome.jsonbecame multi-line, so scaffolded projects were inheritingmodules/**,packages/**,template/**paths that don't exist in their layout. Replaced with a regex swap that emits the correct scaffolded paths plus the new ignores.Verification
dotnet builds; mtimes on all 13types.tsand bothroutes.tsfiles are byte-identical across runs.DemoAppviasm new project;diff'd the generatedscripts/extract-*.mjsagainst the canonical files — byte-identical (single source of truth via embedded resources).dotnet build(0 warnings),dotnet test --no-build(19 assemblies, 1024 tests),npm run test:smoke(47 specs).Test plan
routes.tsmodified ingit status