Repository navigation
feat(docs): ship the translated docs mirrors in the npm package and Docker image - #18869
Conversation
…ocker image The /docs route serves docs/i18n/<locale>/docs/<section>/<PAGE>.md when the NEXT_LOCALE cookie asks for it (#18768), but npm and Docker installs carried no mirrors and always fell back to English. - scripts/build/docsMirrorRuntime.mjs defines the mirrors the route can serve: the sections source.config.ts compiles, minus its operator-internal pages. - The pack policy allows exactly those under dist/ (path matchers), requires one sample mirror, and prepublish keeps them while pruning the rest of docs/i18n. - .dockerignore re-includes the same set; assembleStandalone already colocates jsdom when a bundle carries mirrors. - jsdom moves to dependencies: npm never packs node_modules, so the sanitizer import would otherwise fail on every npm install. - check:pack-boot asserts the installed package has a mirror and jsdom.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
…docs-mirrors-npm-docker-1103
❌ Left the queue · checks interrupted13 min in the queue, 1 min of it CI. So far
Reason The merge conditions cannot be satisfied: the checks were interrupted before producing a result
Failing checks:
Hint An interrupted check reported no result, so it says nothing about this pull request. Merge conditions not met when it left the queue
Tick the box to put this pull request back in the merge queue (same as
1 merge condition met
Times in UTC · dashboard · how the merge queue works |
…docs-mirrors-npm-docker-1103
CI Coverage Report
Coverage artifact was not available for this run. |
#18768 made
/docs/<section>/<PAGE>serve the translated mirror when theNEXT_LOCALEcookie asks for it, but npm and Docker installs carried no mirrors, so they always served English. The owner decided both should ship them. This PR does that, and ships only the mirrors the route can actually serve.What ships
scripts/build/docsMirrorRuntime.mjsdefines the set:docs/i18n/<locale>/docs/<section>/<PAGE>.mdfor the 11 sectionssource.config.tscompiles, minus the 4 operator-internal security pages it excludes (STEALTH_GUIDE,SOCKET_DEV_FINDINGS,MITM-TPROXY-DECRYPT,PUBLIC_CREDS). On the current tree that is 8,885 files. The README, CHANGELOG, AGENTS/CLAUDE/GEMINI,llm.txtand other locale-root mirrors, plus thefeatures/andplans/mirrors the route never reaches, stay out. The renderer loads images from raw.githubusercontent.com, so no local asset is needed.npm
pack-artifact-policy.tsgets path matchers next to its exact and prefix lists. The staging prune and the publish gate both allow exactly that set underdist/, nothing else underdocs/i18n, and never at the tarball root. Every other guard is unchanged: node_modules ban, test leaks, MCP closure, provenance.dist/docs/i18n/pt-BR/docs/getting-started/QUICK-START.mdis now a required path, so the gate fails if the mirrors stop reachingdist/. They arrive through the standalone'sdocs/copy, which already happened, and were pruned until now.jsdommoves from devDependencies to dependencies.docsSanitizer.tsimports it, and npm never packsnode_modules, so on an npm install the import failed and every translated page fell back to English. The lockfile diff only moves the root entry and drops"dev": truefrom jsdom and the 33 packages it pulls in (36.6 MiB on disk). No versions changed.check:pack-bootnow also asserts that the installed package has a mirror andnode_modules/jsdom.Docker
.dockerignorekeepsdocs/i18n/**, re-includes the 11 sections with!docs/i18n/*/docs/<section>/**/*.md, then re-excludes the 4 security pages. Docker applies these rules in order and the last match wins.COPY . ./brings the mirrors in,build-next-isolatedcopiesdocs/into the standalone, andassembleStandalonealready colocates jsdom whenever the bundle hasdocs/i18n(fix(docs): serve translated /docs pages for the selected locale #18768). The builder'snpm ciinstalls dev dependencies, so jsdom is there either way. The runner copies the whole standalone.Dockerfile.bunfollows the same path.Sizes
npm install -g)docs/i18nFor reference, the published 3.8.52 tarball is 114,391,796 B with 29,296 entries. The Docker numbers come from evaluating
.dockerignorestatically. I couldn't build the image here because there is no Docker daemon, so the image delta is estimated: the runner gets the same 374 MB through the standalone copy, plus jsdom's closure.Pack and install time
Measured on a shared 18-core machine with load between 7 and 58 while other sessions were building, so treat these as rough:
build:clinpm pack(staged copy, see below)npm install -gfrom the tarballnpm packrun straight from the worktree went past 40 minutes without finishing. With the inspector attached, npm-packlist's ignore-walk was spending its time in minimatch, matching every entry against the ignore rules, anddist/.build/next/server/chunksalone has 20,615 entries. I packed a copy staged fromfiles[]instead, with node_modules left out (npm never packs it). The before and after times are about the same because the 8,885 new files are small directories that cost far less than that chunk directory. This is relevant to #18791 (check:pack-artifacttiming out): the cost is in the walk overdist/.build, not in this change.Live test
I installed each tarball into a temporary prefix outside the repo, started
omniroute servefrom there on its own port with an isolatedDATA_DIR, and stopped it by its process group when done.getting-started/QUICK-STARTlang=enlang=engetting-started/QUICK-STARTpt-BRlang=pt-BRgetting-started/QUICK-STARTfadir=rtldir=rtlgetting-started/QUICK-STARTxxlang=enlang=enarchitecture/RESILIENCE_GUIDEpt-BRgetting-started/SELF_HOST_GUIDE(nofamirror)falang=fa,dir=rtlsecurity/PUBLIC_CREDSpt-BRThe installed package also passes the publish policy's checks on the real tarball listing: no unexpected paths, nothing required missing, and no test leaks.
Tests
tests/unit/docs-mirror-runtime-shipping.test.ts:source.config.ts;docs/i18ntree (10,273 files);.dockerignore, evaluated with Docker's ordering and parent-directory rules, lets exactly that set into the context;tests/helpers/dockerignore.tsholds that Docker-semantics evaluator.dockerignore-docs-coverage.test.tsnow uses it in place of its own matcher, which ignored rule order and so would have let the security mirrors through. Its "excludes the heavy i18n tree" assertion now checks the locale-root andplans/mirrors, plus that a page mirror is included, because the old assertion is exactly the behavior the owner changed.pack-artifact-policy.test.ts: its pinned missing-required list gains the new required path.check-pack-boot.test.ts: covers the new runtime contract.assemble-standalone-docs-sanitizer-18699.test.ts: comments and one test name updated to say that Docker now carries mirrors. The assertions are unchanged.No size ceilings changed. I found no tarball size or file-count budget in the repo. The pack gate's only limit is the Release-Green 60 min timeout, and
check:build-scopecounts only TS/JS files (12,620 of 13,500).Ran: the focused unit files above plus electron-packaging, the pack closure suites and log-export-child-runner (all pass); the vitest suite
docs-translated-page-18699(16/16);check:build-scope;check:docs-all; Prettier and ESLint on the changed files (0 errors).Not verified
check:pack-artifactandcheck:pack-policywere not run as scripts, because they call the same slownpm pack --dry-runwalk. I applied their path checks to the real tarball listing instead. The MCP closure check was not rerun; this change doesn't touch the MCP files.docs/i18n/<locale>/docs/**, including the security-page mirrors this PR keeps out of npm and Docker.Docs
docs/guides/I18N.mdhas a new "Translated/docspages" subsection. Its 66 mirrors are not updated here.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.