Skip to content

Conversation

@YDX-2147483647
Copy link
Member

@YDX-2147483647 YDX-2147483647 commented Dec 4, 2025

Note

This PR is ready for review, but let's resolve typst-jp/docs#335 first.

At present, it's impossible to use en-US translation without a discord URL, because the ja-JP translation is always imported and it will throw the error below.

[vite] (ssr) Error when evaluating SSR module ./src/index.tsx: The ja-JP translation requires to provide both GitHub and Discord social links in metadata.json, but at present: GitHub = https://github.com/typst/typst, Discord = undefined.

This PR fixes it by making the import lazy.

Links

An alternative approach: typst-jp/docs#303 (comment)

Blocks #21

@netlify
Copy link

netlify bot commented Dec 4, 2025

Deploy Preview for typst-docs-web ready!

Name Link
🔨 Latest commit ea5fce6
🔍 Latest deploy log https://app.netlify.com/projects/typst-docs-web/deploys/6933086eb9b4ea0008aa2c9f
😎 Deploy Preview https://deploy-preview-43--typst-docs-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@YDX-2147483647 YDX-2147483647 force-pushed the no-config branch 2 times, most recently from af184c8 to 5f2d7a0 Compare December 4, 2025 04:12
@YDX-2147483647 YDX-2147483647 marked this pull request as ready for review December 4, 2025 04:15
@3w36zj6
Copy link
Member

3w36zj6 commented Dec 5, 2025

I've updated typst-jp. The preview build should now succeed.

@YDX-2147483647
Copy link
Member Author

YDX-2147483647 commented Dec 5, 2025

The Netlify build still fails, because I forgot to update the metadata format in netlify-build.sh.
Since you've already extracted the logic into scripts/fetch-docs-assets.sh in #41, could you cherry-pick that commit (7fefd7d78d) into a dedicated PR? I'll rebase this PR after that PR is merged.

@3w36zj6 3w36zj6 changed the title refactor: import translations lazily fix: import translations lazily Dec 6, 2025
@3w36zj6 3w36zj6 requested a review from Copilot December 6, 2025 07:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements lazy loading of translation modules to prevent build failures when using en-US translation without optional social metadata (Discord URLs). The ja-JP translation requires both GitHub and Discord social links, while en-US does not. By switching from static imports to dynamic imports, each translation is only loaded when needed, avoiding errors when building for languages that don't require special metadata.

Key Changes:

  • Replaced static imports with lazy dynamic imports in the translation module, using top-level await with an IIFE to conditionally load the appropriate translation based on the configured language
  • Removed dummy Discord URL from test metadata, demonstrating that en-US builds no longer require it
  • Enhanced the fetch-docs-assets.sh script with a --skip option to selectively skip downloading specific assets (docs.json, docs-assets, favicon, metadata), enabling more flexible build configurations

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/translation/index.tsx Converts static translation imports to lazy dynamic imports using top-level await, with detailed comments explaining the rationale for lazy and static import constraints
src/metadata.ts Removes dummy Discord social link from test fallback metadata, validating that en-US translation works without Discord URLs
scripts/fetch-docs-assets.sh Adds --skip option with validation to selectively skip downloading docs.json, docs-assets, favicon, or metadata files; updates usage documentation
scripts/netlify-build.sh Uses the new --skip flags to avoid downloading docs.json and metadata when building ja-JP, since those are fetched separately
.github/workflows/ci.yaml Adds no-config test matrix to verify builds work without optional metadata; uses --skip flags for metadata and favicon in this configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants