Repository navigation
Upgrade kit/ to Svelte 5, SvelteKit 2, Vite 7, Tailwind 4, ESLint 10 - #792
Merged
Merged
Conversation
- Replace the svelteKitCustomClient fork of @sveltejs/kit's client.js with a `reroute` universal hook (src/hooks.js) + a capture-phase click listener in +layout.svelte that canonicalizes shorthand doc links; DOCS_* env vars are now injected via Vite `define` instead of a generated hfDocConsts.js - postprocess.js: extract the hf:doc:metadata tag directly (Svelte 5 dropped the HEAD_svelte-* comment markers) and keep moon-landing's line-1 contract - Tailwind 4: @tailwindcss/postcss, v4 CSS syntax in app.css, legacy config kept via @config, explicit @source "./routes" (gitignored, so skipped by v4 source auto-detection) - ESLint 10 flat config replacing .eslintrc.cjs/.eslintignore - cheerio 1.x namespace import; pin @huggingface/inference to 4.13.15 (newer patches shrink the InferenceProvider union) Verified against a pre-upgrade baseline of the accelerate e2e build: identical metadata/links/ids on all 48 pages, plus a browser smoke test (hydration, SPA nav, shorthand links, HfOptions tabs) on both builds. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`npm install ci` installs a package literally named "ci" and re-resolves
the whole tree from the network; with the upgraded dependency tree this
made npm 10 hang for 8 minutes and crash ("Exit handler never called!"),
leaving node_modules incomplete. Use `npm ci` (lockfile-only, ~20s,
verified on node:20 in docker) and enable the npm cache.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The upgraded lockfile was generated with a user-level npmrc pointing at
npm.registries.huggingface.tech, so every "resolved" URL referenced the
internal mirror. GitHub runners can't reach it — npm hung for its 5-min
fetch timeout and crashed ("Exit handler never called!"), breaking both
the lint and integration workflows. Same dependency versions, all
resolved URLs now registry.npmjs.org.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mishig25
added a commit
that referenced
this pull request
Jul 3, 2026
Svelte 5 raises a hard compile error (node_invalid_placement) when <tr> is a direct child of <table>, which is a common raw-HTML idiom in doc markdown (e.g. hub-docs transformers-js.md) and broke downstream doc builds after #792. Wrap direct-child rows in an explicit <tbody> after mdsvex processing — the resulting DOM is identical to what browsers auto-inserted for the old output. Also silence the new element_invalid_self_closing_tag warning, which md-generated content triggers pervasively (<video ... />, <div ... />). Verified with a full local hub-docs build (268 pages, previously failing). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
mishig25
added a commit
that referenced
this pull request
Jul 3, 2026
…av (#794) After #792, clicking a shorthand doc link (/docs/lib/page) canonicalized the address bar to the full /docs/lib/version/lang/page URL. Restore the old svelteKitCustomClient behavior: SvelteKit still resolves the expanded path internally (partial loading), but once the navigation completes the history entry is rewritten back to the shorthand the user clicked. The anchor's href is also restored right after SvelteKit reads it, and modified clicks (cmd/ctrl/middle) are left untouched so new tabs open the shorthand URL. Caveat: back/forward onto a shorthand history entry falls back to a full page load (the server serves the same page there). Verified with a browser test on the built accelerate docs: shorthand click SPA-navigates AND the address bar shows /docs/accelerate/quicktour. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
mishig25
added a commit
that referenced
this pull request
Jul 3, 2026
Migrated all 110 src/ components with `migrate()` from svelte/compiler ($props/$state/$derived, event attributes, snippets), then hand-finished: - tooltip action rewritten from the removed class API (new Component/$set/ $destroy) to mount/unmount with reactive $state props, in a .svelte.ts module. This FIXES docstring parameter tooltips, which have been silently broken since #792 (`new Tooltip()` throws on Svelte 5 components; hover handlers swallowed the error). Verified against the Svelte 4 baseline. - FrameworkContent, InferenceApi, TokenizersLanguageContent intentionally stay in legacy syntax: their named slots collide with same-named props, which snippets cannot express; mixing legacy and runes is supported. - svelte/legacy shims (preventDefault/stopPropagation/handlers) replaced with plain event handlers; component prop types moved from constructor signatures to `Component<...>`. - `state_referenced_locally` warnings silenced in onwarn: initial-value capture matches the previous Svelte 4 semantics (doc pages pass static props), and they'd flood every downstream doc build log. Verified: svelte-check 0 errors; accelerate e2e output equivalent to the Svelte 4 baseline (identical metadata/links/ids, known whitespace-only diffs); hub-docs build (268 pages) byte-identical on all compared dimensions vs pre-migration; browser tests pass (hydration, SPA nav, shorthand URLs, HfOptions tabs, docstring tooltips mount/unmount). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
4 tasks done
coyotte508
pushed a commit
that referenced
this pull request
Aug 25, 2026
* fix: escape HTML and strip ANSI codes in notebook-to-mdx text outputs Cell outputs were wrapped in <pre> without escaping, so tag-like text (e.g. `--model-id <MODEL_ID>` from a CLI help dump, or object reprs like `<transformers.Trainer object at 0x...>`) reached the Svelte compiler as raw markup. Svelte 4 tolerated the unknown elements; after the kit upgrade to Svelte 5 (#792) they fail the build with 'Expected a valid element or component name', which currently breaks every cookbook PR doc build. Also strip ANSI escape sequences (colors, cursor control), which rendered as garbage characters inside the <pre> blocks. Verified by converting all 71 cookbook en notebooks: no tag-like text and no ANSI sequences remain inside any generated <pre> block. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * style: sort import block (ruff I001) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
mishig25
pushed a commit
that referenced
this pull request
Aug 26, 2026
The `reroute` hook expands shorthand doc URLs to the full route, and its
language matcher only accepted `xx` or `xx-XX`. A code like `pt-br` fails
that test, so the language segment is never shifted off the path and ends
up in the chapter id, while `_lang` falls back to the current language and
still satisfies the equality checks:
/docs/smol-course/pr_306/pt-br/unit1/1
-> /docs/smol-course/pr_306/pt-br/pt-br/unit1/1 (404)
SvelteKit applies `reroute` during prerendering too, so every page of such
a language 404s and the build aborts on the first one. Before the kit
upgrade to Svelte 5 (#792) this logic lived in a fork of SvelteKit's
client and never ran at build time.
huggingface/smol-course is the only repo in the org with a lowercase
region (`pt-br`); `zh-CN`, `ru-RU` and `pt-BR` already matched.
Verified by building `smol-course/units/pt-br` with `--html`: 14 pages
404 and the build exits 1 before the change, and it exits 0 with all 14
HTML files after it. Building `units/ko` still passes.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
coyotte508
pushed a commit
that referenced
this pull request
Sep 24, 2026
…828) Since #792 the shorthand-link canonicalizer in +layout.svelte rewrites the clicked anchor's pathname in the DOM. For course pages served at hf.co/learn/<course>/... it turned /learn/agents-course/unit1/tools into /docs/agents-course/main/en/unit1/tools before the Hub's own link handler read it, so the Hub fetched /api/docs/agents-course/main/en/unit1/tools (404, courses live under /api/learn/) and fell back to a full navigation to the /docs URL, which is also a 404 for courses. Only agents-course was rebuilt with the new kit so far (2026-09-09) and every sidebar / next-page click there ends on a 404 (agents-course#736, #737). Leaving /learn links untouched restores the previous behavior: the Hub handles them via /api/learn/<course>/<page>. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Sep 30, 2026
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
Upgrades the whole
kit/toolchain: Svelte 4 → 5.56, SvelteKit 1.20 → 2.68, Vite 4 → 7.3, Tailwind 3 → 4.1, ESLint 8 (.eslintrc) → 10 (flat config), latest Prettier plugins, svelte-check 4, mdsvex 0.12.Highlights
svelteKitCustomClient/is gone 🎉The ~2,100-line fork of SvelteKit's
client.js(which existed to make shorthand doc URLs like/docs/lib/pagepartial-load instead of full-reload) is replaced by ~40 lines of public API:src/hooks.js— SvelteKit 2'srerouteuniversal hook, expanding shorthand paths to the built library/version/lang route.+layout.sveltethat canonicalizes shorthand anchor hrefs before kit's router reads them (needed because kit's external-URL check runs beforereroutefor URLs outsidepaths.base).DOCS_LIBRARY/DOCS_VERSION/DOCS_LANGUAGEare injected via Vitedefineinstead of a generated file insidenode_modules, so thecustom-svelte-clientnpm script is gone too. No more re-porting the fork on every kit upgrade.One visible behavior change: clicking a shorthand link now shows the canonical full URL (
/docs/lib/main/en/page) in the address bar instead of keeping the shorthand. Navigation is still client-side (verified, see below).Other adaptations
postprocess.js: Svelte 5 no longer emits<!-- HEAD_svelte-*_START -->markers, so thehf:doc:metadatatag is extracted directly; the moon-landing line-1 contract (line 1 = charset + metadata meta, rest = page component) is preserved, including moving the head<link>kit 2 renders inline back to line 2.@tailwindcss/postcss;app.cssrewritten to v4 syntax (@utilityinstead of@variants,!suffix, slash-opacity instead of--tw-bg-opacity) plus the documented v3-compat base styles. The legacytailwind.config.cjstheme is kept via@config; plugins load via@plugin. Utility class names in markup are untouched (prod CSS is emptied and comes from the hub build)..gitignore, which excludessrc/routes(doc pages are pasted there at build time) — added@source "./routes"sodoc-builder previewkeeps its styles.@huggingface/inferencestays lock-pinned at 4.13.15: newer patches shrink theInferenceProvidertype union and breakInferenceSnippet.svelte; bump deliberately vianpm run update-inference-providers.Verification
Baseline accelerate e2e build (same as
accelerate_doc.yml) was run on the old stack first, then compared against the upgraded build:hf:doc:metadata, hrefs, image srcs, heading ids, code-block counts. Only diffs: Svelte 5 trims some trailing whitespace in text nodes (invisible), and Python<object object at 0x…>addresses in docstring signatures that differ between any two runs.svelte-check: 0 errors ·prettier --check: clean ·npm ci && npm run buildexercised through the full doc-builder python pipeline.Note:
npx eslint .reports 39 pre-existing violations (no-shadow,no-explicit-any, non-null assertions) that the old.eslintrcalso declared but never enforced in CI — left untouched here to keep the diff reviewable; happy to fix in a follow-up.🤖 Generated with Claude Code