Repository navigation
🍕 vite: write dev templates to the same 6 files as production - #289
Merged
Merged
Conversation
Kiln edit mode loads every template. Dev builds wrote one <name>.template.js per template (638 requests on sites); minified builds write six _templates-*.js files. Dev builds now write those six files too, unminified, and remove leftover *.template.js files, so a site that globs both layouts no longer loads every template twice. A template that fails to compile during watch keeps its last good version instead of dropping out of its file.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Conflict in CLAY-VITE.md: kept master's CSS wording from #277 and this branch's template output wording.
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.
What does this PR do?
Dev builds of
clay vitenow write Handlebars templates to the same sixpublic/js/_templates-{a-d,…,u-z}.jsfiles as minified builds, just not minified, instead of one<name>.template.jsper template. Each build also removes leftover*.template.jsfiles. In watch mode, a template that fails to compile keeps its last good version in its file.No issue: a sites developer asked why Kiln edit mode downloads every
.template.jsfile.Why are we doing this? Any context or related work?
Kiln edit mode needs every template: it re-renders components in the browser and can add components that aren't on the page. So a dev build of sites put 638 template
<script>tags on every edit page. In Chrome, those 638 files took 104–110 ms to run, against 23–26 ms for the same code in six files. sites globs both layouts, so a checkout holding both loaded every template twice.Where should a reviewer start?
writeOutputinlib/cmd/vite/templates.js. Minified output is unchanged.Manual testing steps?
jestand eslint pass (31 suites, 675 tests). Removing the leftover cleanup or the last-good fallback each makes a new test fail.Screenshots
None.
Additional Context
clay compile(Browserify) still writes one file per template in dev, and sites' local default is still Browserify. Devs see this change only on the Vite pipeline.