fix(content): only collect required translations #8806
Merged
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
Trying to fix and as a part of #8301
Gather all translation would slow down the static document build in translated-content. Only gather the translations of the incoming slug might be a better idea.
Problem
After we migrating to ESM, the PR-test ci in translated-content would spend more than 25 seconds to build a single document (as in most of PRs, the number of changed documents is only
1
). The most of time during a build is spent ongathering all translations
(as metioned in #8301).Solution
Try to gather the translations of a required slug only, this should save most of the time for build a single document.
Using a locale build of
yari
to check the build time.Run
yarn build files/en-us/learn/common_questions/web_mechanics/what_is_a_web_server/index.md
and
node node_modules/@mdn/yari/build/cli.js files/zh-tw/learn/common_questions/web_mechanics/what_is_a_web_server/index.md
to build document.Screenshots
Before
~16
seconds are used to build a single document.After
~1
seconds are used to build a single document.run
yarn start
in content